Php prompts Warning: mysql_fetch_array () expects solution, expects_PHP tutorial

Source: Internet
Author: User
Php prompts "Warning: mysql_fetch_array () expects solution", expects. Php prompts Warning: mysql_fetch_array () expects solution, expects this article describes the php prompt Warningmysql_fetch_array () expects solution, for your reference php prompt Warning: mysql_fetch_array () expects solution: expects

The example in this article describes the solution of the php prompt "Warning mysql_fetch_array () expects", which is for your reference. The specific analysis is as follows:

When connecting to the mysql database, the following error occurs: Warning: mysql_fetch_array () expects.... in my experience, the query returned by the SQL statement is empty. we have not used it directly.

Mysql_fetch_array () function. let's take a look at the problem solution. my code is as follows:

The code is as follows:

Include ("conn. php ");
If (! Empty ($ _ GET ['id']) {
$ SQL = "select * from news where 'id' = '". $ _ GET ['id']. "'";
$ Query = mysql_query ($ SQL );
$ Rs = mysql_fetch_array ($ query );
}


Error message: Warning: mysql_fetch_array () expects parameter 1 to be resource, boolean given in F: xmappmylibrarysearch_result.php on line 32

Later, I upgraded the code as follows:

The code is as follows:

If (! Empty ($ _ GET ['id']) {
$ SQL = "select * from news where 'id' = '". $ _ GET ['id']. "'";
$ Query = mysql_query ($ SQL );
If (mysql_num_rows ($ query)
{
$ Rs = mysql_fetch_array ($ query );
}
Else
{
Mysql_error ();
}
}


In this way, the mysql error message is displayed. The result is that the SQL statement is faulty. modify the SQL statement.

Tip:This type of error is caused by our non-standard syntax. if we want to handle this type of error, we only need to output one SQL statement or process it in mysql_query (SQL) or die (mysql_error, to locate errors more accurately.

I hope this article will help you with PHP programming.

Explain () expects solution, expects this article describes the php prompt Warning mysql_fetch_array () expects solution, share it for your reference...

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.