I cannot find the problem.-php Tutorial

Source: Internet
Author: User
I cannot find out the problem. $ SQL _insert = "insert into tb_user (usernc, turename, pwd, email, sex, tel, qq, address, logintimes, regtime, lastlogintime, ip, yb, usertype, question, answer, truepwd, photo, score) values ('$ _ POST [usernc]', '$ _ POST [truename]', '". md5 ($ psw ). "',' $ _ POST [email] ',' $ _ POST [select] ',' $ _ POST [tel] ',' $ _ POST [qq] ', '$ _ POST [address]', '0 ','". date ('Y-m-d H: I: s '). "','". date ('Y-m-d H: I: s '). "','". $ _ SERVER ['remote _ ADDR ']. "',' $ _ POST [yb] ', '0',' $ _ POST [question] ',' $ _ POST [answer] ', '$ _ POST [truepwd]', '$ _ POST [photo];', '30 ')";
$ Res_insert = mysql_query ($ SQL _insert );
// $ Num_insert = mysql_num_rows ($ res_insert );
If ($ res_insert)
{
Echo "script" alert ('registration successful! '); History. go (-1); script ";
}
Else
{
Echo "script alert ('the system is busy, please wait !!! '); History. go (-1); script ";
}


Reply to discussion (solution)

After the information is filled out, registration can only jump to the system busy. I think there is a problem with my SQL statement but it cannot be found.

{
Echo "script alert ('the system is busy, please wait !!! '); History. go (-1); script ";
}
Change
{
$ Msg = mysql_error ();
Echo "script" alert ('$ msg'); history. go (-1); script ";
}
See what is in the pop-up box

Blank

$ SQL _insert = "insert into tb_user (usernc, turename, pwd, email, sex, tel, qq, address, logintimes, regtime, lastlogintime, ip, yb, usertype, question, answer, truepwd, photo, score) values ('$ _ POST [usernc]', '$ _ POST [truename]', '". md5 ($ psw ). "',' $ _ POST [email] ',' $ _ POST [select] ',' $ _ POST [tel] ',' $ _ POST [qq] ', '$ _ POST [address]', '0 ','". date ('Y-m-d H: I: s '). "','". date ('Y-m-d H: I: s '). "','". $ _ SERVER ['remote _ ADDR ']. "',' $ _ POST [yb] ', '0',' $ _ POST [question] ',' $ _ POST [answer] ', '$ _ POST [truepwd]', '$ _ POST [photo];', '30 ')";
In red ???

No.

If the SQL command is incorrect, mysql will prompt you
What can I do if you don't know?

$ Msg = mysql_error ();
Echo "script" alert ('$ msg'); history. go (-1); script ";
The information cannot be displayed after this game is added.

If it is displayed as blank, it indicates that your program has a syntax error and the error display function is not enabled.
You only gave the program fragment and you cannot judge the problem.

Require_once 'Conn. php ';
If (isset ($ _ POST ["submit"]) & $ _ POST ["submit"] = "register ")
{

$ User = $ _ POST ["usernc"];
$ Trueuser = $ _ POST ["truename"];
$ Psw = $ _ POST ["pwd"];
$ Psw_truepwd =$ _ POST ["truepwd"];
$ Email = $ _ POST ["email"];
$ Sex = $ _ POST ["select"];
$ Tel = $ _ POST ["tel"];
$ Qq =$ _ POST ["qq"];
$ Address = $ _ POST ["address"];
$ Yb = $ _ POST ["yb"];
$ Question = $ _ POST ["question"];
$ Answer = $ _ POST ["answer"];
$ Photo = $ _ POST ["photo"];
If ($ user = "" | $ trueuser = "" | $ psw = "" | $ psw_truepwd = "" | $ email = "" | $ sex = "" | $ tel = "" | $ qq = "" | $ address = "" | $ yb = "" | $ question = "" | $ photo = "" | $ answer = "")
{
Echo "script" alert ('check the information integrity! '); History. go (-1); script ";
}
Else
{
If ($ psw = $ psw_truepwd)
{
$ SQL = "select usernc from tb_user where usernc = '$ _ POST [usernc]'"; // SQL statement
$ Result = mysql_query ($ SQL); // execute an SQL statement
$ Num = mysql_num_rows ($ result); // count the number of rows affected by execution results
If ($ num) // if the user already exists
{
Echo "script" alert ('user name already exists '); history. go (-1); script ";
}
Else // the name of the currently registered user does not exist
{

$ SQL _insert = "insert into tb_user (usernc, turename, pwd, email, sex, tel, qq, address, logintimes, regtime, lastlogintime, ip, yb, usertype, question, answer, truepwd, photo, score) values ('$ _ POST [usernc]', '$ _ POST [truename]', '". md5 ($ psw ). "',' $ _ POST [email] ',' $ _ POST [select] ',' $ _ POST [tel] ',' $ _ POST [qq] ', '$ _ POST [address]', '0 ','". date ('Y-m-d H: I: s '). "','". date ('Y-m-d H: I: s '). "','". $ _ SERVER ['remote _ ADDR ']. "',' $ _ POST [yb] ', '0',' $ _ POST [question] ',' $ _ POST [answer] ', '$ _ POST [truepwd]', '$ _ POST [photo]', '30 ')";
$ Res_insert = mysql_query ($ SQL _insert );
// $ Num_insert = mysql_num_rows ($ res_insert );
If ($ res_insert)
{
Echo "script" alert ('registration successful! '); History. go (-1); script ";
}
Else
{

$ Msg = mysql_error ();
Echo "script" alert ('$ msg'); history. go (-1); script ";
// Echo "script" alert ('the system is busy. please wait! '); History. go (-1); script ";
}
}
}
Else
{
Echo "script" alert ('inconsistent passwords! '); History. go (-1); script ";
}
}
}
Else
{
Echo "script alert ('submission failed! '); History. go (-1); script ";
}
?>
This is a problem when all the code is actually capable of redirection.

Put $ res_insert = mysql_query ($ SQL _insert );
Change to $ res_insert = mysql_query ($ SQL _insert) or die (mysql_error ());

Unknown column 'turename' in 'Field list'

Okay, I typed it wrong.

Ah, it's so sloppy, but I learned how to find the SQL problem. thank you!

The turename column does not exist.

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.