homepage Welcome to WebmasterWorld Guest from 54.237.213.31
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Displays username, but not maiden or last name.
Scotty13



 
Msg#: 4449383 posted 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

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



 
Msg#: 4449383 posted 1:40 pm on May 4, 2012 (gmt 0)

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



 
Msg#: 4449383 posted 2:18 pm on May 4, 2012 (gmt 0)

Didnt work! ;(

rocknbil

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



 
Msg#: 4449383 posted 3:58 pm on May 4, 2012 (gmt 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 . . . )

lucy24

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



 
Msg#: 4449383 posted 6:38 pm on May 4, 2012 (gmt 0)

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



 
Msg#: 4449383 posted 7:45 pm on May 4, 2012 (gmt 0)

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

lucy24

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



 
Msg#: 4449383 posted 2:29 am on May 5, 2012 (gmt 0)

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

cffrost2

5+ Year Member



 
Msg#: 4449383 posted 5:18 am on May 5, 2012 (gmt 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';

Scotty13



 
Msg#: 4449383 posted 7:00 am on May 5, 2012 (gmt 0)

//test code

Gives me this error...

username:Scotty lastname: maidenname is empty

cffrost2

5+ Year Member



 
Msg#: 4449383 posted 12:43 pm on May 5, 2012 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved