PDO query failed!

Source: Internet
Author: User
PDO query failed! The code is as follows:
 
 Prepare ($ SQL); $ stm-> execute (array ($ name, $ password); $ rs = $ stm-> fetch (); var_dump ($ rs ); if (empty ($ rs) {echo "script alert ('query failed'); script";} else {echo "script" alert ('query succeeded '); script ";}?>


Admin table


Now the question is: If fetch is obtained, use empty to judge that false is returned. why?


Reply to discussion (solution)

Come on...

$ SQL = "select * from admin where user_name =? And password =? ";
What is this query?

Comment out error_reporting (0 );
Add print_r ($ db-> errorinfo () to lines 16 and 17 ());

$ SQL = "select * from admin where user_name =? And password =? ";
What is this query?

Query whether the user exists in the admin table! User name and md5-encrypted password

Comment out error_reporting (0 );
Add print_r ($ db-> errorinfo () to lines 16 and 17 ());

After adding a great God, the output is as follows: Array ([0] => 00000 [1] => [2] =>). What are the problems?

It indicates that no error has occurred.
Therefore, we can assume that your table does not have a qualified record.

It indicates that no error has occurred.
Therefore, we can assume that your table does not have a qualified record.

The field length is set to be less, and the md5 encrypted password is 32 characters. I only gave 30 characters, so the password is missing 2 characters! Thank you!

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.