[Resolved] An error is returned when mysql is queried in php.

Source: Internet
Author: User
It is about the reason that Chinese characters are not supported: After all mysql attributes are changed to English characters, mysql is used.! If you use mysqli to write data, it will still return NULL (If you test the Password box again, you will receive a logon success prompt if you do not enter the password box or enter 0). All of you can see that the returned result is incorrect. then... it is about the reason that Chinese characters are not supported: After all mysql attributes are changed to English characters, mysql is ready to be used.
But! If you use mysqli to write data, it will still return NULL (If you test it again, the logon will be successful if you do not enter the password box or enter 0)
I understand that the returned result of result is not correct. I just need to use mysqli_fetch_array to retrieve the elements to be used.

Part of the php code is as follows: No information is output that cannot connect to the database (the connection should be successful). No error is reported in the log error logs of apache2 and mysql. however, the returned result value is always NULL. (Of course, if you enter another password, the system will display a wrong password and log on again)
However, the password I set for them in mysql has already been changed to be equal to the account value. Why is an error message returned? Is the query incorrect ??

@ $ Db = new mysqli ('localhost', 'webdba ', '000000', 'educational _ admin'); if (mysqli_connect_errno () {echo "error ". mysqli_connect_errno (). ": Unable to connect to Database"; exit () ;}// echo "success"; if ($ user_type = 'teacher ') {$ query = "select password from teacher where instructor id = $ user_id"; if (! $ Query) {echo 'this user does not exist. Click to log on again ';} $ result = $ db-> query ($ query); // echo $ result .'
'; If ($ result! = $ Passwd) {echo 'incorrect Password
'; $ Db-> close (); echo' click to log on again ';} else {echo $ user_id.' login successful
';}}

Reply content:

It is about the reason that Chinese characters are not supported: After all mysql attributes are changed to English characters, mysql is ready to be used.
But! If you use mysqli to write data, it will still return NULL (If you test it again, the logon will be successful if you do not enter the password box or enter 0)
I understand that the returned result of result is not correct. I just need to use mysqli_fetch_array to retrieve the elements to be used.

Part of the php code is as follows: No information is output that cannot connect to the database (the connection should be successful). No error is reported in the log error logs of apache2 and mysql. however, the returned result value is always NULL. (Of course, if you enter another password, the system will display a wrong password and log on again)
However, the password I set for them in mysql has already been changed to be equal to the account value. Why is an error message returned? Is the query incorrect ??

@ $ Db = new mysqli ('localhost', 'webdba ', '000000', 'educational _ admin'); if (mysqli_connect_errno () {echo "error ". mysqli_connect_errno (). ": Unable to connect to Database"; exit () ;}// echo "success"; if ($ user_type = 'teacher ') {$ query = "select password from teacher where instructor id = $ user_id"; if (! $ Query) {echo 'this user does not exist. Click to log on again ';} $ result = $ db-> query ($ query); // echo $ result .'
'; If ($ result! = $ Passwd) {echo 'incorrect Password
'; $ Db-> close (); echo' click to log on again ';} else {echo $ user_id.' login successful
';}}

First:
If (! $ Query) {echo 'this user does not exist. Click to log on again ';}
This value is always false, and the subsequent values will never be output.

Second:
$ Result = $ db-> query ($ query );
The returned result should be an array, which should be $ result0.

I don't know whether the Chinese in your query is intentionally written in this way or itself. You can print out the query statement and query it in mysql once.

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.