Welcome to WebmasterWorld Guest from 54.227.5.198

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Displays username, but not maiden or last name.

     

Scotty13

1:26 pm on May 4, 2012 (gmt 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

incrediBILL

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

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



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

Scotty13

2:18 pm on May 4, 2012 (gmt 0)



Didnt work! ;(

rocknbil

3:58 pm on May 4, 2012 (gmt 0)

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



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 . . . )

lucy24

6:38 pm on May 4, 2012 (gmt 0)

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



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?

Scotty13

7:45 pm on May 4, 2012 (gmt 0)



@lucy24 - thanks, but that placed () on each side of the username.

lucy24

2:29 am on May 5, 2012 (gmt 0)

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



Heh. I just copied a segment of your code as background to the question :) The parentheses were already there.

cffrost2

5:18 am on May 5, 2012 (gmt 0)

5+ Year Member



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

Scotty13

7:00 am on May 5, 2012 (gmt 0)



//test code

Gives me this error...

username:Scotty lastname: maidenname is empty

cffrost2

12:43 pm on May 5, 2012 (gmt 0)

5+ Year Member



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.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month