Getting Started example PHP MySQL reading the data in the table failed to ask the hero to teach
1. Problem: Read MySQL in a table in PHP, how can not read it, the page is sometimes blank, and sometimes a bar code in PHP, bitter tune a day, for guidance! Appreciate!!
2.mysql, database: Test; table name: Apple; (field: Firstname,lastname)
3.index.php (tried to connect the database successfully)
Code:
PHP Pagination Example
$DBH = @mysql_connect ("localhost", "root", "");
if (! $dbh) {die ("error");}
@mysql_select_db ("Test", $DBH);
$sql = "SELECT * from Apple";
?>
$rs = mysql_query ($sql, $DBH);
echo $row [id];
echo $row [name];
Echo '
';
?>
@mysql_close ($DBH);
Please help the heroes, heavens!!
------Solution--------------------
This post was last edited by phpnewnew on 2012-05-27 17:51:30
The log error is only a hint that the default icon does not exist, and it is not related.
Take a closer look at the code
while ($row = Mysql_fetch_array ($rs))
echo $row [id];
echo $row [name];
Echo '
';
?>
Add the parentheses here
while ($row = Mysql_fetch_array ($rs)) {
echo $row [id];
echo $row [name];
Echo '
';
}
?>
Save after refresh to see
In addition, you don't say that the database is
(Field: Firstname,lastname)
How to run a $row [' ID ']? $row [' name ']?