whelpton Posted April 3, 2008 Share Posted April 3, 2008 Hi, i am trying to create a script to update my MYsql Table. As far as I know this should work I dont understand why it dosnt. <?php $do = mysql_query("UPDATE Users SET kmail address = ".$_SESSION['s_username']." WHERE username = ".$_SESSION['s_username']." LIMIT 1") or die(mysql_error()); $dotwo = mysql_query("UPDATE Users SET kmail = 1 WHERE username = ".$_SESSION['s_username']." LIMIT 1") or die(mysql_error()); if((($do)&&($dotwo))) { echo '<script>alert("Email changed. You will now be logged out and you must re-activate your account, check your email, a confirmation email has been sent.");</script>'; echo '<script>location.replace("logout.php");</script>'; exit; } else { echo '<script>alert("There appears to have been an error in the script. 1 or 2 of 3 things may have happened:\n\n• Your email could have been reset/changed\n• Your account could have been deactivated, see the resend validation email page\n• Your email may not have been sent.\n\nYou will now be logged out, if you are unable to login or cannot resend the validation email to either addresses, please contact the administrator.\n\nWe are sorry for the inconvenience.");</script>'; echo '<script>location.replace("logout.php");</script>'; exit; } ?> That is my code for updating, and I get the 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 'address = test WHERE username = test LIMIT 1' at line 1 Thanks alot Link to comment https://forums.phpfreaks.com/topic/99306-mysql-errors/ Share on other sites More sharing options...
almightyegg Posted April 3, 2008 Share Posted April 3, 2008 $do = mysql_query("UPDATE Users SET kmail address = '{$_SESSION['s_username']}' WHERE username = '{$_SESSION['s_username']}' LIMIT 1") or die(mysql_error()); // note the chage is the way the $_SESSION is written You'll get the same problems with other things ones too but use the same logic. That should do it Link to comment https://forums.phpfreaks.com/topic/99306-mysql-errors/#findComment-508097 Share on other sites More sharing options...
whelpton Posted April 3, 2008 Author Share Posted April 3, 2008 Thank you so much for your help =) You guys are awsome Link to comment https://forums.phpfreaks.com/topic/99306-mysql-errors/#findComment-508100 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.