PDO Execute execution failed
I saved the session to the MySQL database and saved the SessionID in a user table. I want to find the corresponding data in the session table through the SessionID in the user 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 here This binding parameter must be a ADMIN_SESSID string, not a variable value OH
------Solution--------------------
Example #3 executes a preprocessing statement (placeholder) using an array containing the inserted values
/* executes a preprocessing statement by passing an array of inserted values */
$calories = 150;
$colour = ' red ';
$sth = $dbh->prepare (' SELECT name, colour, calories
From fruit
WHERE calories <? and colour =? ');
$sth->execute (Array ($calories, $colour));
?>
------Solution--------------------
Execute (Array (' admin_sessid ')) execution result is false
This means the error, because it is not PHP's fault, nature will not automatically prompt out
You can print out the results of errorinfo to see
------Solution--------------------
Find a data from two tables?
To correlate two table queries!
------Solution--------------------
Binding is a value, not a field name
At least write it like this.
$sql = ' Select Update_time from Admin_session,admin where Admin_session.sessid=admin.sessid and admin.sessid=? ';