PHP表单变量,mysql_fetch_array()的错误

时间:2011-06-08 22:57:34

标签: php database variables

不确定我在这里做错了什么..它给了我错误:*警告:mysql_fetch_array():提供的参数不是有效的MySQL结果资源*

我错过了什么?刚编辑的代码..仍然存在mysql_fetch_array()

的问题
<?
    //Extract data from form
    if(isset($_POST["editUserName"])){
 $myUserName = mysqli_real_escape_string($myConn, $_POST["editUserName"]);
    }

 if(isset($_POST["updateSubmit"])){ 
  $mySubmit = mysqli_real_escape_string($myConn, $_POST["updateSubmit"]);
    }


    //Verify form was submitted before beginning database interaction
    if ($mySubmit != "")
    {

    //Create an SQL delete statement to select the desired record
    $mySQLselect = "SELECT * FROM tblUsers WHERE userName = '.$myUserName.'";
    $myRS = mysqli_query($myConn, $mySQLselect) or die('Error: ' .mysqli_error($myConn));
    $myData = mysql_fetch_array($myRS);

    //Create form output for editing
    echo("<form name='frmEdit' id='frmEdit' action='doEdit.php' method='post'>");
    echo("<input type='hidden' name='hidUserName' id='hidUserName' value='.$myUserName.'/>");       
    echo("<p>User Name: <input type='text' name='BuserName' id='BuserName' value='$myData[userName]'/></p>");
    echo("<p>Password: <input type='text' name='BuserPass' id='BuserPass' value='$myData[userPass]'/></p>");
    echo("<p>First Name: <input type='text' name='BfirstName' id='BfirstName' value='$myData[userFirst]'/></p>");
    echo("<p>Last Name: <input type='text' name='BlastName' id='BlastName' value='$myData[userLast]'/></p>");
    echo("<p>Address: <input type='text' name='Baddress' id='Baddress' value='$myData[address]'/></p>");
    echo("<p>City: <input type='text' name='Bcity' id='Bcity'value='$myData[city]'/></p>");
    echo("<p>State: <input type='text' name='Bstate' id='Bstate' value='$myData[state]'/></p>");
    echo("<p>Zip: <input type='text' name='Bzip' id='Bzip' value='$myData[zip]'/></p>");
    echo("<p>Email: <input type='text' name='Bemail' id='Bemail'$myData[email]'/></p>");
    echo("<p>Phone: <input type='text' name='Bphone' id='Bphone'$myData[phone]'/></p>");
    echo("<p><input type='submit' name='btnDoEdit' id='btnDoEdit' value='Make Changes'/></p>");
    echo("</form>");
            }   

            ?>

2 个答案:

答案 0 :(得分:1)

您使用mysqli代码的所有方式,但是为了获取您使用mysql_fetch_array的数据,不是mysqli_fetch_array()

答案 1 :(得分:0)

'isset'会给你一个布尔值,而不是$ _POST数组中的值。它只是检查该值是否存在(已设置)。

     if(isset($_POST["editUserName"])){
     $myUserName = mysqli_real_escape_string($myConn, $_POST["editUserName"]);
        }

     if(isset($_POST["updateSubmit"])){ 
      $mySubmit = mysqli_real_escape_string($myConn, $_POST["updateSubmit"]);
        }