On the PHP message board, click the sent content. SQL data cannot receive information. Output is displayed on other pages! Solution

Source: Internet
Author: User
On the PHP message board, click the sent content. SQL data cannot receive information. Output is displayed on other pages! I made a message board using PHP. The homepage of the message board uses "index. php ". A successfully exported webpage & quot; chenggong. php & quot ;. the other one is the "shujuku" page that is successfully submitted to the database. php ". I made two forms on the homepage. one is a message board for successful PHP, and click the content to be sent. SQL data cannot receive information. Output is displayed on other pages!
I made a message board using PHP. The homepage of the message board uses "index. php ". A successful webpage "chenggong. php ". the other one is the "shujuku" page that is successfully submitted to the database. php ". I made two forms on the home page. one is the submit button and text field for the successfully output page. Click the button and you will receive the message on the "chenggong. php" page. The problem arises when I click the "shujuku. php" page of the content submitted to the database. The data cannot receive the input information. The index. php code is:

The shujuku. php page code 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 ("
  • Failed to save ");
    Echo"
  • Saved successfully ";
    ?>
    Note: The output result is: failed to save.
    What I want is to save successfully.


    Set the format of my SQL Data Table: data name: db_message table name: t_message ID field: intMessageID message content field: strContent



    ------ Solution --------------------
    You didn't seem to have selected a database. Whether mysql_select_db ("your database name") or die ("The selected database is incorrect. check"); whether to put this statement after mysql_connect ().

    ------ Solution --------------------
    We do not recommend that you use mysql_db_query ()
    This is the content of the official manual:
    Mysql_db_query
    (PHP 4, PHP 5 and PECL mysql: 1.0)

    Mysql_db_query-send a MySQL Query

    Description
    Resource mysql_db_query (string $ database, string $ query [, resource $ link_identifier])

    Returns a positive MySQL result resource number based on the query results. If an error occurs, FALSE is returned. This function returns TRUE/FALSE for the INSERT/UPDATE/DELETE query to indicate success or failure.

    Mysql_db_query () select a database and execute the query on it. If no optional connection identifier is provided, this function will find an opened connection to the MySQL server. If no connection is found, mysql_connect () will be called without parameters ().

    Note that this function will not switch back to the database previously connected. In other words, you cannot use this function to temporarily execute SQL queries in another database, but you can only switch back manually. We strongly recommend that you replace this function with the database. table syntax in SQL queries.

    See mysql_connect () and mysql_query ().


    Note: This function is not recommended since PHP 4.0.6. Do not use this function. replace it with mysql_select_db () and mysql_query.



    ------ Solution --------------------
    In the SQL statement of mysql, the database name, table name, and field name do not use single quotation marks ('), but use reverse quotation marks ('), that is, "~". The one below.
    ------ Solution --------------------
    Syntax error! No database! How do you insert it?

    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.