forumnz Posted September 22, 2007 Share Posted September 22, 2007 It should display the members username based on their uid but it doesnt didplay anything like that. Help please? <?php //Start session session_start(); //Connect to mysql server $link=mysql_connect("localhost","###","###"); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db=mysql_select_db("bbmembers"); if(!$db) { die("Unable to select database"); } $userid = $_SESSION['SESS_MEMBER_ID']; $qry="SELECT * FROM members WHERE id='$userid'"; $result=mysql_query($qry); { echo $row['firstname']; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/70290-solved-display-from-db-firstname/ Share on other sites More sharing options...
pocobueno1388 Posted September 22, 2007 Share Posted September 22, 2007 You never defined $row. <?php //Start session session_start(); //Connect to mysql server $link=mysql_connect("localhost","###","###"); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db=mysql_select_db("bbmembers"); if(!$db) { die("Unable to select database"); } $userid = $_SESSION['SESS_MEMBER_ID']; $qry="SELECT * FROM members WHERE id='$userid'"; $result=mysql_query($qry); if (mysql_num_rows($result) > 0){ $row = mysql_fetch_assoc($result); echo $row['firstname']; } else { echo "No results found in the DB"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/70290-solved-display-from-db-firstname/#findComment-353072 Share on other sites More sharing options...
darkfreaks Posted September 22, 2007 Share Posted September 22, 2007 mhmm Quote Link to comment https://forums.phpfreaks.com/topic/70290-solved-display-from-db-firstname/#findComment-353074 Share on other sites More sharing options...
forumnz Posted September 22, 2007 Author Share Posted September 22, 2007 Thanks everyone! Quote Link to comment https://forums.phpfreaks.com/topic/70290-solved-display-from-db-firstname/#findComment-353075 Share on other sites More sharing options...
pocobueno1388 Posted September 22, 2007 Share Posted September 22, 2007 mhmm darkfreaks, instead of going from thread to thread posting unhelpful comments like this one just to raise your post count, you should try to actually help someone. When you do get the post count you desire, it won't mean a thing to yourself, or anyone else, it will only mean you did a good job spamming the boards. I wouldn't be saying anything if I haven't observed you doing this a lot ever since you joined the site. If you want respect, just be helpful to the people on this forum. Post count means nothing, in the end the content of your posts will always determine your knowledge. Quote Link to comment https://forums.phpfreaks.com/topic/70290-solved-display-from-db-firstname/#findComment-353081 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.