homepage Welcome to WebmasterWorld Guest from 54.243.23.129
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe and Support WebmasterWorld
Visit PubCon.com
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:4449385
 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




msg:4449389
 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:4449401
 2:18 pm on May 4, 2012 (gmt 0)

Didnt work! ;(

rocknbil




msg:4449468
 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




msg:4449570
 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:4449596
 7:45 pm on May 4, 2012 (gmt 0)

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

lucy24




msg:4449717
 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




msg:4449754
 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:4449765
 7:00 am on May 5, 2012 (gmt 0)

//test code

Gives me this error...

username:Scotty lastname: maidenname is empty

cffrost2




msg:4449822
 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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved