Simple PHP Message This example code _php tutorial

Source: Internet
Author: User
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 ' ...

  • 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.