Writing to mysql using php and prepared statements
Get the solution ↓↓↓I have the below code in "profile_server.php" but nothing is being written to the database and I cant figure out why. I appreciate your help :
if(isset($_POST['submit'])){
$id = $_SESSION['id']; // Retrieved from previous session
//Declaring variables
$country = mysqli_real_escape_string($db, $_POST['country']);
$province = mysqli_real_escape_string($db, $_POST['province']);
$city = mysqli_real_escape_string($db, $_POST['city']);
$sql_u_details = $db->prepare ("UPDATE user_details
SET (country, province, city)
VALUES (?, ?, ?)
WHERE id = ? ");
$sql_u_details->bind_param("ssss", $country, $province, $city, $id);
$sql_u_details->execute();
mysqli_query($db, $sql_u_details);
}
Answer
Solution:
Change your sql statement to the following:
$sql_u_details = $db->prepare ("UPDATE user_details
SET country = ?, province = ?, city = ?
WHERE id = ?");
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: object not found by the @paramconverter annotation.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.