I downloaded the PHP code of a message board from the Internet, but the Mysql content cannot be displayed in the browser.
Source: Internet
Author: User
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 ;! DOCTYPEHTMLP: 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 ());
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.