On a Function That Gets Settings from a Db I Ran into the Error

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



Leave a reply



Submit