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
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

Link to comment
Share on other sites

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.  :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.