Mysqli throws "Warning: mysqli_stmt_bind_param () expects parameter 1 to be mysqli_stmt, boolean set"

Possible duplicate:
mysql_fetch_array () expects parameter 1 to be a resource, boolean is set to select

I know that this code works on another site that I have, but today it does not play the ball. I get three warnings:

Warning: mysqli_stmt_bind_param () expects parameter 1 to be mysqli_stmt, boolean is listed in / homepages / 14 / d248783986 / htdocs / subdomains / clients.bionic-comms.co.uk / httpdocs / carefree / process.php on line 33

Warning: mysqli_execute () expects parameter 1 to be mysqli_stmt, boolean is set to / homepages / 14 / d248783986 / htdocs / subdomains / clients.bionic-comms.co.uk / httpdocs / carefree / process.php on line 34

Warning: mysqli_stmt_affected_rows () expects parameter 1 to be mysqli_stmt, boolean is set in / homepages / 14 / d248783986 / htdocs / subdomains / clients.bionic-comms.co.uk / httpdocs / carefree / process.php on line 35

Can someone help me figure this out?

I need to use htaccess to upgrade to PHP5 if this helps.

$connection = mysqli_connect($hostname, $username, $password, $dbname);

if (!$connection) {
    die('Connect Error: ' . mysqli_connect_error());
}

$query = "INSERT INTO entries (name, dob, school, postcode, date) VALUES (?,?,?,?,?)";
$stmt1 = mysqli_prepare($connection, $query);
mysqli_stmt_bind_param($stmt1, 'sssss',$name,$dob,$school,$postcode,$date);
mysqli_execute($stmt1);
if(mysqli_stmt_affected_rows($stmt1) != 1)
    die("issues");
mysqli_stmt_close($stmt1);
return "new";

EDIT

After some research, it turns out that the preparation operator does not play the ball with mysql4. I created a new mysql5 database, but now I get this error when trying to connect:

Warning: mysqli_connect () [function.mysqli-connect]: (HY000 / 2005): Unknown MySQL server node "localhost: /tmp/mysql5.sock" (1)

Does anyone have any idea why this is happening?

+5
source share
2 answers

.
, mysqli_connect_error() .
mysqli_error() .
, mysqli_stmt_error(). ... , / mysqli false , a) b) , . . . , ( , ).

- :

$connection = mysqli_connect(...);
if ( !$connection ) {
  die( 'connect error: '.mysqli_connect_error() );
}

$query = "INSERT INTO entries (name, dob, school, postcode, date) VALUES (?,?,?,?,?)";
$stmt1 = mysqli_prepare($connection, $query);
if ( !$stmt1 ) {
  die('mysqli error: '.mysqli_error($connection);
}
mysqli_stmt_bind_param($stmt1, 'sssss',$name,$dob,$school,$postcode,$date);
if ( !mysqli_execute($stmt1) ) {
  die( 'stmt error: '.mysqli_stmt_error($stmt1) );
}
...

; -)

+6

mysqli_prepare(), false, , "boolean given". , $connection. , ?

:

$connection = mysqli_connect("localhost", "my_user", "my_password", "world");

, echo mysqli_connect_error(), , - . , , , , ?

+3

All Articles