Re: while - if problem

From: Date: Wed, 04 Jun 2003 20:22:38 +0000
Subject: Re: while - if problem
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-28314@lists.php.net to get a copy of this message
The closing else is not bracketed. Have you echoed the vars & confirmed values therein? It's amazing how often that will catch you. Otherwise simplicate: comment out a bunch of stuff and build it up bit by bit, echoing all the while. Miles Thompson At 02:07 PM 6/4/2003 -0600, Earl wrote:
Sorry about that I did not get the closing tag when i copied the code. I did as you said and it still gave the same problem. below is the complete code ------------------------------------------------ $eventQuery=ifx_query('select * from event'
      .' where e_date >= today '
      .' and e_status in ("O","C") '
       .' and out_id is not null '
      .' order by s_acro, e_acro ',$db) or die (ifx_error());
while($cols=ifx_fetch_row($eventQuery)) { if ($cols['out_type']=='0') {
    $r_away['linetype']='L';
    $r_home['linetype']='L';
} elseif ($cols['out_type']=='1') {
    $r_away['linetype']='H';
    $r_home['linetype']='H';
} if (($cols['s_acro']=='CF') || ($cols["s_acro"]=='PF')) {
    $r_away['sport']='1';
    $r_home['sport']='1';
    $s_lt='PS';
    $t_lt='TP';
} elseif (($cols['s_acro']=='PB') || ($cols['s_acro']=='CB')) {
    $r_away['sport']='2';
    $r_home['sport']='2';
    $s_lt='PS';
    $t_lt='TP';
} elseif ($cols['s_acro']=='B') {
    $r_away['sport']='3';
    $r_home['sport']='3';
    $s_lt='ML';
    $t_lt='TM';
} else
    $r_away['sport']='4';
    $r_home['sport']='4';
    $s_lt='ML';
    $t_lt='TM';
$r_away['rotation']=$cols['out_id']; $r_home['rotation']=($r_away['rotation'] + 1); echo "".$r_away['rotation']." , ".$r_home['rotation']." , ".$r_away['linetype']." , ".$r_home['linetype']." , ".$r_away['sport']." , ".$r_home['sport']."\n"; } ------------------------------------------------- ----- Original Message ----- From: "Becoming Digital" <subs@becomingdigital.com> To: "PHP-DB" <php-db@lists.php.net> Sent: Wednesday, June 04, 2003 1:52 PM Subject: Re: [PHP-DB] while - if problem You don't have a closing bracket on your while() loop and you should not have the else comments bracketed. Try this: while($cols=ifx_fetch_row($eventQuery)) { if (($cols['s_acro']=='CF') || ($cols["s_acro"]=='PF')) {
    $r_away['sport']='1';
    $r_home['sport']='1';
    $s_lt='PS';
    $t_lt='TP';
} elseif (($cols['s_acro']=='PB') || ($cols['s_acro']=='CB')) {
    $r_away['sport']='2';
    $r_home['sport']='2';
    $s_lt='PS';
    $t_lt='TP';
} elseif ($cols['s_acro']=='B') {
    $r_away['sport']='3';
    $r_home['sport']='3';
    $s_lt='ML';
    $t_lt='TM';
} else
    $r_away['sport']='4';
    $r_home['sport']='4';
    $s_lt='ML';
    $t_lt='TM';
} Edward Dudlik Becoming Digital www.becomingdigital.com ----- Original Message ----- From: "Earl" <earl@caribsports.com> To: "PHP-DB" <php-db@lists.php.net> Sent: Wednesday, 04 June, 2003 15:44 Subject: [PHP-DB] while - if problem Hey guys, I've got a problem with this piece of code.... it is skipping the contents of the if and elseif statements and only printing the else values, even though the if or one of the elseif statements might be true. what could possibly be the problem?? -------------------------------------------------------------------------- ------ ------------ $eventQuery=ifx_query('select * from eventtable'
      .' where e_date >= today '
      .' and e_status in ("O","C") '
       .' and out_id is not null '
      .' order by s_acro, e_acro ',$db) or die (ifx_error());
while($cols=ifx_fetch_row($eventQuery)) { if (($cols['s_acro']=='CF') || ($cols["s_acro"]=='PF')) {
    $r_away['sport']='1';
    $r_home['sport']='1';
    $s_lt='PS';
    $t_lt='TP';
} elseif (($cols['s_acro']=='PB') || ($cols['s_acro']=='CB')) {
    $r_away['sport']='2';
    $r_home['sport']='2';
    $s_lt='PS';
    $t_lt='TP';
} elseif ($cols['s_acro']=='B') {
    $r_away['sport']='3';
    $r_home['sport']='3';
    $s_lt='ML';
    $t_lt='TM';
} else {
    $r_away['sport']='4';
    $r_home['sport']='4';
    $s_lt='ML';
    $t_lt='TM';
} -------------------------------------------------------------------------- ------ ------------ output is always: 4, ML, TM thanks in advance -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.db (#28314) next »