I'm sure I'm missing something really simple, but the code below causes an error: $cntry_lvl = $row["co_level"]; if $v_uid == 'ZUXW-FYJS-XJBW-TEQR' { switch ($cntry_lvl) { case 1: $minadrate = .02; break; case 2: $minadrate = .015; break; case 3: $minadrate = .01; break; default: $minadrate = .004; } } Code (markup): Any idea why? Thanks, James
off the top of my head I'd be concerned that $cntry_lvl isn't an integer and so the "match" isn't working right. What line do you get the error with and what does the error say? $cntry_lvl = $row['co_level']; if $v_uid == 'ZUXW-FYJS-XJBW-TEQR' { switch ($cntry_lvl) { case '1': $minadrate = .02; break; case '2': $minadrate = .015; break; case '3': $minadrate = .01; break; default: $minadrate = .004; } } PHP:
Thanks Sarah! After a change to: $ctlvl = (integer) $cntry_lvl; if $v_uid == 'ZUXW-FYJS-XJBW-TEQR' { switch ($ctlvl) { ...all works great. Much appreciated, James
Also you might want to add parenthesis around your if statement, to convert a string to integer use the (int) typecast or the intval() function.