I ve written a function which updates the mysql database row with some new column data. Here is the function:
function sql($set,$data){
$sql = mysql_query("UPDATE members SET ".$set." = ".$data." WHERE login = ".$_SESSION[ login ]." ");
if($sql){
echo Profile updated. ;
}
else{
echo Could not update profile. Please try again later. ;
}
}
这里是方案的一个零碎部分,该方案本应利用这一功能:
$array = array("$password", "$email", "$age");
if($array[0] != 0){
sql("password",$password);
}
if($array[1] != 0){
sql("email",$email);
}
if($array[2] != 0){
sql("age",$age);
}
它没有将价值写给数据库。 什么错误? 是否可以引用该功能中的变量?