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

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

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.

The Complete PHP MySQL Professional Course with 5 Projects

The Complete PHP MySQL Professional Course with 5 Projects

PHP Interview Questions with Solutions: Prepare for PHP Interview

Prepare for PHP Interviews. Set Variable With php.ini File. Logic & Output Behind PHP Code Segment. Class Concept, Error & Functions in PHP. Start PHP Now!