Variable Prob
| From: | Jason Soza | Date: | Sun, 12 May 2002 07:09:14 +0000 |
| Subject: | Variable Prob | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-97207@lists.php.net to get a copy of this message | ||
Argh!
I hate it when one little annoying thing starts up right when I think I have
the coding finished! I have the following code:
if($last_name) {
printf("%s
%s's<br><b>%s</b><br>%s\n</td>",$first_name,$last_name,$year,$color);
} else {
printf("%s's<br><b>%s</b><br>%s\n</td>",$first_name,$year,$color);
}
So if the person has a last name in the database, print "John Doe's 1990
Red" and if they don't, print "John's 1990 Red".
This is in a while() statement, and it works except that on one particular
query, the last record that comes up has a NULL value for the last name, but
rather than printing $first_name's it prints $first_name $last_name using
the last name of the previous record!
Am I missing something there? Do I need to clear out a variable somewhere?
It seems like since $last_name isn't even called in the else statement, it
shouldn't even be showing up!
Jason Soza