Data cannot be written to the database solution ideas

Source: Internet
Author: User
Data cannot be written to the database
Session_Start ();
[Email Protected]_connect ("localhost", "root", "ch12345") or Die ("Database link error");
mysql_select_db ("Literature", $coon);
mysql_query ("Set names ' UTF-8 '");
@ $username =$_post[' username ');
@ $password =$_post[' password ');
@ $email =$_post[' email '];
@ $sex =$_post[' sex '];
@ $constallation =$_post[' constallation ');
$time =time ();
$STR = "SELECT * from user where username={$username}";
$result 1= $coon->query ($STR); This line is wrong, how should it be changed?
$row = $result 1->fetch_row ();
if ($row)
{
$temp = "Someone has registered this name, please re-select the name!";
Echo $temp;
echo "Back";
}
else {
$sql = "INSERT into user (Username,sex,time,constallation,password,email)".
"VALUES (' $username ', ' $sex ', now (), ' $constallation ', ' $password ', ' $email ')";
$sql = "INSERT into user VALUES ($username, $sex, $time, $constallation, $password, $email)";
$result = $coon->query ($sql);
if ($result ==true)
{
$_session[' mail ']= "Registration is successful, please login";
echo "";
}
else {echo "registration failed". Mysql_error ();}
}
?>

------Solution--------------------
discuss
$result 1= $coon->query ($STR); This line is wrong, how should it be changed?
$row = $result 1->fetch_row ();

------Solution--------------------
[Email Protected]_connect ("localhost", "root", "ch12345") or Die ("Database link error");
$coon->query ($STR);
I haven't seen it like this before! Take a closer look at the manual first http://www.php.net/manual/zh/book.mysql.php
------Solution--------------------
discuss

[Email Protected]_connect ("localhost", "root", "ch12345") or Die ("Database link error");
$coon->query ($STR);
I haven't seen it like this before! Take a closer look at the manual first http://www.php.net/manual/zh/book.mysql.php
  • 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.