RE: [PHP] Variable Prob

2002-05-11 Thread Jason Soza

Thanks for the debugging tip... Seems that the 'else' statement wasn't being
called at all, so for some reason $last_name was evaluating to true even
though there's a NULL entry for that record/field. I used a different query,
where a person with a NULL last_name showed up first, and the 'else'
statement still wasn't being called but there was no $last_name showing.

Anyway, I added "ORDER BY last_name" to my mysql_query() statement and for
some reason the 'else' statements started working. Any ideas on why that
would be? I'm glad it works now, but I'm a little confused as to why it
works.

Thanks again.

-Original Message-
From: Miguel Cruz [mailto:[EMAIL PROTECTED]]
Sent: Saturday, May 11, 2002 11:06 PM
To: Jason Soza
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Variable Prob


It would seem the only way this could happen is if $last_name evaluates to
true. Two suggestions:

1) Make some extra change in one of the printf statements so you can see
which one is really being called.

2) If that doesn't illuminate anything, show a little more code.

miguel

On Sat, 11 May 2002, Jason Soza wrote:
> 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%s%s\n",$first_name,$last_name,$year,$color);
>   } else {
>   printf("%s's%s%s\n",$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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Variable Prob

2002-05-11 Thread Miguel Cruz

It would seem the only way this could happen is if $last_name evaluates to 
true. Two suggestions:

1) Make some extra change in one of the printf statements so you can see 
which one is really being called.

2) If that doesn't illuminate anything, show a little more code.

miguel

On Sat, 11 May 2002, Jason Soza wrote:
> 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%s%s\n",$first_name,$last_name,$year,$color);
>   } else {
>   printf("%s's%s%s\n",$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
> 
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php