Forum Moderators: coopster

Message Too Old, No Replies

Update command will not update fields

         

NeilB84

4:34 pm on Mar 16, 2006 (gmt 0)

10+ Year Member



I'm currently trying to execute some coding that will insert updated data into a MySQL database, but it is not doing it but is not throwing up any error messages for me to go on. Can anyone see where I am going wrong please?


<?

session_start();
$carid = $_SESSION['carid'];

$database="neil";

mysql_connect("****", "****", "****");
@mysql_select_db($database) or die( "Unable to select database");

$query = "UPDATE cars SET 'make' = '$_POST[make]', 'model' = '$_POST[model]','history' = '$_POST[history]','facts' = '$_POST[facts]','variants' = '$_POST[variants]','produced' = '$_POST[produced]' WHERE idno = '$carid' 'LIMIT 1'";

echo $query;
echo mysql_error();

mysql_close();

?>

Robber

7:08 pm on Mar 16, 2006 (gmt 0)

10+ Year Member



You need to fire off $query to your database take a look at mysql_query()

dreamcatcher

7:48 pm on Mar 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

I`m guessing its the apostrophes in your query. No apostrophes around table names.

$query = mysql_query("UPDATE cars SET make = '$_POST[make]', model = '$_POST[model]',history = '$_POST[history]',facts = '$_POST[facts]',variants = '$_POST[variants]',produced = '$_POST[produced]' WHERE idno = '$carid' 'LIMIT 1'") or die(mysql_error());

dc