jeff5656 Posted July 9, 2012 Share Posted July 9, 2012 When i try to update a record, it does not get updated. $qq = "update dos set completed = 'rejected', rejectreason='$rejectreason' where dos_id = '$dosid' LIMIT 1"; mysql_query($qq) or die(mysql_error()); the field that is called "completed" is an enum: CREATE TABLE IF NOT EXISTS `dos` ( `dos_id` int(254) NOT NULL AUTO_INCREMENT, [...] `completed` enum('n','y','rejected') NOT NULL, etc. So when I try to change the "completed" field to "rejected" it does not update but when i update it to either an "n" or a "y" it works. Does anyone see any problems? It's weird. I can also manually change it to "rejected" within phpmyadmin. Also when I echo $qq, the dos_id (and $dosid) is correct, but that record is not being updated. That record still has a "n" instead of "rejected". Quote Link to comment https://forums.phpfreaks.com/topic/265437-wont-update/ Share on other sites More sharing options...
redarrow Posted July 9, 2012 Share Posted July 9, 2012 http://dev.mysql.com/doc/refman/5.0/en/enum.html let also check if completed is a reserved name for mysql. http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html not seen nothing yet thinking. Quote Link to comment https://forums.phpfreaks.com/topic/265437-wont-update/#findComment-1360300 Share on other sites More sharing options...
jeff5656 Posted July 9, 2012 Author Share Posted July 9, 2012 The other interesting thing is the other field DOES get updated correctly (rejectreason). Quote Link to comment https://forums.phpfreaks.com/topic/265437-wont-update/#findComment-1360301 Share on other sites More sharing options...
redarrow Posted July 9, 2012 Share Posted July 9, 2012 try with no '<<< acts like a LIKE then see what happens? $qq = "update dos set completed = rejected, rejectreason='$rejectreason' where dos_id = '$dosid' LIMIT 1"; mysql_query($qq) or die(mysql_error()); echo out the input see what happening. echo $qq; Quote Link to comment https://forums.phpfreaks.com/topic/265437-wont-update/#findComment-1360303 Share on other sites More sharing options...
Pikachu2000 Posted July 9, 2012 Share Posted July 9, 2012 I take it you aren't getting any errors, right? If you echo the query string, and paste it in to phpMyAdmin or the MySQL CLI, does it work as it should? Quote Link to comment https://forums.phpfreaks.com/topic/265437-wont-update/#findComment-1360304 Share on other sites More sharing options...
redarrow Posted July 9, 2012 Share Posted July 9, 2012 $ <<<<<<< missing? $ add the >>>rejected Quote Link to comment https://forums.phpfreaks.com/topic/265437-wont-update/#findComment-1360307 Share on other sites More sharing options...
jeff5656 Posted July 9, 2012 Author Share Posted July 9, 2012 Ok I feel really stupid about this especially with everyone chiming in to help. That update statement was up at top of the page under an if (isset(_post). right below that was another IF line that was true, containing a query to update completed to n!! So it WAS updating to "rejected" and then a second query 4 lines down was updating it to "n"! Sorry to waste everyone's time LOL! Quote Link to comment https://forums.phpfreaks.com/topic/265437-wont-update/#findComment-1360311 Share on other sites More sharing options...
Pikachu2000 Posted July 9, 2012 Share Posted July 9, 2012 try with no '<<< acts like a LIKE then see what happens? $qq = "update dos set completed = rejected, rejectreason='$rejectreason' where dos_id = '$dosid' LIMIT 1"; mysql_query($qq) or die(mysql_error()); What are you talking about? Removing the quotes from 'rejected' will attempt to set the `completed` field to the value of the `rejected` field if one exists, and has nothing to do with a LIKE comparison. Quote Link to comment https://forums.phpfreaks.com/topic/265437-wont-update/#findComment-1360312 Share on other sites More sharing options...
redarrow Posted July 9, 2012 Share Posted July 9, 2012 try with no '<<< acts like a LIKE then see what happens? $qq = "update dos set completed = rejected, rejectreason='$rejectreason' where dos_id = '$dosid' LIMIT 1"; mysql_query($qq) or die(mysql_error()); ok what ever. What are you talking about? Removing the quotes from 'rejected' will attempt to set the `completed` field to the value of the `rejected` field if one exists, and has nothing to do with a LIKE comparison. Quote Link to comment https://forums.phpfreaks.com/topic/265437-wont-update/#findComment-1360318 Share on other sites More sharing options...
redarrow Posted July 9, 2012 Share Posted July 9, 2012 i read it from my notes from site pro maybe there wrong only had to try it... Quote Link to comment https://forums.phpfreaks.com/topic/265437-wont-update/#findComment-1360319 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.