donnan Posted March 14, 2011 Share Posted March 14, 2011 Hi guys, My server mysql version is 5.1.55 I have been pulling my hair out trying to figure where I have got the syntax wrong with this one. mysql_query("UPDATE `gemps_shares` SET `given_gemps` = given_gemps + " . $gemps . ", `total_gemps` = given_gemps + link_gemps WHERE `user_id` = '$_REQUEST[user_id]' AND `user_id` = '$_REQUEST[owner_id]'") or die (mysql_error()); I am just trying to add values from field `given_gemps` to a int variable $gemps, then getting a total by adding `given_gemps` field to `link_gemps` field and settting `total_gemps` field with the result. It's got me where I have gone wrong. I think I have tried everything. Maybe it's something really simple. Thanks in advance for your help and guidance. Quote Link to comment https://forums.phpfreaks.com/topic/230575-mysql-syntax-error-please-help/ Share on other sites More sharing options...
kickstart Posted March 14, 2011 Share Posted March 14, 2011 Hi Nothing jumps out at me (except the logic of checking that user_id is the same as 2 different variables). Can you echo out the sql to see what it really looks like with the variables in place. Also it is normally a really bad idea to use user input (ie, $_REQUEST variables in this case) in SQL without using mysql_real_escape_string. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/230575-mysql-syntax-error-please-help/#findComment-1187287 Share on other sites More sharing options...
donnan Posted March 14, 2011 Author Share Posted March 14, 2011 Hi Keith, Thanks for your reply mate. I found the syntax error was being caused because of an ealier query that wasn't getting correct data to apply to this query. I am learning though. Thanks again for your help. Most appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/230575-mysql-syntax-error-please-help/#findComment-1187305 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.