Jump to content

mysql errors


whelpton

Recommended Posts

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

$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

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.