-1

Having trouble getting my head around using a prepared statement for updating an SQL DB.

I have another code for adding the data that works fine. I just don't understand where to start looking.

I have tried to only update one field and I am still getting the same error:

"Call to a member function bind_param() on boolean in...."

//SQL Server Details
$servername = "localhost";
$username = "root";
$password = "password";
$dbname = "database1";

// Create connection
$conn= new mysqli($servername, $username, $password, $dbname);
// Check connection

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$CustID = $_POST['CustID'];

// prepare and bind 
$stmt = $conn->prepare("UPDATE customers (CustName, Phone, Address, City,  
State, PCode, link, Region, ShowOnWebsite) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)WHERE CustID=$CustID"); 
$stmt->bind_param("ssssssssi",$Customer, $Phone, $Address, $City, $State, 
$PCode, $link, $Region, $ShowOnWebsite);`

Any help would be greatly appreciated.

StackedQ
  • 3,673
  • 1
  • 25
  • 38
Falz
  • 7
  • 5
  • Possible duplicate of [Fatal error: Call to a member function bind\_param() on boolean](https://stackoverflow.com/questions/27394710/fatal-error-call-to-a-member-function-bind-param-on-boolean) – Progman Dec 25 '18 at 19:58

1 Answers1

0

You are using INSERT syntax for an UPDATE statement.

UPDATE syntax is different: UPDATE customers set CustName=?, Phone=?, ...