Tutorial: I downloaded the PHP code of a message board from the Internet, but the Mysql content cannot be displayed in the browser. I downloaded the PHP code of a message board from the Internet, however, the content in the Mysql table cannot be displayed in the browser. If no error is displayed, it is blank. I don't know which part of the code is incorrect. please help me with it. thank you. & Nbsp; The following is the original code & nbsp; & lt ;! DOCTYPEHTMLPUBLIC & quot;-W3C Tutorial: I downloaded the PHP code of a message board from the Internet, but the Mysql content cannot be displayed in the browser.
I downloaded the PHP code of a message board from the Internet, but the content in the Mysql table cannot be displayed in the browser. If no error is displayed, it is blank and I don't know which part of the code is wrong, thank you for your help.
The following is the original code
Untitled Document
$ DBhost = "localhost"; // server name
$ DBuser = "user name (existing)"; // User name
$ DBpass = "password (existing)"; // user password
$ DBName = "super-tomato"; // database name
$ Table = "guestbook"; // table name of the database
$ NumComments = 10; // number of records displayed per worker
// Start connecting to mysql
$ DBConn = mysql_connect ($ DBhost, $ DBuser, $ DBpass) or die ("unable to connect to the database:". mysql_error ());
// Select the mysql database
Mysql_select_db ($ DBName, $ DBConn) or die ("unable to connect to the database:". mysql_error ());
$ Action = $ _ GET ['action']; // wait for execution
Switch ($ action) {// use switch... case here. I don't want to be familiar with it.
Case 'read': // read data
// SQL command... select the content of the data table
$ SQL = 'select * FROM ''. $ table .''';
$ AllComments = mysql_query ($ SQL, $ DBConn) or die ("unable to select materials:". mysql_error ());
$ NumallComments = mysql_num_rows ($ allComments); // get the number of records returned
$ SQL. = 'Order BY 'time' DESC LIMIT '. $ _ GET ['numlow'].', '. $ numComments;
$ FewComments = mysql_query ($ SQL, $ DBConn) or die ("unable to select materials:". mysql_error ());
$ NumfewComments = mysql_num_rows ($ fewComments );
Print '& totalEntries ='. $ numallComments .'&';
Print"
& Entries = ";
If ($ numallComments = 0 ){
Print "no record ....";
} Else {
While ($ array = mysql_fetch_array ($ fewComments )){
$ Name = mysql_result ($ fewComments, $ I, 'name ');
$ Email = mysql_result ($ fewComments, $ I, 'Email ');
$ Comments = mysql_result ($ fewComments, $ I, 'comments ');
$ Time = mysql_result ($ fewComments, $ I, 'time ');
Print'
Name:'. $ Name .'
Email:'. $ Email .'
Message:'. $ Comments .'
Date: '. $ time .'
';
$ I ++;
}
}
Break;
Case 'write': // write record
// Receives data from Flash.
$ Name = ereg_replace ("&", "% 26", $ _ POST ['username']);
$ Email = ereg_replace ("&", "% 26", $ _ POST ['useraddress']);
$ Comments = ereg_replace ("&", "% 26", $ _ POST ['usermessage']);
$ TodayDate = date ("Y-m-d H: I: s", time (); // get the current server time
// Write data into the data table
$ SQL = "INSERT ". $ table. "(name, email, comments, time) VALUES ('$ name',' $ email ',' $ comments ',' $ todaydate ')";
$ Insert = mysql_query ($ SQL, $ DBConn) or die ("unable to connect to database:". mysql_error ());
If ($ insert ){
Print '$ msg = Successful ';
} Else {
Print '$ msg = error ';
}
Break;
}
?>
------ Solution --------------------
It is actually wrong, but you have not enabled the error mode. you can open the error mode and check again.