Php cannot read user information in the database to solve the problem.

Source: Internet
Author: User
Php cannot read user information in the database to solve the problem.



Personal Center



Session_start ();
If (! Isset ($ _ SESSION ['uid']) {
Header ("Location: login.html ");
Exit ();
}
Include ('Conn. php ');
$ Userid = $ _ SESSION ['uid'];
$ Username = $ _ SESSION ['username'];
$ User_query = mysql_query ("select * from zhuce where Uid = $ userid limit 1 ");
$ Row = mysql_fetch_row ($ user_query );
Echo 'user information:
';
Echo 'user ID: ', $ userid ,'
';
Echo 'user name: ', $ username ,'
';
Echo 'email: ', $ row ['mail'],'
';
Echo 'date of birth: ', $ row ['birthday'],'
';
Echo 'Landline: ', $ row ['phone'],'
';
Echo 'Cell Phone: ', $ row ['mobile _ telephone'],'
';
Echo 'registration Date: ', $ row ['Date'],'
';
Echo 'logout
';
?>




Reply to discussion (solution)

$ Row = mysql_fetch_row ($ user_query );
The result is a subscript array.
You can associate an array, for example, $ row ['mail']. Naturally, no data is available.
$ Row [0], $ row [1]...

This way
$ Row = mysql_fetch_assoc ($ user_query );
Only
$ Row ['mail'], $ row ['phone']...

Okay.
While ($ info = mysql_fetch_array ($ result ))
Echo $ info [name];
In this way, I cannot read your data from the row by row.

Okay.
While ($ info = mysql_fetch_array ($ result ))
Echo $ info [name];
In this way, I cannot read your data from the row by row.
Read the first piece of data in the query without writing the traversal, and only one piece of data is read.

Positive solution on the first floor.

The boss has already replied to you. the array returned by mysql_fetch_row is an index array. you cannot obtain the value in the form of an associated array.
Or you can $ row = mysql_fetch_assoc ~ Try again ~

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.