Consider the following mysql table:
table: information
id | name | address | mobile
----------------------------
1 | Mr.X | Japan | 95321663
2 | Mr.Y | USA | 1458963201
Here, id is PRIMARY key and name and address is UNIQUE columns. Now while I update the table by the following query:
UPDATE information SET name='Mr.Z', address='Japan', mobile=95321663 WHERE id=1;
it successfully updates the table, but if I try by:
UPDATE information SET name='Mr.X', address='Japan', mobile=95321663 WHERE id=1;
It is not updating the database. I catch the update success by following php code:
if($this->conn->affected_rows>=1{
echo 'Data updated successfully!';
}else{
echo 'Data could not be updated due to: '.$this->conn->err;
}
Note that, in 2nd query, all field value of mysql table is same (for id=1).
I want to set an error message if there is any error in sql syntax or other type error.
How to achieve this?