Forum Moderators: coopster

Message Too Old, No Replies

Problems updating the database

         

nicuz

6:59 pm on Apr 14, 2006 (gmt 0)



$connection = mysql_connect($host, $user,$password)
or die ("Couldn't connect to server.");
$db = mysql_select_db($database, $connection)
or die ("Couldn't select database.");

$sql = "UPDATE ad SET adName='$adName', adInfo='$adInfo', adPrice='$adPrice' WHERE adID='21'";
$result = mysql_query($sql) or die("Couldn't modify database.");
mysql_close($connection);

This is the error I get: Couldn't modify database. Anyone knows what is happening and why I cannot update the database?

FalseDawn

7:15 pm on Apr 14, 2006 (gmt 0)

10+ Year Member



Make sure the user has update permissions on this database, and if that doesn't fix it, then change this line:

$result = mysql_query($sql) or die("Couldn't modify database.");

to this:
$result = mysql_query($sql);

And make sure error reporting is turned on - the error message should help you pinpoint the problem.

Birdman

7:30 pm on Apr 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Mysql_error() will give you the error message without changing PHP's error reporting:

$db = mysql_select_db($database, $connection)
or die ("Couldn't select database, because: " . mysql_error());

Habtom

7:35 am on Apr 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try this:

$sql = "UPDATE ad SET adName='". $adName ."', adInfo='". $adInfo ."', adPrice='". $adPrice ."' WHERE adID='21'";

Check your table name and fields too.

Habtom