PDO execute execution failed to solve the idea

Source: Internet
Author: User
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=? ';
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.