PHP Novice Simple message board related issues

Source: Internet
Author: User
PHP Novice Help Simple message board problem
This is the source code

<?php$con = mysql_connect ("localhost", "root", "" "), if (! $con)   {die   (' Could not connect: '. Mysql_error ());   } $db _selected = mysql_select_db ("test_db", $con), if (! $db _selected)   {die   ("can\ ' t use test_db:". Mysql_error ());   } $sql = "INSERT into ' test_db '. ' Form ' (' name ', ' Pass ') VALUES (\ ' fdgsdfg\ ', \ ' dsfgsdfg\ ');"; mysql_query ($sql, $con);? >

Seems to be able to connect to the database, but there's no way to update it.
Database very simple field type grooming properties null default extra action
field is two name and pass
I hope the master will come and see


------Solution--------------------
"INSERT into ' test_db '. ' Form ' (' name ', ' Pass ') VALUES (\ ' fdgsdfg\ ', \ ' dsfgsdfg\ ');"
First, because the string is within double quotation marks, it does not conflict with single quotation marks, so it is not allowed to escape
Next do not need to end with a semicolon. Because mysql_query () itself sends only one query statement to MySQL at a time.
The Modified code:

    • PHP Code
    • $sql = "INSERT into ' test_db '. ' Form ' (' name ', ' Pass ') VALUES (' Fdgsdfg ', ' DSFGSDFG ')"; mysql_query ($sql, $con) or exit (MYSQ L_error ()); That's the point, it's going to tell you why it went wrong
  • Related Article

    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.