I have got MySQL table with three columns 'primary Key','debit_cash','user_id' So now i want to update the debit_cash values to the corresponding user_id by adding "15" to the value already present. The debit_cash is in VARCHAR so i tried converting to int and sum it , but still the values in MySQL is not changing .
Here is my code:
$user_id = $_POST['user_id'];
//importing database connection script
//Creating sql query
$sql = "SELECT cos_details.debit_cash AS debitCash,
(convert(int, debit_cash)+15) AS updatedDebitCash
UPDATE cos_details SET debit_cash = '$updatedDebitCash'
WHERE user_id = $user_id";
//Updating database table
echo 'Updated Successfully';
echo 'Could Not Update Try Again';
Seems that you don't need the select but the update only
UPDATE cos_details SET debit_cash = cast( (convert(int, debit_cash)+15) as VARCHAR(20)) WHERE user_id = $user_id
could be that your user_id is a string too so you should surround the value with quote
UPDATE cos_details SET debit_cash = cast( (convert(int, debit_cash)+15) as VARCHAR(20)) WHERE user_id = '$user_id'