Jump to content

[SOLVED] Syntax error in updating script...


Alecdude

Recommended Posts

Ok, I'm a bit lost. The code:

if ($_POST['Submit']=='Update')
{
  $profile = $_POST['Desc'];
  
  mysql_query("UPDATE users SET Desc='".$Desc."' WHERE id=".$_SESSION['user_id']."") or die(mysql_error());
  header("Location: myaccount.php?msg=Profile Description Updated!");				
}

 

And it generates this 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 'Desc='Testing, 123 testing...' WHERE id=47' at line 1

 

Help?

Link to comment
https://forums.phpfreaks.com/topic/137299-solved-syntax-error-in-updating-script/
Share on other sites

Desc is a reserved word. Encapsulate it in backticks(`) or better yet change that column name.

 


if ($_POST['Submit']=='Update')
{
  $profile = $_POST['Desc'];
  
  mysql_query("UPDATE users SET `Desc`='".$Desc."' WHERE id=".$_SESSION['user_id']."") or die(mysql_error());
  header("Location: myaccount.php?msg=Profile Description Updated!");


}

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.