On a function that gets settings from a DB I ran into the error
The problem lies in:
$query = $this->db->conn->prepare('SELECT value, param FROM ws_settings WHERE name = ?');
$query->bind_param('s', $setting);
The prepare()
method can return false
and you should check for that. As for why it returns false
, perhaps the table name or column names (in SELECT
or WHERE
clause) are not correct?
Also, consider use of something like $this->db->conn->error_list
to examine errors that occurred parsing the SQL. (I'll occasionally echo the actual SQL statement strings and paste into phpMyAdmin to test, too, but there's definitely something failing there.)
bFatal error/b: Uncaught Error: Call to a member function bind_param() on boolean in E:\Xamp\htdocs\FindMyDoc\Api.php:100
You might wish to try using a logical test to the creation of the prepared statement before blindly proceeding with the rest of the code - what I mean is like this:
$sql='INSERT INTO `doctorsignuprequest`
( `doc_first_name`, `doc_last_name`, `doc_email`, `doc_profile_image`, `doc_password`, `doc_ph_number`, `doc_age`, `doc_gender`, `doc_category`, `doc_education`, `doc_doctor_message` )
VALUES
( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )';
$stmt=$conn->prepare( $sql );
if( $stmt ){
$stmt->bind_param( 'sssssssssss',
$doc_first_name,
$doc_last_name,
$doc_email,
$doc_profile_image,
$doc_password,
$doc_ph_number,
$doc_age,
$doc_gender,
$doc_category,
$doc_education,
$doc_doctor_message
);
$res=$stmt->execute();
$stmt->close();
/* yay - all good perhaps */
} else {
exit( 'BOGUS' );
}
On a function that gets settings from a DB I ran into the error
The problem lies in:
$query = $this->db->conn->prepare('SELECT value, param FROM ws_settings WHERE name = ?');
$query->bind_param('s', $setting);
The prepare()
method can return false
and you should check for that. As for why it returns false
, perhaps the table name or column names (in SELECT
or WHERE
clause) are not correct?
Also, consider use of something like $this->db->conn->error_list
to examine errors that occurred parsing the SQL. (I'll occasionally echo the actual SQL statement strings and paste into phpMyAdmin to test, too, but there's definitely something failing there.)
mySQLi insert error - Call to a member function bind_param
$stmt = $mysqli->prepare('INSERT INTO users (id, firstname, lastname) VALUES ("", ?, ?)');
Removed !
in from of $stmt
and you were missing a )
to close the VALUES
(PHP) Fatal error: Call to a member function bind_param()
As per the MySQLi documentation page http://php.net/manual/en/mysqli.prepare.php it states that:
mysqli_prepare() returns a statement object or FALSE if an error
occurred.
Your error says that you are trying to call the function bind_param()
on a boolean
(FALSE) and as such your error suggests that there is an error in your prepare call.
I would suggest that this is due to a missing comma after student_fatherContactNo = ?
.
Related Topics
PHP Mail Function Doesn't Complete Sending of E-Mail
Are PHP Short Tags Acceptable to Use
Deleting an Element from an Array in PHP
How to Extract and Access Data from Json With PHP
Are Pdo Prepared Statements Sufficient to Prevent SQL Injection
Grabbing the Href Attribute of an a Element
Php Fatal Error: Uncaught Pdoexception: Could Not Find Driver
How to Get Useful Error Messages in PHP
Send Email Using the Gmail Smtp Server from a PHP Page
Generating a Truly Unique Order Id in PHP
Why Does This Pdo Statement Silently Fail
Project Links Do Not Work on Wamp Server
Warning: MySQL_Fetch_Array(): Supplied Argument Is Not a Valid MySQL Result
The Get Method Is Not Supported for This Route. Supported Methods: Put. But I'M Using Put
Pass a PHP String to a JavaScript Variable (And Escape Newlines)