PHP made a good message board, click on the content sent. The SQL data is not receiving information. Other pages can show the output!
I made a message boards with PHP. Message Board home page with "index.php". A successful output of the webpage "chenggong.php". The other one is the page "shujuku.php" that was submitted to the database for success. I made two forms on the homepage, one for the Submit button and text field for the successful output page. When you click the button, the chenggong.php page receives the message. The question is "when I click on the" shujuku.php "page of the content submitted to the database. The data is not receiving the input information. The code for index.php is:
The code for the shujuku.php page is: $sql = "INSERT into ' db_message '. ' T_message ' (";
$sql = $sql. " Intmessageid ', ' strcontent ') ";
$sql = $sql. " VALUES (NULL, ' ". $strContent." '); ";
Echo
". $sql;
$connect = mysql_connect ("localhost", "root", "qqq3893009") or Die ("Unable to connect database server!");
$query = Mysql_db_query ("Db_message", $sql, $connect) or Die ("
Save Failed ");
echo "
Save Success ";
?>
Note: The result of his output is: Save failed.
What I want is to save the success.
Format of my SQL data table: Data name: Db_message table name: T_message ID field: Intmessageid message Content field: Strcontent
------Solution--------------------
You don't seem to have chosen a database. Should there be mysql_select_db ("Your database name") or Die ("Select Database error, please check"); Do you want to put this statement behind Mysql_connect () and try
------Solution--------------------
It is also not recommended that you use Mysql_db_query ()
This is the official manual content:
Mysql_db_query
(PHP 4, PHP 5, PECL mysql:1.0)
Returns a positive MySQL result resource number based on the query result, FALSE on error. This function returns True/false to the Insert/update/delete query to indicate success or failure.
Mysql_db_query () Select a database and execute the query on it. If you do not provide an optional connection ID, this function will find an open connection to the MySQL server, and if it cannot find an open connection, it will attempt to create one without a parameter call mysql_connect ().
Note This function does not switch back to the database that you previously connected to. In other words, you cannot use this function to temporarily execute SQL queries on another database, only manually switching back. It is strongly recommended that users replace this function with the database.table syntax in SQL queries.
See Mysql_connect () and mysql_query ().
Note: Use of this function is not advocated from PHP 4.0.6. Do not use this function with mysql_select_db () and mysql_query () instead.
------Solution--------------------
MySQL SQL statements in the database name, table name, field names are not single quotation marks "'", but with the anti-quote "'", is "~" under that.
------Solution--------------------
The grammar is wrong! Database No! How do you plug it?
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.