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