How to query and modify the information after entering the user name and password

Source: Internet
Author: User
After entering the user name and password, you can query the information and modify the information. this is my code and the running result. How to display the database information and modify a certain item.
 Student Information
  
 Complete the Information

"; Echo" "; Exit;} else {$ query =" select * from $ student_table where xuehao = '$ xuehao' "; mysql_query (" set names 'gb2312 '"); $ result = mysql_query ($ query); $ row = mysql_fetch_array ($ result); if ($ row = 0) {echo"

You have not registered. please register first.

"; Echo" "; Exit;} $ query =" select password as sm from $ student_table where xuehao = '$ xuehao' "; mysql_query (" set names 'gb2312 '"); $ result = mysql_query ($ query); $ row = mysql_fetch_array ($ result); $ num = strlen ($ row ['xuehao']); $ xh = $ row ['xuehao']; $ n = 0; if ($ row [sm]! = $ Password) {echo"

The student ID and password you entered do not match. please enter them again.

"; Echo" "; Exit ;}}?>


Reply to discussion (solution)


$ Query = "select password as sm from $ student_table where xuehao = '$ xuehao '";
Mysql_query ("set names 'gb2312 '");
$ Result = mysql_query ($ query );
$ Row = mysql_fetch_array ($ result );
This section will overwrite the previous $ row, and you only have sm columns in the SQL list. Therefore, the following two rows will report an error.
$ Num = strlen ($ row ['xuehao']);
$ Xh = $ row ['xuehao']; // no xuehao column

The following control assignment also reports an error.

The solution is to change the second $ row to $ row1.

This is similar to a logon interface.

Thank you. the problem is fixed. The information is displayed normally. But what is the unnecessary error above?

$ Query = "select password as sm from $ student_table where xuehao = '$ xuehao '";
Mysql_query ("set names 'gb2312 '");
$ Result = mysql_query ($ query );
$ Row = mysql_fetch_array ($ result );
This section will overwrite the previous $ row, and you only have sm columns in the SQL list. Therefore, the following two rows will report an error.
$ Num = strlen ($ row ['xuehao']);
$ Xh = $ row ['xuehao']; // no xuehao column

The following control assignment also reports an error.

The solution is to change the second $ row to $ row1. thank you! After the problem is solved, it can be displayed normally, but what does the above error prompt mean?

$ Row [sm]
Change
$ Row ['SM ']

Sm is parsed as a constant without quotation marks.

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.