Getting Started example PHP MySQL reading the data in the table fails, ask the hero to teach

Source: Internet
Author: User
Tags php mysql
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 ']?
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.