Current location: Hot Scripts Forums » Programming Languages » PHP » help with displaying variables


help with displaying variables

Reply
  #1 (permalink)  
Old 12-20-03, 09:11 PM
tisza tisza is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
help with displaying variables

ok, i am having trouble displaying variables form a databse, i downlaoded a login script from http://www.hotscripts.com/Detailed/26782.html, the login and stuff works fine, it stores the variables in the database, the only thing is i cant figure out how to display them, when you login in i want it to display all your info, i changed it so when u log in it redirects you to a page, i just dont know what to put on the page so it displays them, i have included the connect.php which ocnnects to the database, i just dont know how to display the variables once you log in, thanx

(if you need any mroe info like sources just post)
Reply With Quote
  #2 (permalink)  
Old 12-21-03, 01:31 AM
Beaver Beaver is offline
Newbie Coder
 
Join Date: Dec 2003
Location: Anaheim CA
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Check out the mysql_query, and mysql_fetch_row functions to grab the info you want. I'd recommend you check out the online php docs, and some tutorials, which can be searched for via google.
Reply With Quote
  #3 (permalink)  
Old 12-21-03, 09:23 AM
tisza tisza is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
can you kind of give me a breif run through, most tutorials are over my head
Reply With Quote
  #4 (permalink)  
Old 12-22-03, 01:19 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
just provide us with table structure and we will handle it
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #5 (permalink)  
Old 12-22-03, 01:11 PM
NerdRUS NerdRUS is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
you could have something like this where the valid_user is the variable you carry throughout the site

$display = mysql_query("select * from members where email = '$valid_user'");
$row = mysql_fetch_array($display);


Username:&nbsp;<?php echo stripslashes($row['username']); ?></br>
E-mail:<br/><?php echo stripslashes($row['email']); ?>
Reply With Quote
  #6 (permalink)  
Old 12-22-03, 01:56 PM
tisza tisza is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by NeverMind
just provide us with table structure and we will handle it
the table that i am using?

ok well its called users and it has:

Field-----------Type--------Null-----------Extra Action
user_id---------int(11)-------No---------auto_increment
username----varchar(20)-----No
password----varchar(10)------No
email--------varchar(30)-------No

all i want to know is how to display those after you log in, like once you log in it directs you to a page, i changed it so it directs you to info.php, what do i need to put on info so that it shows you your info
Reply With Quote
  #7 (permalink)  
Old 12-22-03, 04:46 PM
tisza tisza is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by NerdRUS
you could have something like this where the valid_user is the variable you carry throughout the site

$display = mysql_query("select * from members where email = '$valid_user'");
$row = mysql_fetch_array($display);


Username:&nbsp;<?php echo stripslashes($row['username']); ?></br>
E-mail:<br/><?php echo stripslashes($row['email']); ?>

and when i do this all it displays is:

Username:
E-mail:

and nothing else
Reply With Quote
  #8 (permalink)  
Old 12-22-03, 04:56 PM
blaw's Avatar
blaw blaw is offline
Junior Code Guru
 
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
Hi there,

Quick check - Does your variable $valid_user contain email or username? And are you sure there is such an email (or username) stored in the database?
__________________
Blavv =|
Reply With Quote
  #9 (permalink)  
Old 12-22-03, 05:00 PM
tisza tisza is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
i am pretty sure its email, isnt that what it is in nerdrus's code

and its in the database, i know for a fact
Reply With Quote
  #10 (permalink)  
Old 12-22-03, 05:08 PM
blaw's Avatar
blaw blaw is offline
Junior Code Guru
 
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
Hi again,

Quote:
Originally Posted by tisza
i am pretty sure its email, isnt that what it is in nerdrus's code
No. Look carefully - there is no part where he assigns a value to this variable, so it could contain anything. If you just copied & pasted this code, it will always give you an empty set because $valid_user will contain "" (empty string), and you are trying to match the email field to this value, but your email field does not contain an empty string.

Assign whatever the value (i.e. valid user's email) you carry throughout the site into this $valid_user, and you should be getting what you want. As to how, I can't tell you as of because I don't know what your site dynamics is.

Just to note, I'm going out for lunch now and will perhaps be back in 2 hours or so. Good luck.
__________________
Blavv =|
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
formmail problem gscraper Perl 12 08-27-04 03:06 AM
Storing and accessing variables from a session Obakeng Everything Java 0 12-08-03 07:52 AM
Creating String For Paypal Cart, Many variables to one submit Jazzed JavaScript 0 11-19-03 12:23 PM
Creating String For Paypal Cart, Many variables to one submit Jazzed HTML/XHTML/XML 1 11-17-03 07:12 PM
adding more variables to the mail() result spinicrus PHP 6 08-28-03 04:55 PM


All times are GMT -5. The time now is 07:39 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.