Page 1 of 1

The right func breake it, other func also but at least it works

Posted: 2024-02-22 13:15
by arcanebits
CONTEXT:
Will add manualy a record after the login_ok, After the partial success and total failure I GET ERROR500, the insert works nice in phpadmin and also using the wrong func it ADDS a record but the right func does noting at all. Code Bellow:

function login_ok($memberInfo, &$args) {

///This sends an email it works nicely
$timeTasks=sqlValue("SELECT SUM(minuesti) FROM tareas WHERE tareas.cip='1' AND tareas.estado='Activo' AND DATE(tareas.fechaini) = CURDATE()");
mail(
'aalain@???.com',
'Entrada al sistema exitosa, dentro veras los segundos pendientes' ,
'Tienes un total de: ' . $timeTasks . ' segundos pendientes.' ,
"From: tachasserver@???\r\n"
);
///This works adding the record (I know this is not the right func but at least it adds the record, then breaks
$anade=sqlValue("INSERT INTO tareas (detalle, fechaini, fechafinal, cip, estado, minuesti, tipo) VALUES ('macarron', '$fecha_actual', '$fecha_actual', 1, 'Activo', 88, 'Recu')");

///This is supposed to be the right func, it just breaks the system
sql("INSERT INTO tareas (detalle, fechaini, fechafinal, cip, estado, minuesti, tipo) VALUES ('macarron', '$fecha_actual', '$fecha_actual', 1, 'Activo', 99, 'Recu')");

return '';
}

Re: The right func breake it, other func also but at least it works

Posted: 2024-02-22 21:18
by pbottcher
Hi try

Code: Select all

$eo=Array();
$anade=sqlValue("INSERT INTO tareas (detalle, fechaini, fechafinal, cip, estado, minuesti, tipo) VALUES ('macarron', '$fecha_actual', '$fecha_actual', 1, 'Activo', 88, 'Recu'),$eo");
Actually the Same applies for the sql function call

Re: The right func breake it, other func also but at least it works

Posted: 2024-02-26 17:36
by arcanebits
Hi, thanks for the help this is the status (failed) here is what I did

01 Sanitized the sql statement so it adds nulls just for minimize any dumb error

02 Tested running and works but BREAKS it
$anade=sqlValue("INSERT INTO tareas (cip, nomb1, ape1, detalle, fechaini, comentario, fechafinal, estado, minuesti, tipo) VALUES (1, NULL, NULL, 'gettinghelp','$fecha_actual', NULL, '$fecha_actual', 'Activo', 77, 'Recu')");

03 Added the sugested adjustments and it doesnt breake it, but it doesnt add anything to the DB either:
$eo=Array();
$anade=sqlValue("INSERT INTO tareas (cip, nomb1, ape1, detalle, fechaini, comentario, fechafinal, estado, minuesti, tipo) VALUES (1, NULL, NULL, 'gettinghelp','$fecha_actual', NULL, '$fecha_actual', 'Activo', 77, 'Recu'),$eo");

I think Im doing something wrong
Any comment?
a3

Re: The right func breake it, other func also but at least it works

Posted: 2024-02-26 18:35
by jsetzer
Just a hint:
I've seen that data-mofifying SQL commands like INSERT, UPDATE, DELETE may not work with sqlValue-function.

For those try sql("YOUR SQL COMMAND", $eo) instead of sqlValue("...", $eo).

That's just what I've noticed when migrating projects to PHP 8.x.

Re: The right func breake it, other func also but at least it works

Posted: 2024-02-28 15:34
by arcanebits
Thanks! Im gonna try that ASAP
aw