Skip to content
Advertisement

Unable to update a field in phpMyadmin using PHP

I have been trying to update a field in database using php, everytime I run the script there is no effect on the table. Here’s how my code looks :

$sql="UPDATE users set sentMsg = $msg+1 where username = '$username' ";
$result = $link->query($sql);

where $link is the connection variable which is working fine with other queries. Here’s the table structure. enter image description here

The $result variable is returning true. I am unable to understand where the actual problem is.

Advertisement

Answer

Try this

$sql="UPDATE `users` SET `sentMsg` =".($msg+1)." WHERE `username` ='".$username."'";

$result = mysqli_query($link,$sql);

Thats what i could make out of your code till now.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement