I'm having problems with the following code to update a database. There are no errors, and I know it's not the database because I have another 'GET' script which uses the same &con information and returns data from the database just fine. However, the database just never updates.
<?php
define("DB_DSN","xxx");
define("DB_HOST","xxx");
define("DB_USER","xxx");
define("DB_PASS","xxx");
$con = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die('Could not connect: ' .mysql_error());
mysql_select_db(DB_DSN) or die('Could not select database');
$id = base64_decode($_POST["id"]);
$deaths = base64_decode($_POST["deaths"]);
$sql = "UPDATE Level01 SET Deaths =' . $id .' WHERE DeathID= ' . $deaths . '" ;
$uresult = mysql_query($sql,$con);
if(! $uresult )
{
die('Could not update data: ' . mysql_error());
}
echo "Updated data successfully\n";
mysql_close($con);
exit;
Can anyone help??
$_POSTvariables have in tem what you expect? Are you sure they're Base64 encoded?UPDATEstatement to"UPDATE Level01 SET Deaths ='" . $id . "' WHERE DeathID= '" . $deaths . "'";