Make sure that the field names are correct. Anyway, post the codes above of these three lines. It may easy to find the problem quickly.
Zero13
Practically a Master Poster
624 posts since Jan 2009
Reputation Points: 120
Solved Threads: 139
try:
$sql = mysql_query("UPDATE joke SET joketext='$text' WHERE id='$id'") or die( mysql_error() );
notice the apostrophes around the value of $id
hielo
Veteran Poster
1,124 posts since Dec 2007
Reputation Points: 116
Solved Threads: 244
I always get this error:
"Error updating joke: 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 '1' at line 1"
There's something about this part of my code that causes that error and I just can't figure out what that is. help please :(
$id = mysql_real_escape_string($_POST['id']);
$text = mysql_real_escape_string($_POST['text']);
$sql = mysql_query("UPDATE joke SET joketext='$text' WHERE id=$id");
comment the above codes and replace with this and post its output
$id = mysql_real_escape_string($_POST['id']);
$text = mysql_real_escape_string($_POST['text']);
$sql = mysql_query("UPDATE joke SET joketext='$text' WHERE id=$id");
print_r($_POST);
echo "";
echo $sql;
die();
evstevemd
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 462
Solved Threads: 392