update query not working in prepared statement with multiple where clause

update query not working in prepared statement with multiple where clause

I have the following update statement which does execute successfully but with no value change in the table.

I have the following update statement which does execute successfully but with no value change in the table.

 $name = "John Doe"; //to update into John Stack
 $chenna = "Mz"; $reg = 25; $km = 3;
 $dbh = PDO Object

$stmt = $dbh->prepare("UPDATE hl_customer SET name=:hming, address=:chenna WHERE regd=:regd AND kum=:km"); $stmt->bindParam(':hming', $name, PDO::PARAM_STR); $stmt->bindParam(':chenna', $hmun, PDO::PARAM_STR); $stmt->bindParam(':regd', $reg, PDO::PARAM_INT); $stmt->bindParam(':km', $km, PDO::PARAM_INT); $stmt->execute(); $affected = $stmt->rowCount();

Another tested code:

 $stmt = $dbh->prepare("UPDATE hl_customer SET name=?, address=?
         WHERE regd=? AND kum=?");
 $stmt->execute([$name, $hmun, $reg, $km]);
 $affected = $stmt->rowCount();

$stmt = $dbh->query("UPDATE hl_customer SET name='$name', address='$chenna' WHERE regd='$reg' AND kum='$km'");

In order to update I kept changing the $name variable, yet there was no affected row. The row count always return 0. I did tested in both phpmyadmin(latest version) and mysql Workbench(latest) and the problem is still there. Then I tested again in mysql console, and it works as expected. But why is it not working in the code shown above, phpmyadmin and workbench. What could be the problem? Is my code wrong? I used mysql 8.0.12, php 5.6.* and php 7.1.*. I did test it again without parameterized query, still it did not work. Now I begin to think that it is a kind of bug in php. Thanks

php mysql

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Best MySQL DigitalOcean Performance – ScaleGrid vs. DigitalOcean Managed Databases

Compare ScaleGrid MySQL vs. DigitalOcean Managed Databases - See which offers the best MySQL throughput, latency, and pricing on DigitalOcean across workloads.

Category Subcategory Dropdown in PHP MySQL Ajax

PHP mysql dynamic dropdown list onchange. Here, we'll show how to populate category and subcategory in dropdown list using ajax in PHP mysql

PhP MySQL Projects

Simpliv LLC, a platform for learning and teaching online courses. We basically focus on online learning which helps to learn business concepts, software technology to develop personal and professional goals through video library by recognized industry experts and trainers.

PHP MySQL Tutorial - User Registration System Using PHP & MySQL

In this PHP MySQL Tutorial, you'll learn how to create a user registration and login system using PHP and a MySQL database.

The Complete PHP MySQL Professional Course with 5 Projects

The Complete PHP MySQL Professional Course with 5 Projects