Jump to content

BIND_PARAMETER FATAL ERROR


cthlnlmd

Recommended Posts

So I am having this error:

Fatal error: Uncaught Error: Call to a member function bind_param() on bool in C:\xampp\htdocs\Practice\exam.php:727 Stack trace: #0 {main} thrown in C:\xampp\htdocs\Practice\exam.php on line 727. Can anyone help me to solve this? 

if (!empty($FirstName) || !empty($MiddleName) || !empty($LastName) || !empty($Age) || !empty($HomeAddress) || !empty($ContactNumber) || !empty($LastSchoolAttended))
{
    $host = "localhost";
    $dbUsername = "root";
    $dbPassword = "";
    $dbname = "studentsinformation";
}
    $conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
    
        if (mysqli_connect_error())
        {
            die('Connect Error('.mysqli_connect_errno().')'.mysqli_connect_error());
        }
        else
        {    
            $SELECT = "SELECT FirstName, MiddleName, LastName, LastSchoolAttended From information Where FirstName = ? And MiddleName = ? And LastName = ? And LastSchoolAttended = ? Limit 1";
            $INSERT    = "INSERT Into information (FirstName, MiddleName, LastName, Age, HomeAddress, ContactNumber, LastSchoolAttended) values (?,?,?,?,?,?,?)";
            $stmt = $conn->prepare($SELECT);
            $stmt -> bind_param("ssss", $FirstName,$MiddleName,$LastName,$LastSchoolAttended);
            $stmt -> execute();
            $stmt -> bind_result($FirstName,$MiddleName,$LastName,$LastSchoolAttended);
            $stmt -> store_result();
            $rnum = $stmt -> num_rows;

            if ($rnum == 0 ) {    
                $stmt->close();
                $stmt = $conn -> prepare($INSERT);
                $stmt -> bind_param("sssisis", $FirstName,$MiddleName,$LastName,$Age,$HomeAddress,$ContactNumber,$LastSchoolAttended); //LINE 727 ERROR
                $stmt -> execute();
            }
        }

 

Link to comment
Share on other sites

Its telling you that the var you are attempting to bind to (the connection?) is not valid.  Check that it happened correctly with a little more code and turn on error checking

Check the prepare.  Is everything correct in that insert query statement?

Edited by ginerjm
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.