jamiehook01 Posted May 16, 2009 Share Posted May 16, 2009 Hello, i am pulling my hair out, i am trying to do a simple update and it just wont work. Here is my code $query = "UPDATE books "; $query .= "SET image = 'dfgdfgd' "; $query .= "WHERE id = 49 LIMIT 1 "; mysql_query($query) or die(mysql_error()); //Following two echos are just there for trouble shooting echo $query; echo mysql_error(); On the same page I have got select statements work fine so there is no problem connecting to the DB. the mysql_error does not return any thing. Any ideas? Link to comment https://forums.phpfreaks.com/topic/158386-solved-php-sql-update-help/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 16, 2009 Share Posted May 16, 2009 Do you have a row in that table that matches: WHERE id = 49 Is your code even being executed? Is it inside of a conditional test that is FALSE? Link to comment https://forums.phpfreaks.com/topic/158386-solved-php-sql-update-help/#findComment-835286 Share on other sites More sharing options...
jamiehook01 Posted May 16, 2009 Author Share Posted May 16, 2009 yes there is a record that matches 49. I have executed the code directly onto the database through PHP my admin and it updates fine. I have isolated this update from a large block of code that did have if/while statements etc, so now this is the one thing on the page apart from the includes for the DB connection. It just seems like it should work? Link to comment https://forums.phpfreaks.com/topic/158386-solved-php-sql-update-help/#findComment-835289 Share on other sites More sharing options...
Ken2k7 Posted May 16, 2009 Share Posted May 16, 2009 Can you post more of the code? Link to comment https://forums.phpfreaks.com/topic/158386-solved-php-sql-update-help/#findComment-835291 Share on other sites More sharing options...
jamiehook01 Posted May 16, 2009 Author Share Posted May 16, 2009 Just as i was getting my connection function to show you i realised that my code is still connecting to my development online enviroment rather that my local DB so when i was checking the updates in php myadmin they were not showing because i was looking at the wrong DB. Sorry for wasting your time, but you did help by making me go and check code that i would never look at because it works in other areas of the site!!! Thank you. Link to comment https://forums.phpfreaks.com/topic/158386-solved-php-sql-update-help/#findComment-835294 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.