Hi Guys
First apologies since no doubt this type of question has been asked before.
Thanks for any help in advance..
I have a form to modify data... it works just fine as I echo the modified array. However the database is not updated. Could anone tell me why?
function sql_update()
{
global $conn;
global $_POST;
$location="Localhost";
$userName="username";
$password="password";
$dbname="database";
$sql = "update `DTable` set
`Town`= " .sqlvalue(@$_POST["Town"], true) .",
`id`=" .sqlvalue(@$_POST["id"], true) .",
`Age`=" .sqlvalue(@$_POST["Age"], false) .",
`pool`=" .sqlvalue(@$_POST["pool"], true) ."
where " ."
(`Town`=" .sqlvalue(@$_POST["xTown"], true) .") and
(`id`=" .sqlvalue(@$_POST["xid"], true) .") and
(`Age`=" .sqlvalue(@$_POST["xAge"], false) .") and
(`pool`=" .sqlvalue(@$_POST["xpool"], true) .")";
echo $sql; //OK to here, but does not update record
// Connect to the Database
if (!($conn=mysql_pconnect($location,$username,$password))) {
DisplayErrMsg(sprintf("error connecting to host %s, by user %s",
$location, $username)) ;
exit() ;
}
// Select the Database
if (!mysql_select_db($dbname, $conn)) {
DisplayErrMsg(sprintf("Error in selecting %s database", $dbname)) ;
DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link), mysql_error($link))) ;
exit() ;
}
// Execute the Statement
if (!mysql_query($sql, $conn)) {
DisplayErrMsg(sprintf("Error in executing %s stmt", $sql)) ;
DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link), mysql_error($link))) ;
exit() ;
}
}
}