finlander208 Posted March 9 Share Posted March 9 (edited) trying to update a single value in the database. The variable value in PHP is good but db query won't update the value in the row in the database table. No errors in error logs in file directory or in console in browser. I am loading in config.inc.php so class Db can execute (this is a small specialty php file). What could be wrong? <?php require(dirname(__FILE__).'/../../../config/config.inc.php'); function getOAuthCreds() { ... $token = $array['access_token']; var_dump ($token); // all is good here $query = "UPDATE `"._DB_PREFIX_."configuration` SET value=". $token ." WHERE id_configuration=1772"; Db::getInstance()->Execute($query); return $token; } getOAuthCreds(); ?> Edited March 10 by finlander208 (see edit history) Link to comment Share on other sites More sharing options...
Nickz Posted March 9 Share Posted March 9 What happened when executing and which errorlogs are you viewing? Is that your shop you wish to update a DB Table? Why don't you go to PHPMyAdmin? Link to comment Share on other sites More sharing options...
ComGrafPL Posted March 9 Share Posted March 9 On 3/9/2025 at 1:06 PM, finlander208 said: trying to update a single value in the database. The variable value in PHP is good but db query won't update the value in the row in the database table. No errors in error logs in file directory or in console in browser. I am loading in config.inc.php so class Db can execute (this is a small specialty php file). What could be wrong? <?php require(dirname(__FILE__).'/../../../config/config.inc.php'); function getOAuthCreds() { ... $token = $array['access_token']; var_dump ($token); // all is good here $query = "UPDATE `"._DB_PREFIX_."configuration` SET value=". $token ." WHERE id_configuration=1772"; Db::getInstance()->Execute($query); return $token; } getOAuthCreds(); ?> Expand Maybe with: $query = "UPDATE `"._DB_PREFIX_."configuration` SET value='". pSQL($token) ."' WHERE id_configuration=1772"; Db::getInstance()->execute($query); 1 Link to comment Share on other sites More sharing options...
finlander208 Posted March 9 Author Share Posted March 9 On 3/9/2025 at 1:17 PM, Nickz said: What happened when executing and which errorlogs are you viewing? Is that your shop you wish to update a DB Table? Why don't you go to PHPMyAdmin? Expand hi and thank you. Everything seems fine when executing. I am checking logs in the directory where this file is, and root directory of the site. Yes, it's my shop's database table. I need to do this with a cron job every two hours, by running this file with a cron job. If I could get this DB update to work, then I would have the whole job done. Link to comment Share on other sites More sharing options...
finlander208 Posted March 9 Author Share Posted March 9 On 3/9/2025 at 1:19 PM, ComGrafPL said: Maybe with: $query = "UPDATE `"._DB_PREFIX_."configuration` SET value='". pSQL($token) ."' WHERE id_configuration=1772"; Db::getInstance()->execute($query); Expand worked precisely. Thank you very much. Link to comment Share on other sites More sharing options...
Prestashop Addict Posted March 10 Share Posted March 10 Don't forget to change your title post by adding [SOLVED] and add a Thanks or Like to the good answer, this will help community. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now