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