Page 1 of 1

can't update database

Posted: Sat Dec 07, 2002 12:41 am
by justinb
Hello,
I am trying to write an update script, this script is a reused script tht I've used for another db and it works there, but not here. I have allready created and add entry and delete entry with similar code
$table_name = business (name of table)
$id is variable that sends the table primary key from other page, i have a table at bottom of page that shows what is updated, And it has all the correct info, and says it was successful, but when I go back and check, it didn't update


$db = @mysql_select_db("$db_name", $connection) or die("Error2 - Couldn't connect - try again later");

$sql = "UPDATE $table_name

SET
catID = '$catID',
busName = '$busName',
busOwner = '$busOwner',
busAd = '$busAd',
busCity = '$busCity',
busPostal = '$busPostal',
busPhone = '$busPhone',
busPhone2 = '$busPhone2',
busFax = '$busFax',
busUrl = '$busUrl',
busEmail = '$busEmail',
busLogo = '$busLogo',
featured = '$featured',
keyWords = '$keyWords',
busDesc = '$busDesc'
WHERE busID = '$id'
";



$result = @mysql_query($sql, $connection) or die("Error3 - Couldn't connect - try again later");


?>

Posted: Sat Dec 07, 2002 4:49 am
by qiangxd
$result =mysql_query($sql, $connection) or die(mysql_error());


?>

Re: can't update database

Posted: Sat Dec 07, 2002 1:08 pm
by f1nutter
It might be a typo, but you need to remove the quotes from around $db_name.
justinb wrote: $db = @mysql_select_db("$db_name", $connection) or die("Error2 - Couldn't connect - try again later");
You also say that "it has all the correct info, and says it was successful, but when I go back and check, it didn't update". What is displaying the info and how?. What do you go back and check?

Use phpMyAdmin to look at the database. That will tell you exactly what is in your db, you can also check your query by running it directly from phpMyAdmin without going through a browser.