Problem with updating a record
Posted: Tue May 06, 2003 5:29 pm
To start with uname is the username and is a number. At the bottom of the code I echo all of the variables to see if they are correct. It displays them all correctly.
Update.php is called from a page called edit.php which has a form and a submit button. The variable are passed from edit.php to update.php with the exception of the username, which is retrieved from a cookie that is set at login.
==== update.php ====
<?
mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db($db_name);
$result = mysql_query("UPDATE $db_table SET uname='$_COOKIE[USERNAME]', pass2=$password, email=$email WHERE uname='$_COOKIE[USERNAME]''")or DIE($result .' :'.mysql_error());
print '
<center>Variable Values</center><br>
<center><table border=1 bordercolor = "blue">
<tr>
<td> Username: </td>
<td>' . $_COOKIE[USERNAME] . '</td>
</tr>
<tr>
<td> Password: </td>
<td>' . $password . '</td>
</tr>
<tr>
<td> E-mail address: </td>
<td>' . $email . '</td>
</tr>
<tr>
<td> SQL: </td>
<td>' . $result . '</td>
</tr>
</table></center>';
?>
==== end of code ====
This is the error message I get when I run the update.
:You have an error in your SQL syntax near '@4-webdesign.net WHERE uname='14298691''' at line 1
The 14298691 is the username of a particular user and the @4-webdesign.net is the last part of that users email address.
If anyone has any ideas I would be forever greatful.