Today the test database connection, traversing the data table in the information is the following error has occurred:
Warning:mysql_fetch_row (): supplied argument is not a valid MySQL result resource in D:\AppServ\www\wordpress\lianjie001. PHP on line 20
The code I originally wrote was this:
$db _host= "localhost";
$db _database= "WordPress";
$db _username= "root";
$db _password= "admin123";
$connection =mysql_connect ($db _host, $db _username, $db _password);
mysql_query ("Set names ' UTF8 '");
$sql = "SELECT * from Huanzhexinxi";
$result =mysql_query ($sql);
while ($resultrowzhen =mysql_fetch_row (($result))) {
$huanname = $resultrowzhen [0];
$huanage = $resultrowzhen [1];
$huancall = $resultrowzhen [2];
$huanliu = $resultrowzhen [3];
echo "";
echo "Name: $huanname
";
echo "Age: $huanage
";
echo "Tel: $huancall
";
echo "Patient Message: $huanliu
";
echo "
";
}
Mysql_close ($connection);
?>
Check the half-day also did not find errors, and then peer guidance is missing the code to select the database is as follows:
$db _selecct=mysql_select_db ($db _database);
The complete code is the following to complete the traversal.
$db _host= "localhost";
$db _database= "WordPress";
$db _username= "root";
$db _password= "admin123";
$connection =mysql_connect ($db _host, $db _username, $db _password);
mysql_query ("Set names ' UTF8 '");
$db _selecct=mysql_select_db ($db _database);
$sql = "SELECT * from Huanzhexinxi";
$result =mysql_query ($sql);
while ($resultrowzhen =mysql_fetch_row (($result))) {
$huanname = $resultrowzhen [0];
$huanage = $resultrowzhen [1];
$huancall = $resultrowzhen [2];
$huanliu = $resultrowzhen [3];
echo "";
echo "Name: $huanname
";
echo "Age: $huanage
";
echo "Tel: $huancall
";
echo "Patient Message: $huanliu
";
echo "
";
}
Mysql_close ($connection);
?>
Reply to discussion (solution)
Is this the question? Or do you want to share your experience?
The knot rate is 0, it's an impulse to come and play.
To give a man to fish is better than to teach
Echo Mysql_error ();
mysql_query ($sql) or Die (Mysql_error ());
4 Floor positive solution ....