PDOexecute failed. I saved the session to the mysql database and saved the sessionID to another user table. I want to use the sessionID in the user table to find the corresponding data in the session table. The code is as follows: $ SQL & nbsp; select & nbsp; update_time & nbsp; from & nbsp; admin_session, admin & nbsp PDO execute execution failed
I saved the session to the mysql database and saved the sessionID to another user table. I want to use the sessionID in the user table to find the corresponding data in the session table. The code is as follows:
$ SQL = 'SELECT update_time from admin_session, admin where admin_session.sessid =? ';
$ Stmt = $ pdo-> prepare ($ SQL );
$ Stmt-> execute (array ('admin _ sessid '));
------ Solution --------------------
What is the error message?
------ Solution --------------------
Array ('admin _ sessid ') is not the bound parameter. it must be the admin_sessid string, not the variable value.
------ Solution --------------------
Example #3 use an array containing inserted values to execute a preprocessing statement (placeholder)
/* Execute a preprocessing statement by passing an array of inserted values */
$ Calories = 150;
$ Color = 'red ';
$ Something = $ dbh-> prepare ('select name, color, calories
FROM fruit
WHERE calories <? AND color =? ');
$ Something-> execute (array ($ calories, $ color ));
?>
------ Solution --------------------
Execute (array ('admin _ sessid '). The execution result is false.
This indicates an error. because it is not a php error, it will not be automatically prompted.
You can print the result of errorInfo to view
------ Solution --------------------
Find a data from two tables?
Join two tables for query!
------ Solution --------------------
It is bound with a value, not a field name.
At least write like this
$ SQL = 'SELECT update_time from admin_session, admin where admin_session.sessid = admin. sessid and admin. sessid =? ';