Woodie Posted September 9, 2003 Share Posted September 9, 2003 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? Quote Link to comment https://forums.phpfreaks.com/topic/998-update-help/ Share on other sites More sharing options...
PHPcadet Posted September 9, 2003 Share Posted September 9, 2003 The words \"table\" and \"tables\" are reserved words in MySQL. Not sure if that\'s your problem. Quote Link to comment https://forums.phpfreaks.com/topic/998-update-help/#findComment-3378 Share on other sites More sharing options...
Woodie Posted September 9, 2003 Author Share Posted September 9, 2003 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\' Quote Link to comment https://forums.phpfreaks.com/topic/998-update-help/#findComment-3382 Share on other sites More sharing options...
PHPcadet Posted September 9, 2003 Share Posted September 9, 2003 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. Quote Link to comment https://forums.phpfreaks.com/topic/998-update-help/#findComment-3383 Share on other sites More sharing options...
metalblend Posted September 9, 2003 Share Posted September 9, 2003 Remember, ORDER BY is fairly new to UPDATE queries (introduced in 4.0.0).. be sure your host has MySQL 4 or later. Other than that, there are no syntax errors in your query. Quote Link to comment https://forums.phpfreaks.com/topic/998-update-help/#findComment-3384 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.