config.php
Copy CodeThe code is as follows:
$conn = @mysql_connect ("localhost", "root", "") or Die ("Database connection Error!");
mysql_select_db ("GB", $conn);
mysql_query ("Set names ' GBK '");
?>
add.php
Copy CodeThe code is as follows:
Include ("config.php");
if ($_post[' submit ']) {
In this case, forget that the message has a field lastdate not written, resulting in the insertion of data is unsuccessful. It took a long time to find out the mistake.
$sql = "INSERT into message (id,user,title,content,lastdate) VALUES (' ', ' $_post[user] ', ' $_post[title] ', ' $_post[ Content] ', now ()) ";
mysql_query ($sql);
echo "Success";
}
?>
view.php
Copy CodeThe code is as follows:
Include ("config.php");
?>
$sql = "SELECT * from message ORDER by id DESC"; $query =mysql_query ($sql); while ($row =mysql_fetch_array ($query)) {?>//nnd. I use this syntax in the Wampserver default environment, which is to not read the content. You have to use this. Depressed. It was a long time before I figured it out
| Title: User: |
| Content: |
}?>
Then there is a database of SQL.
Copy CodeThe code is as follows:
CREATE TABLE ' message ' (
' id ' tinyint (1) not NULL auto_increment,
' User ' varchar (+) not NULL,
' title ' varchar (not NULL),
' Content ' Tinytext not NULL,
' Lastdate ' date not NULL,
PRIMARY KEY (' id ')
) Engine=innodb DEFAULT CHARSET=GBK auto_increment=1;
http://www.bkjia.com/PHPjc/321804.html www.bkjia.com true http://www.bkjia.com/PHPjc/321804.html techarticle config.php Copy the code as follows:? php $conn = @mysql_connect ("localhost", "root", "") or Die ("Database connection Error!"); mysql_select_db ("GB", $ conn); mysql_query ("Set names ' GBK ' ...