Sunday, 15 January 2012

php - How do I extract a single column from another database? -



php - How do I extract a single column from another database? -

why status passes if alter $_get variable?

i've code

elseif(isset($_get['results']) && $_get['results'] == 'reorder' && isset($_get['sort_column']) && $_get['sort_column'] != '' && isset($_get['sort_order']) && $_get['sort_order'] != '' && $_get['sort_order'] == 'asc' || $_get['sort_order'] == 'desc') { /*rest goes here*/ } else {redirect}

link returns this

http://localhost/system/results.php?script_id=2&results=reorder&sort_column=supplier_address&sort_order=desc

but when alter sort_column=supplier_address illustration sorcodsalumn=supplier_address doesn't redirect, instead goes ahead, thought why? if remove few letters , dont replace else redirect...

how come if using isset($_get['sort_column'] , modifying sort_column else still passes condition

basic php operator precedence... && evaluates before ||, entire statement boils downwards to:

(x && y && z && ....) || ($_get['sort_order'] == 'desc')

you need simplify if(), add together () enforce own evaluation order, , things should start working bit better.

php

No comments:

Post a Comment