$user=$_REQUEST["user"];
$fsjf=&$_REQUEST["jf"];
$xguser=$_REQUEST["xguser"];
$pass=$_REQUEST["pass"];
$con=mysql_connect($dz,$sqluser,$sqlpass);
if (!$con) {
die('数据库连接失败'.$mysql_error());
exit;
}
mysql_select_db($sqlk,$con);
$dbuser=null;
$dbpass=null;
$result=mysql_query("select * from user where user ='{$user}';");
while ($row=mysql_fetch_array($result)) {
$dbuser=$row["user"];
$dbid=$row["id"];
$dbpass=$row["pass"];
}
if ($dbpass!=$pass){//当对应密码不对时跳回index.html界面
echo "false:{密码错误}";
mysql_close($con);
exit;
}else {
if ($dbid==1) {
$xgid=null;
$xgresult=mysql_query("select * from user where user ='{$xguser}';");
while ($row=mysql_fetch_array($xgresult)) {
$xgid=$row["id"];
}
$xgsql="update user set jf=$fsjs where id=$xgid";
$xgresult = mysql_query($con,$xgsql);
if($xgresult){
echo "修改成功!";
}else{
echo "修改失败!";
}
}
}
mysql_close($con);//关闭数据库连接,如不关闭,下次连接时会出错
}
$fsjf=&$_REQUEST["jf"];
$xguser=$_REQUEST["xguser"];
$pass=$_REQUEST["pass"];
$con=mysql_connect($dz,$sqluser,$sqlpass);
if (!$con) {
die('数据库连接失败'.$mysql_error());
exit;
}
mysql_select_db($sqlk,$con);
$dbuser=null;
$dbpass=null;
$result=mysql_query("select * from user where user ='{$user}';");
while ($row=mysql_fetch_array($result)) {
$dbuser=$row["user"];
$dbid=$row["id"];
$dbpass=$row["pass"];
}
if ($dbpass!=$pass){//当对应密码不对时跳回index.html界面
echo "false:{密码错误}";
mysql_close($con);
exit;
}else {
if ($dbid==1) {
$xgid=null;
$xgresult=mysql_query("select * from user where user ='{$xguser}';");
while ($row=mysql_fetch_array($xgresult)) {
$xgid=$row["id"];
}
$xgsql="update user set jf=$fsjs where id=$xgid";
$xgresult = mysql_query($con,$xgsql);
if($xgresult){
echo "修改成功!";
}else{
echo "修改失败!";
}
}
}
mysql_close($con);//关闭数据库连接,如不关闭,下次连接时会出错
}
当前问题共有如下(1)个解决方案
你这种连接数据库的写法在2015年废弃了
用了...操作符,要求PHP5.6以上