<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<?php
$oldpwd=$_POST["oldpwd"];
$newpwd=$_POST["loginpwd"];
$newpwd1=$_POST["loginpwd1"];
if(empty($oldpwd) || empty($newpwd) || empty($newpwd1)){
echo("<script language=javascript>alert('填写不完整!');window.history.go(-1);</script>");
exit();
}
mysql_connect("localhost","root","123456") or die("无法连接MySQL数据库服务器!");
$db = mysql_select_db("tuoneng") or die("无法连接数据库!");
$sql = "SELECT * FROM p8_members WHERE username = '$username' and password = '$oldpw'"; 
$rs = $db->GetRow($sql); 
if (!$res) {
echo("<script language=javascript>alert('修改失败!原始密码不正确');window.location = 'xiugaimima.php' </script>");
exit;
}
$updateSQL = "update p8_members set `password` = '{$newpw}' where `username` = '{$username}'";
$db->Execute($updateSQL);
$db->close();
echo("<script language=javascript>alert('修改成功!');window.location = 'xiugaimima.php' </script>");
exit;
?>
</body>
</html>

解决方案 »

  1.   

    $db->GetRow($sql);
    $db->没有GetRow()方法吧,
    你可能用了某封装db类的方法
      

  2.   

    $rs = $db->GetRow($sql);
    改为
    $result = mysql_query($sql);
    $rs = mysql_fetch_row($result);
      

  3.   

    mysql_fetch_row
    mysql_fetch_array
    都可以
      

  4.   

    $db = mysql_select_db("tuoneng") or die("无法连接数据库!"); 
    $sql = "SELECT * FROM p8_members WHERE username = '$username' and password = '$oldpw'"; 
    $res=mysql_query($sql);
    if (mysql_num_rows($res)==0) { 
    echo(" <script language=javascript>alert('修改失败!原始密码不正确');window.location = 'xiugaimima.php' </script>"); 
    exit; 

    $updateSQL = "update p8_members set `password` = '{$newpw}' where `username` = '{$username}'"; 
    mysql_query($updateSQL);
    echo(" <script language=javascript>alert('修改成功!');window.location = 'xiugaimima.php' </script>"); 
    exit; 
    ?>