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
https://forums.phpfreaks.com/topic/70290-solved-display-from-db-firstname/
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";
}

?>

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.