Why is mysql_fetch_array not executed?

Source: Internet
Author: User
Why is mysql_fetch_array not executed? Reference & lt ;? Phperror_reporting (0); $ conn = mysql_connect ("localhost", "root", "root"); // enter the database connection information mysql_select_db ("a1209173000 "); // why is mysql_fetch_array not executed?
Reference
Error_reporting (0 );
$ Conn = mysql_connect ("localhost", "root", "root"); // enter the database connection information.
Mysql_select_db ("a1209173000"); // enter the database name
$ ValA = $ _ POST ["valA"];
If ($ valA! = ""){
$ SQL = "select * from table where chepai = '". $ valA ."'";
$ Result = mysql_query ($ SQL );
While ($ arr = mysql_fetch_array ($ result ))
{
Echo $ arr ["name"]."
";
}
} Else {
?>

}
?>


By adding echo output after each row, we can find that while ($ arr = mysql_fetch_array ($ result) is not executed. what is wrong? $ SQL is normal.
------ Solution --------------------
$result=mysql_query($sql);
if(mysql_error()){
  echo mysql_errno() . ": " . mysql_error() . "\n";
}

Check whether an error is reported?
------ Solution --------------------
In
Mysql_select_db ("a1209173000"); // enter the database name
And then add
Mysql_query ('set names gbk ');
This is because the operated data is inconsistent with the default character set of the database.

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.