baconDelta
01-26-2012, 10:31 PM
i wrote a little comment system and made a db just for storing comment info. everything works except if i try to store the url from which the comment is made, which is the most important part! i get a syntax error and i haven't been able to figure out what i'm doing wrong.
//captcha code, if they fail blah blah, below is what happens if they pass the recaptcha.
} else {
$name = $_POST['name'];
$comment = $_POST['comment'];
$this_guy = $_SERVER['REMOTE_ADDR'];
$this_time = date("y/m/d : H:i:s", time());
$from = $_SERVER["REQUEST_URI"];
require_once("../functions/connection_comments.php");
$query="INSERT INTO data (From, Name, Comment, IP, TIME)
VALUES('$from','$name','$comment', '$this_guy','$this_time')";
if (!mysql_query($query,$connection))
{
die('<br />Error: ' . mysql_error());
}
my column names all match up to the insert string above, and everything is stored correctly if i tell it not to insert to 'From'. but storing the page of the comment is crucial!
i had the From column as a VARCHAR, but switched it to TEXT and get the same error. the error i'm getting with the above code is:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'From, Name, Comment, IP, TIME) VALUES('/r/0','tester','hey im a te' at line 1
//captcha code, if they fail blah blah, below is what happens if they pass the recaptcha.
} else {
$name = $_POST['name'];
$comment = $_POST['comment'];
$this_guy = $_SERVER['REMOTE_ADDR'];
$this_time = date("y/m/d : H:i:s", time());
$from = $_SERVER["REQUEST_URI"];
require_once("../functions/connection_comments.php");
$query="INSERT INTO data (From, Name, Comment, IP, TIME)
VALUES('$from','$name','$comment', '$this_guy','$this_time')";
if (!mysql_query($query,$connection))
{
die('<br />Error: ' . mysql_error());
}
my column names all match up to the insert string above, and everything is stored correctly if i tell it not to insert to 'From'. but storing the page of the comment is crucial!
i had the From column as a VARCHAR, but switched it to TEXT and get the same error. the error i'm getting with the above code is:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'From, Name, Comment, IP, TIME) VALUES('/r/0','tester','hey im a te' at line 1