Wrote a simple message board release code, but always can not put the message into the MySQL database, ask the big God pointing wrong!
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 "";
}
}
?>
Share to:
------Solution--------------------
$sql = "INSERT INTO ' message ' (id,username,email,content) VALUES (', $_post[' username '],$_post[' email '],$_post[' Content ']) ";
------Solution--------------------
There is no email field in your table, show create table message; Look