Wrote a simple message board release code, but always can not put the message into the MySQL database, ask the big God pointing wrong!

Source: Internet
Author: User
I beginner PHP and MySQL, imitate php100 video tutorial to do a message board publishing site, but click on the "message" button always pops up "message failed!" , at the same time the database also did not import information, ask the big God to see which out of the code problems, thank you!
Database name: Test_liuyanban
Table Name: Message
Fields: Int (primary key), username (username), email (email), content (message).
Altogether two documents: conn.php and index.php
conn.php:
$conn = @mysql_connect (' localhost ', ' root ', ' 12345 ') or Die (' Connection failed! ');
@mysql_select_db ("Test_liuyanban") or Die (' No database! ');
mysql_query ("Set names ' GBK '");
?>

index.php:
Include_once ' conn.php ';
if ($_post[' POST ']) {
$sql = "INSERT INTO ' message ' (id,username,email,content) VALUES (' ', ' $_post[username] ', ' $_post[email] ', ' $_post[ Content] ";
$result =mysql_query ($sql);
if ($result) {
echo "";
}else{
echo "";
}
}
?>









Reply to discussion (solution)

$sql = "INSERT INTO ' message ' (id,username,email,content) VALUES (', $_post[' username '],$_post[' email '],$_post[' Content ']) ";

$sql = "INSERT INTO ' message ' (id,username,email,content) VALUES (', $_post[' username '],$_post[' email '],$_post[' Content ']) ";

According to this method to try, the page does not display properly, the browser can see this before the change

$result =mysql_query ($sql) or Die (Mysql_error ()); Do you have an error?

$result =mysql_query ($sql) or Die (Mysql_error ()); Do you have an error?
Added the code you said, click "Reply" After the browser displays this

And


How to solve? Thank you Guide




$result =mysql_query ($sql) or Die (Mysql_error ()); Do you have an error?
Added the code you said, click "Reply" After the browser displays this

And


How to solve? Thank you Guide





Wrong, click "Message"

There is no email field in your table, show create table message; Look

There is no email field in your table, show create table message; Look
Find the answer, I made a low-level error, the database field name "email" into the "emai", haha

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