Displaying a Member Name from a Database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
perryp5
Forum Newbie
Posts: 4
Joined: Sat May 15, 2004 4:14 pm

Displaying a Member Name from a Database

Post by perryp5 »

:twisted:
Ok I have been trying to do this for a week and now I am asking for help.
I have a membership login system running. What i want to do is display 'Welcome (membername) ! if they are logged in. I have a simple script that i have gotten to display:

Welcome Resource Id#4 !

Why won't it display the name instead??

Here is the code:

Code: Select all

<?
session_start();
?>
<?php
include ("db.php");
?>
<?php

$sql_member = mysql_query("SELECT us_name FROM twb_users WHERE us_id = '". $u_id ."'") or die (mysql_error());

echo "Welcome $sql_member !"; 
?>

Could someone please help me??
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

list($name) = mysql_fetch_row($sql_member);
echo "Welcome $name!";
perryp5
Forum Newbie
Posts: 4
Joined: Sat May 15, 2004 4:14 pm

Geeze

Post by perryp5 »

:roll:
OK Feyd You truely are my master. It's like that HUH?

THAT %^&*%## easy??

thanks man

Perry
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Code: Select all

<?php
$member = mysql_result($sql_member);
echo "Welcome, " . $member;
?>
Works also.

And like I said in your other post, theres no need to go in and out of PHP if you're not printing large amounts of HTML.
Post Reply