PHP Connection Database related issues

Source: Internet
Author: User
Tags database issues
PHP Connection Database Issues
Help me look, the database is not content, but I look at the feeling is right



<title>Untitled Document</title>




User Login







Include "comm.php";
?>


<title>Online Message-Message board</title>




if (isset ($_post[' username ')) {
$user = $_post[' username ');
$PW = MD5 ($_post[' PW1 ');

$conn = mysql_connect ("localhost", "root", "123456");
mysql_select_db ("Car");
$sql = "INSERT into Car_user (USER_NAME,PW) VALUES (' $user ', ' $PW ')";
mysql_query ("Set names ' gb2312 '");
mysql_query ($sql, $conn);
Mysql_close ($conn);
Get_show_msg ("left.html", "registered success");
}
?>






------Solution--------------------
mysql_query ($sql, $conn) or Die (Mysql_error ()); Do you have any error message?
------Solution--------------------
mysql_query ($sql, $conn) or Die (Mysql_error ());
------Solution--------------------
HTML code
 #js中pw1, pw2 undefined, return stopped, the following code does not execute if ( myform.pw1.value== "" | myform.pw2.value== "") {alert ("Password cannot be empty!"); return false;} #改为  
#后面添加
#导致php页面 $PW = MD5 ($_post[' PW1 ']); #没有值, don't believe you echo come out try instead: $conn = mysql_connect ("localhost", "root", "123456"); mysql_select_db ("Car"); $sql = "INSERT into Car_user (USER_NAME,PW) VALUES (' $user ', ' $PW ')"; mysql_query ("Set names ' gb2312 '"); $res = mysql_query ($sql, $conn); #如果sql未执行成功, print out the error if (! $res) die ("sql:{$sql}
Error:". Mysql_error ()); if (mysql_affected_rows () > 0) get_show_msg ("left.html", "registered successfully"); else echo "registration failed". Mysql_error (); Mysql_close ($conn);
  • 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.