-4

I don't understand why this is the same as the other question. The error message is different, and I asked about the UPDATE statement, what is wrong? If you tell me, I'll fix it

I'm using phpMyAdmin, and I'm trying to update TB_MESSAGE, but I get this error message.

Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, bool given in .../ReadUpdate.php on line 11

Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, bool given in .../ReadUpdate.php on line 14

Here is ReadUpdate.php

 <?php 
$con = mysqli_connect("localhost", "**id**", "**pw**", "**DBname**");

$userID = $_POST["userID"]; // String userID
$read = $_POST["read"]; // String read = "R", VARCHAR (1) in DB

$statement = mysqli_prepare($con, "UPDATE TB_MESSAGE SET READ=? WHERE RECEIVER=?");

mysqli_stmt_bind_param($statement, "ss", $userID, $read);

$response = array();
$response["success"] = mysqli_stmt_execute($statement);

echo json_encode($response);
mysqli_close($con);
?>

Is the syntax of the update that I wrote wrong? Why mysqli_stmt_bind_param() is failed????

sonacK
  • 7
  • 1
  • [https://www.php.net/manual/en/mysqli.prepare.php](`mysqli_prepare) returns a statement object or false if an error occurred.`) So your sql query is not correct – Baracuda078 Jun 02 '22 at 09:13
  • thank you... I was guessing the problem, too. I don't know how to fix it. I don't know which part is wrong. I've been searching for 2 hours, but there are no posts that clearly wrote an update example. I'll refer to the link attached. – sonacK Jun 02 '22 at 09:14
  • When you get errors, always read the documentation of the functions you use. That way you know what to expect back from them and many times there are some nice examples on how to use them correct – Baracuda078 Jun 02 '22 at 09:16
  • 2
    Did you read the duplicate about *how to get the actual, relevant error messages __from MySQL__* and have implemented that? That's the first step to finding the *actual* cause of the problem. – deceze Jun 02 '22 at 09:17
  • It can print out an error message..!!! I didn't know because it was my first time using it Thank you! – sonacK Jun 02 '22 at 10:00

0 Answers0