PHP MYSQL update query not updating fields

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pilot911
Forum Newbie
Posts: 1
Joined: Fri Mar 04, 2011 4:25 pm

PHP MYSQL update query not updating fields

Post by pilot911 »

I have the following PHP script to update two time/date fields in the database.

When i run this the fields are not updated.

Can anyone see where i m going wrong.

<?php
$con = mysql_connect("localhost","dbname","dbpassword");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

echo 'Connected successfully';

mysql_select_db("my_db", $con);

mysql_query("UPDATE msm_content SET created = '2011-01-02 00:00:00', modified = '2011-01-01 00:00:00'");

echo 'Query Updated successfully';

mysql_close($con);
?>

Your guidance is much appreciated.

Chris
anantha
Forum Commoner
Posts: 59
Joined: Thu Dec 23, 2010 7:38 pm

Re: PHP MYSQL update query not updating fields

Post by anantha »

try echoing mysql_error() and see what error it display after the mysql_query()
msmohandg
Forum Newbie
Posts: 1
Joined: Mon Mar 07, 2011 1:07 pm

Re: PHP MYSQL update query not updating fields

Post by msmohandg »

hi..

make sure your databasde field format is acceptable.. (like datetime or varchar)

or give the error msg which you got..

i ll try to give you a solution..
Post Reply