0

Not sure what I am doing wrong here.. it is giving me the error: *Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource*

What am I missing? Just edited code.. still has a problem with 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>");
            }   

            ?>
0

2 Answers 2

1

All the way in your code you've used mysqli but for fetching data you're using mysql_fetch_array, isn't is mysqli_fetch_array()?

Sign up to request clarification or add additional context in comments.

Comments

0

'isset' will give you a boolean value, not a value in the $_POST array. It just checks whether that value exists (is set).

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.