Jump to content

[SOLVED] Display from db firstname


forumnz

Recommended Posts

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'];
}

?>

Link to comment
Share on other sites

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";
}

?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.