[RESOLVED] mysql Update code not working
hi i am trying to run an update command but it keeps failing
Code:
<?php
$updatetext = $HTTP_POST_VARS['welcomeinfo'];
$conn=@mysql_connect("localhost", "ckids_ckids1", "christiankids")
or die("MYSQL Connection Error");
$rs = @mysql_select_db("ckids_wcms1", $conn)
or die("Database Error");
$sql = "UPDATE `hompage` SET `welcome` = '$updatetext' WHERE `id` = 1 LIMIT 1";
mysql_query($sql)
or die("Error: Update Failed");
echo "Updated";
?>
its keeps showing error update failed
i have tried many things and cant get it to work, i know that $updatetext contains a value as i have echoed this in trying to fix it
Re: mysql Update code not working
Try the below. HTH :)
PHP Code:
$sql = "UPDATE hompage SET welcome = '$updatetext' WHERE id = 1 LIMIT 1";
Re: mysql Update code not working
Back ticks ` should only be used for table names. Not field names. ;)
Re: mysql Update code not working
You can also display the error from mysql by using the mysql_error()
Re: mysql Update code not working
Re: mysql Update code not working
What is the error mysql is giving you?
Re: mysql Update code not working
the mysql_error() wouldnt work, but have fixed it now, it was a spelling error in the table, thanks everyone
Re: [RESOLVED] mysql Update code not working
If the table name was incorrect then mysql_error() should have told you that :confused:
Re: [RESOLVED] mysql Update code not working
yes i know it should have, and i set it up like it showed, but for some reason it didnt like it, might try it again one day when my code goes wrong