Hello,
I am having trouble getting a MySQL UPDATE SET query to work. The query is being sent from a web page using PHP to deliver the comand. Below is the snippit of code that is trying to perform an update. I know the $conn = my_conn; works to connect me to the db, besides which, the error that I am getting (see error at bottom of message) is a syntax error and not a connection error as indicated by the error message.
The snippit of code shown below is contained withing a function which I know is being called correctly as I CAN get it to echo something to the screen when called with an echo inside the function as a test.
$conn = my_conn();
/* DEFINE QUERIES THAT WILL APPEND DATA BEING SENT FROM */
/* get_data() (above) INTO THE VARIOUS FIELDS IN THE DTATABASE. */
$sql_update = "UPDATE client SET ";
$sql_update .= "client.client_id = '" . $_REQUEST['client_id'] . "', ";
$sql_update .= "client.client_name = '" . $_REQUEST['client_name'] . "', ";
$sql_update .= "WHERE client.client_id = " . $_REQUEST['client_id'] . ")";
// ----------------------------
// END DEFINE QUERIES....
// ----------------------------
// ----------------------------------
// PASS QUERY (above) TO DATABASE.
// ----------------------------------
$result = mysql_query($sql_update, $conn);
if (!$result) {
echo("
Error performing query: " . mysql_error() . "</p>");
exit();
}
/* Prints succes message */
print "
Successfully Updated</p>";
/* closes connection */
mysql_close ($conn);
____________________
THE ERROR MESSAGE
____________________
Error performing query: You have an error in your SQLsyntax near 'WHERE client.client_id = 1)' at line 1
___________________
END ERROR MESSAGE
___________________
client_id is a field within the table 'client' and is set as an integer as well as the primary key and was set to null upon creation.
I have been looking at various examples of the syntax to be used for what I am trying to accoplish and while I can understand how most of what I've seen works, those examples do not resemble the example I have shown above (which I tweaked slightly from the following exaple:
http://www.keithjbrown.co.uk/vworks/php/php_p5.php). Take a look at the syntax the auther of that exmple uses and you should see that it is the same?
Any assistance I can get in determining why I still get the error would be appreciated. I have tried many different variotions of the WHERE clause to try and fix but can't get rid of the darnd error.
Thanks in advance!
Soulfolk