cthlnlmd Posted March 18, 2020 Share Posted March 18, 2020 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(); } } Quote Link to comment https://forums.phpfreaks.com/topic/310318-bind_parameter-fatal-error/ Share on other sites More sharing options...
ginerjm Posted March 18, 2020 Share Posted March 18, 2020 (edited) 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 March 18, 2020 by ginerjm Quote Link to comment https://forums.phpfreaks.com/topic/310318-bind_parameter-fatal-error/#findComment-1575575 Share on other sites More sharing options...
mac_gyver Posted March 18, 2020 Share Posted March 18, 2020 the OP solved this on another forum. Quote Link to comment https://forums.phpfreaks.com/topic/310318-bind_parameter-fatal-error/#findComment-1575581 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.