Why is mysql_fetch_array not executed?
citation
error_reporting (0);
$conn =mysql_connect ("localhost", "root", "root");//fill in the database connection information
mysql_select_db ("a1209173000");//fill in 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 the echo output at the back of each line, the discovery executes to the while ($arr =mysql_fetch_array ($result)) when there is no execution, what's wrong, $sql normal
Share to: more
------Solution--------------------
$result =mysql_query ($sql);
if (Mysql_error ()) {
Echo Mysql_errno (). ": " . Mysql_error (). "\ n";
}
See if there's an error?
------Solution--------------------
In
mysql_select_db ("a1209173000");//fill in the database name
After that, join
mysql_query (' Set names GBK ');
This is caused by inconsistencies between the data being manipulated and the default character set of the database