efficacious Posted July 3, 2012 Share Posted July 3, 2012 Hi all, I am having some trouble getting a query to run and I was hoping someone might be able to point out why. Here is the SQL: UPDATE `myTable` SET `myColumn`='SomeText' WHERE ID='15' thanks Every time I run it, it just returns as 0 rows affected.. and surely enough checking the DB shows that nothing has happened. Quote Link to comment https://forums.phpfreaks.com/topic/265141-help-with-a-query/ Share on other sites More sharing options...
gristoi Posted July 3, 2012 Share Posted July 3, 2012 try to add escape quotes around id UPDATE `myTable` SET `myColumn`='SomeText' WHERE `ID`='15' and if ID is an integer field in the db remove the quotes from around 15 Quote Link to comment https://forums.phpfreaks.com/topic/265141-help-with-a-query/#findComment-1358774 Share on other sites More sharing options...
Barand Posted July 3, 2012 Share Posted July 3, 2012 Possible causes: There is an error - check mysql_error() after running the query There is no row with id=15 The text in mycolumn is already = 'SomeText' Quote Link to comment https://forums.phpfreaks.com/topic/265141-help-with-a-query/#findComment-1358855 Share on other sites More sharing options...
efficacious Posted July 3, 2012 Author Share Posted July 3, 2012 OK so I did a test, I copied this generated SQL and pasted it into PHP my ADMIN and it works just fine... so there is nothing wrong with the SQL why does it not execute? I have a DB access object that i wrote.. It probably fires off 20 or 30 some queries through this exact same method yet for some reason this ONE query doesn't run.. I just don't get. None of the column names are wrong.. none of the values are already in the DB, mysql_error reports no errors and affected rows says 0. I double checked and checked and rechecked and checked again to see if there was some issue stopping the query from being run or something along those lines and no such thing. The SQL statement gets sent to the DB and the DB puts up its middle finger. Quote Link to comment https://forums.phpfreaks.com/topic/265141-help-with-a-query/#findComment-1358998 Share on other sites More sharing options...
mikosiko Posted July 3, 2012 Share Posted July 3, 2012 the only way to get some help is if you post the relevant code where you are using that line, otherwise is only a guessing game Quote Link to comment https://forums.phpfreaks.com/topic/265141-help-with-a-query/#findComment-1359001 Share on other sites More sharing options...
Barand Posted July 3, 2012 Share Posted July 3, 2012 Have you tried <?php mysql_query ("UPDATE `myTable` SET `myColumn`='SomeText' WHERE ID=15 ") or die (mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/265141-help-with-a-query/#findComment-1359003 Share on other sites More sharing options...
efficacious Posted July 3, 2012 Author Share Posted July 3, 2012 the only way to get some help is if you post the relevant code where you are using that line, otherwise is only a guessing game I would love to do this for you mikosiko but like I said it is wrapped up within an entire database object, even if I showed you the code where the SQL is compiled for the query you wouldn't have any clue what was going on. I would have to basically show you two full objects and a bunch of other crap... However your bit about error reporting got me thinking ... Why not check the error log just in case the error didn't get output to the error catch. I figured out the problem... I was missing a ">" character when I was calling the link method to the DB. How fricken stupid is that.. honestly it should have thrown up a syntax error but it didn't. mysql_error didn't even report that the connection wasn't being established... SOAFB. Thanks for the help... (such a stupid issue lol) Quote Link to comment https://forums.phpfreaks.com/topic/265141-help-with-a-query/#findComment-1359006 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.