这是我的代码。
if(!isset($_SESSION['user'])) header("Location: ../");
$username = $_SESSION["user"];
$id = $_SESSION["id"];
$nume=$_POST["nume"];
$prenume=$_POST["prenume"];
$telefon=$_POST["telefon"];
$email=$_POST["email"];
$adresa=$_POST["adresa"];
$ziNastere=$_POST["ziNastere"];
$poza=$_POST["poza"];
include('../conn2.php');
mysql_query("UPDATE $username SET nume=$nume,prenume=$prenume,telefon=$telefon,email=$email,adresa=$adresa,ziNastere=$ziNastere,poza=$poza
WHERE id=$id");
mysql_select_db($username);
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not update data: ' . mysql_error());
}
echo "Updated data successfully\n";
if(isset($_SESSION['id'])) unset($_SESSION['id']);
//header("Location: ../home");
mysql_close($con);
?>
我想用字符串更新数据库“$username”:$nume、$prenume、$telefon...但是当我单击保存时它返回"Error: Query was empty"
- 为什么会这样?