guyfromfl Posted May 6, 2010 Share Posted May 6, 2010 I have been struggling with this sql line for a few days now, and it is really backing this project up. I have php spit out $sql in a die() command, and it looks good. I also have php tell me how many rows the same line returns when I convert it into a select. Can someone please help me find the problem with why this simple update does not work. // I left the date command that creates the date and hard coded the date into this example for testing purposes. $sql = "UPDATE repairs.raitem SET repairDate='2010-05-06' AND repairTech={$_SESSION['user_id']} WHERE repairs.raitem.repair IS NOT NULL AND repairs.raitem.repairDate IS NULL AND repairs.raitem.id={$raitem['id']} LIMIT 1"; ANY help is much appreciated! EDIT: What I get is repairDate and repairTech are still NULL after the sql is run. No errors. Quote Link to comment https://forums.phpfreaks.com/topic/200909-simple-update-doesnt-work/ Share on other sites More sharing options...
guyfromfl Posted May 6, 2010 Author Share Posted May 6, 2010 it hit me as soon as i posted it and re-read it. I was seperating the SET columns by an AND no a "," I feel dumb Quote Link to comment https://forums.phpfreaks.com/topic/200909-simple-update-doesnt-work/#findComment-1054179 Share on other sites More sharing options...
Daz84 Posted May 6, 2010 Share Posted May 6, 2010 Everyone makes syntax errors, nothing to worry about! As long as it is solved that is the main thing! I was going to suggest looking at the conditions of the statement though. If you already have a record stored where raitem.id = {$raitem['id']} and it has a date assigned to it already then the statement will not return any records and nothing will be updated. Maybe this is suitable to your application but it just feels a little 'unsafe' Daz Quote Link to comment https://forums.phpfreaks.com/topic/200909-simple-update-doesnt-work/#findComment-1054181 Share on other sites More sharing options...
guyfromfl Posted May 6, 2010 Author Share Posted May 6, 2010 Thanks for the tip. I am using the database to test the condition, not php. The code I am writing determines the state of a warranty repair. If the repair field is empty, the repair has not been complete. I am doing it this way so the user doesn't have to check a checkbox to tell the computer something it can figure out. Is there a better way? Quote Link to comment https://forums.phpfreaks.com/topic/200909-simple-update-doesnt-work/#findComment-1054208 Share on other sites More sharing options...
Daz84 Posted May 6, 2010 Share Posted May 6, 2010 Ah I see what you are doing now. It makes sense once you explain it What kind of data is stored in the repair field? Quote Link to comment https://forums.phpfreaks.com/topic/200909-simple-update-doesnt-work/#findComment-1054227 Share on other sites More sharing options...
guyfromfl Posted May 6, 2010 Author Share Posted May 6, 2010 the repair field is the tech's explanation of what he did to fix the engine. We are a small company, about 8 people so I can get away with slack names like that , especially since I'm the only one who knows how to even open the editor for the code. We manufacture model trains... Quote Link to comment https://forums.phpfreaks.com/topic/200909-simple-update-doesnt-work/#findComment-1054230 Share on other sites More sharing options...
Daz84 Posted May 6, 2010 Share Posted May 6, 2010 Ah I see. In that case yes this seems like a perfectly good system. Just so long as your techs don't get lazy and stop putting in details Quote Link to comment https://forums.phpfreaks.com/topic/200909-simple-update-doesnt-work/#findComment-1054232 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.