An error occurred while reading table data in phpmysql. could you please advise?

Source: Internet
Author: User
An error occurred while reading data from the table in phpmysql. question: I can't read a table in mysql using php. the page is sometimes blank, and sometimes there is a section of code in php. I 've been calling it for a day. please help me! Thank you !! 2. in mysql, database: test; table name: apple; (field: firstname, l entry example: failed to read table data in php mysql. could you please advise?
1. problem: I can't read a table in mysql using php. the page is sometimes blank. sometimes I have a code section in php. I 've been calling it for a day. please give me some advice! Thank you !!
2. in mysql, database: test; table name: apple; (field: firstname, lastname)
3. index. php (successful connection to the database)
Code:




Php paging example




$ Dbh = @ mysql_connect ("localhost", "root ","");
If (! $ Dbh) {die ("error ");}
@ Mysql_select_db ("test", $ dbh );
$ SQL = "SELECT * FROM apple ";
?>
$ Rs = mysql_query ($ SQL, $ dbh );
While ($ row = mysql_fetch_array ($ rs ))
Echo $ row [id];
Echo $ row [name];
Echo'
';
?>
@ Mysql_close ($ dbh );
?>



 

Thank you !!
------ Solution --------------------
This post was last edited by PhpNewnew at 17:51:30. the error message is that the default icon does not exist. it does not matter.

Read the code carefully
While ($ row = mysql_fetch_array ($ rs ))
Echo $ row [id];
Echo $ row [name];
Echo'
';
?>

Brackets are added here.

While ($ row = mysql_fetch_array ($ rs )){
Echo $ row [id];
Echo $ row [name];
Echo'
';
}
?>

Save and refresh.


In addition, you do not say that the database is
(Field: firstname, lastname)

How to run $ row ['id']? $ Row ['name']? Come out

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.