Jump to content

Update help


Woodie

Recommended Posts

need a little guidance if anyone can help!

 

I want to update just a selection of rows based on some information given to the query.

 

My update statement reads as follows....

 

UPDATE table SET fieldx = fieldx+1 WHERE fieldx = \'$value\' ORDER BY fielda DESC LIMIT 4;

 

now this is done in a php script that generates $value from another query to the same table before this update query is attempted!

 

that query is as follows..

 

SELECT * FROM table WHERE filedy = \'$val\' ORDER BY fielda DESC;

 

and $val is user defined an not null!

 

I am using php 4.0 (on the server I use but I have no admin priviledges!)

 

is there something I\'m missing with the LIMIT statement?

Link to comment
Share on other sites

The tables are not actually called that. Sorry I did not make that easy for anyone did I!

 

The table is Called Uses! When I try to run the command on myphpadmin (v2.5.....) an erro is returned saying I have a syntax error in \'ORDER BY fileda DESC LIMIT 10\'

Link to comment
Share on other sites

Check the spelling of your column names. In the error message it says \"fileda\". In your UPDATE statement it says \"fielda\". I notice with MySQL and other languages, the error messages aren\'t always exact, meaning you should look \"around\" the code for the eror, sometimes it is before, sometimes it is after. Hope this helps.

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.