Update Multiple columns with no effect


I am developing an API’s, in my project we are using dynamic databases so for that one i am connecting databases by using mysqli it’s working fine i can able to do CRUD operations also on Database but if i try to update multiple columns at that time changes are not reflected in Database did i miss anything can anyone please help me ?

$childConnection=  new mysqli(env('DB_HOST', ''), env('DB_USERNAME', 'test'), env('DB_PASSWORD', ''), $item->dbname,env('DB_PORT', '3306'),env('DB_SOCKET', ''));
$childConnection->query("UPDATE users SET name={$uname} WHERE id={$uid}"); // this query is working fine.

 $t_now = Carbon::now();
 $t_sessionStarted = \Carbon\Carbon::parse($userData['log_time']);
 $r_time= $t_sessionStarted->diffForHumans($t_now, ['parts' => 3, 'syntax' => CarbonInterface::DIFF_ABSOLUTE]); //output is "2hours 50minutes"
$childConnection->query("UPDATE users SET ltime={$r_time} WHERE id={$uid}"); //This is not working

Desc users :- ltime is VARCHAR(300)


name={$uname} should be name='{$uname}' since it is a string

same for SET ltime={$r_time} should be SET ltime='{$r_time}'

also VARCHAR cannot be > 255

Answered By – Ron

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published