Welcome to WebmasterWorld Guest from 23.22.140.143

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Displays username, but not maiden or last name.

     
1:26 pm on May 4, 2012 (gmt 0)

Junior Member

joined:Feb 23, 2012
posts: 91
votes: 0


/////// Mechanism to Display Real Name Next to Username - real name(username) //////////////////////////

if ($firstname != "") {
$mainNameLine = "$firstname $maidenname $lastname ($username)";
$username = $firstname;
} else {
$mainNameLine = $username; $maidenname; $lastname;
}

I want to display maiden and last name along with the user name. I've tried everything I could think of. Any suggestions?

Thanks,
Scott
1:40 pm on May 4, 2012 (gmt 0)

Administrator from US 

WebmasterWorld Administrator incredibill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 25, 2005
posts:14624
votes: 88


Have you tried echoing $maidenname and $lastname just to make sure they have a value to start with?

This line:
$mainNameLine = $username; $maidenname; $lastname;

Should be:
$mainNameLine = "$username $maidenname $lastname";
2:18 pm on May 4, 2012 (gmt 0)

Junior Member

joined:Feb 23, 2012
posts: 91
votes: 0


Didnt work! ;(
3:58 pm on May 4, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 0


When you have problems like this, you need to learn to trace back from the endpoint and find the point of failure.

echo $maidenname; // No output, go back one step

while ($row=mysql_fetch_array($result)) {
$row[1]=$firstname;
$row[2]=$lastname;
$row[3]=$maidenname;
echo "Maiden " . $row[3] . '<br>';
}

In this example, if that last one is STILL blank, there's nothing in that field or you're setting the wrong value in the row index (e.g., maidenname might not be $row[3], it's $row[4] or something . . . )
6:38 pm on May 4, 2012 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

joined:Apr 9, 2011
posts:12708
votes: 244


Tangential but I gotta ask: Who is your audience? What happens if the user's last name is their maiden name, and possibly also their mother's maiden name?

$mainNameLine = "$firstname $maidenname $lastname ($username)";
$username = $firstname;


What's the value of $username before it gets redefined?
7:45 pm on May 4, 2012 (gmt 0)

Junior Member

joined:Feb 23, 2012
posts: 91
votes: 0


@lucy24 - thanks, but that placed () on each side of the username.
2:29 am on May 5, 2012 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

joined:Apr 9, 2011
posts:12708
votes: 244


Heh. I just copied a segment of your code as background to the question :) The parentheses were already there.
5:18 am on May 5, 2012 (gmt 0)

Junior Member

5+ Year Member

joined:June 6, 2006
posts:97
votes: 0


Scott, where are your variables being set? and are you sure the db values are not empty/null?
if ($firstname != "") {
$mainNameLine = "$firstname $maidenname $lastname ($username)";
$username = $firstname;
} else {
$mainNameLine = $username; $maidenname; $lastname;
}

I always echo inline vars like this (be it the "right way" or "another way", it's my way ;)

$mainNameLine = $username.' '.$maidenname.' '.$lastname;


Try commenting out each var and echo each var at a time and see which ones work and which don't. Maybe even use some isset catching to see which ones are empty. Like so.

//test code
if(isset($username))
echo ' username:'.$username;
else
echo ' username is empty';
if(isset($firstname))
echo ' firstname:'.$firstname;
else
echo ' Firstname is empty';
if(isset($maidenname))
echo ' maidenname:'.$maidenname;
else
echo ' maidenname is empty';
7:00 am on May 5, 2012 (gmt 0)

Junior Member

joined:Feb 23, 2012
posts: 91
votes: 0


//test code

Gives me this error...

username:Scotty lastname: maidenname is empty
12:43 pm on May 5, 2012 (gmt 0)

Junior Member

5+ Year Member

joined:June 6, 2006
posts:97
votes: 0


You used this
//test code
if(isset($username))
echo ' username:'.$username;
else
echo ' username is empty';
if(isset($firstname))
echo ' firstname:'.$firstname;
else
echo ' Firstname is empty';
if(isset($maidenname))
echo ' maidenname:'.$maidenname;
else
echo ' maidenname is empty';

and got this
username:Scotty lastname: maidenname is empty

?
or did you change one to test the lastname? If so, you can see you firstnam var is not empty. Your lastname var is not empty but has no real value (possibly a space?). And maidenname has no value. Either pulled wrong from the db or there isn't anything there to get.

Your next step should be to check your db values and see if they exist. Then check your SQL query statement and make sure it's right.