Error in PHP mysql_query return value
$conn =mysql_connect ("localhost", "root", "root") or Die ("link database failed");
mysql_select_db ("text");
$sql = "SELECT * from MyText";
$query =mysql_query ($sql);
if ($query)//Determine if mysql_query successfully returned
{
echo "true";
$num =mysql_fetch_array ($query);
Print_r ($num);
echo $num [1];
}
Else
echo "false";
?>
Execute knot: The page prints out false
Why is the $sql= "select * from MyText" not executed successfully, the tables in the database have fields and values?? Ask for prawns to help!!
------Solution--------------------
$query =mysql_query ($sql) or Die (Mysql_error ());
Is that an error?
It is recommended that you write the canonical point:
else{
echo "false";
}
------Solution--------------------
Database name is text? This is the MySQL reserved word oh, add anti-quote try:
PHP Code
mysql_select_db ("' Text '");