Jump to content

[SOLVED] update database value from php file


Recommended Posts

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 by finlander208 (see edit history)
Link to comment
Share on other sites

  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);

 

  • Thanks 1
Link to comment
Share on other sites

  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

  • finlander208 changed the title to [SOLVED] update database value from php file

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...