About Warning: mysql_fetch_array (): suppliedargumentisnotavalidMySQLresult-php Tutorial

Source: Internet
Author: User
About Warning: mysql_fetch_array (): suppliedargumentisnotavalidMySQLresult
$ Con = mysql_connect ("localhost", "root", "", "PhysicalTest ");
If (! $ Con)
{
Die ('could not connect: '. mysql_error ());
}
Mysql_select_db ("PhysicalTest", $ con );
Mysql_query ("set names 'gbk _ chinese_ci '");

Error_reporting (E_ALL ^ E_NOTICE );
If (isset ($ _ COOKIE ['student _ id'])
{
$ Student_id = $ _ COOKIE ['student _ id'];
}

$ Result = mysql_query ("SELECT * FROM score WHERE student ID = '$ student_id '");

$ Row = mysql_fetch_array ($ result );
If (empty ($ row) echo "script alert ('No matching items found '); script";
Else {
Echo <HTML
...
Why is there warning, mysql_fetch_array (): supplied argument is not a valid MySQL result... The database table is correct... Ask what is going on.


Reply to discussion (solution)

$ Result = mysql_query ("SELECT * FROM score WHERE student ID = '$ student_id '");
Query failed
You can use echo mysql_error () to check what is wrong.

It is estimated that it is a problem with the Chinese table name and field name.

$ Result = mysql_query ("SELECT * FROM score WHERE student ID = '$ student_id'") or die (mysql_error ());
Check for any errors.

$ Result = mysql_query ("SELECT * FROM score WHERE student ID = '$ student_id '");
Query failed
You can use echo mysql_error () to check what is wrong.

It is estimated that it is a problem with the Chinese table name and field name.


Bytes --------------------------------------------------------------------------------------
The result is as follows: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE student ID = ''' at line 1
Is it because the table name and column name are in Chinese? Should I change it to English?

Try this first
$ Result = mysql_query ("SELECT * FROM 'score 'where' student ID '=' $ student_id '");

But it's not a long term. you don't want to start an English name. you can also use Chinese pinyin.

Try this first
$ Result = mysql_query ("SELECT * FROM 'score 'where' student ID '=' $ student_id '");

But it's not a long term. you don't want to start an English name. you can also use Chinese pinyin.


No more Chinese characters next time. 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.