Update Query by passing id but found error mention below

Hi , I am passing id with a button and i had done it but i want add update query in suitecrm like
$sql="UPDATE users SET status='Active' WHERE id='user_id'";


but found error below error on this line $db->query($sql):

Fatal error : Uncaught Error: Call to a member function query() on null in C:\xampp\htdocs\SuiteCRM-7.12.7\custom\MyTimeEntryPoint.php:15

Well, what is your $db variable set to? You need to initialize it to contain the database object.

1 Like

Hola! El error se debe a que estás intentando utilizar el método “query()” en una variable no definida -null-.
Deberías previamente instanciarlo.

$conexion = “mysql:host=.;dbname=”;
$PDOcon = new PDO($conexion, “use” , “pass”, $options);

luego podrías utilizarlo en tu variable $PDOcon

1 Like

Hi , i had done it ,it was simple

$bean = BeanFactory::getBean(‘Users’,$id);





yes you are right it was my mistake i was using $db->query($sql); i was intiallizing $db but it was no use ,i do not how i was using this