Jump to content

[SOLVED] PHP SQl Update help


jamiehook01

Recommended Posts

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

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?

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.