Jump to content

Mysql SYNTAX error - please help!


donnan

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/230575-mysql-syntax-error-please-help/
Share on other sites

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

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.