PHP hint Warning:mysql_fetch_array () expects_php Tutorial

Source: Internet
Author: User
My height 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);
}

The hint is wrong.

Warning:mysql_fetch_array () expects parameter 1 to BES resource, boolean given in F:xmappwww.bkjia.c0mmylibrarysearch_res Ult.php on line 32

Later I upgraded the code

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 ();
}
}

This will see the MySQL error message, the result is a SQL statement has a problem, the SQL statement can be modified,

A small series of tutorials tips you, cause this kind of error is our grammar is not standardized, if you want to handle only the SQL to do a strip of output processing or in mysql_query (SQL) or Die (Mysql_error ()) to handle this site original reprint must indicate the source/HTTP/ Www.bKjia.c0m/phper/php.html

http://www.bkjia.com/PHPjc/687413.html www.bkjia.com true http://www.bkjia.com/PHPjc/687413.html techarticle My height code has the following include ("conn.php"), if (!empty ($_get[' id ')) {$sql = "SELECT * from news where ' id ' = '". $_get[' id ']. "'"; Query=mysql_query ($sql); $rs = mysql_fetch_array ($qu ...

  • Related Article

    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.