$host = "localhost";
$user = "root";
$password = "123456";
$connection = Mysqli_connect ($host, $user, $password);
if (! $connection) {
Exit (' Failed to connect to MySQL database! ');
}
$dbname = "Chuanke";
mysqli_select_db ($connection, $dbname);
$sql = "SELECT * from ' user '";
$result = Mysqli_query ($connection, $sql);
while ($row =mysqli_fetch_array ($result))
{
echo $row [' UserName ']. "
";
}
?>
This time tip: notice:undefined index
Then I changed the while ($row =mysqli_fetch_array ($result)) to while ($row =mysql_fetch_array ($result))
This time the error becomes: mysql_fetch_array () expects parameter 1 to be resource,
Reply to discussion (solution)
Open Error_report,
Ini_setting ("Display_errors", 1);
Each line of code is var_dump a bit. You'll almost be able to locate the problem.
The ability to strengthen the debug base.
while ($row = Mysql_fetch_array ($result, Mysql_assoc)) {
Alas, the whole day is my careless echo $row [' UserName '].
"; [' UserName '] should be [' UserName '] or thank you upstairs. Two-bit Help