0

I keep getting an error on line 27,

Fatal error: Call to a member function bind_param() on a non-object in line 27

But it seems fine to me. Sorry a bit new to this, any help would be appreciated.

<?php   
$mysqli = new mysqli('localhost','root','root','newfawna');

//Output any connection error
if ($mysqli->connect_error) {
    die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
}
//values to be inserted in database table
    $id = $_POST["id"];
    $animal = $_POST['animal'];
    $family = $_POST['family'];
    $code = $_POST['code'];     
    $dateOfEncounter = $_POST['dateOfEncounter'];
    $encounterAddress = $_POST['encounterAddress'];
    $postcode = $_POST['postcode'];
    $timeOfCall = $_POST['timeOfCall'];     
    $callerDetails = $_POST['callerDetails'];
    $contactNumber = $_POST['contactNumber'];
    $incidentDetails = $_POST['incidentDetails'];
    $finalised = $_POST['resolved'];        

echo $id . " <br />" . $animal . " <br />" . $family . " <br />" . $code . " <br />" . $dateOfEncounter . " <br />" . $encounterAddress . " <br />" . $postcode . " <br />" . $timeOfCall . " <br />" . $callerDetails . " <br />" . $contactNumber . " <br />" . $incidentDetails  . " <br />" . $finalised;

$query = "UPDATE newrecords SET (animal, family, code, dateOfEncounter, encounterAddress, postcode, timeOfCall, callerDetails, contactNumber, incidentDetails, finalised) WHERE id = '$id' VALUES (?,?,?,?,?,?,?,?,?,?,?)";
$statement = $mysqli->prepare($query);

//bind parameters for markers, where (s = string, i = integer, d = double,  b = blob)
$statement->bind_param('sssssssssbs', $animal, $family, $code, $dateOfEncounter, $encounterAddress, $postcode, $timeOfCall, $callerDetails, $contactNumber, $incidentDetails, $finalised);

if($statement->execute()){
header('Location: listRecordsPhone.php');
}else{
die('Error : ('. $mysqli->errno .') '. $mysqli->error);
}
$statement->close();
?>

I know that all of the data is coming through as line 22 is showing up all of the data correctly, I just can't work out the error.

  • 2
    Your `UPDATE` syntax is just wrong ([can't find what you try in the docs...](http://dev.mysql.com/doc/refman/5.0/en/update.html)). It's `UPDATE newrecords SET animal = ?, family = ? ...` – Marcel Gwerder Jan 05 '15 at 00:46
  • 1
    `$statement` is `false` because the `prepare` failed - Marcel's comment explains why. – halfer Jan 05 '15 at 00:48
  • Thanks for helping me clear this up. sorry about the newbie question. – Rod Miller Jan 05 '15 at 06:12

0 Answers0