PHP5 - if elseif not evaluating.....

liunx

Guest
I just installed a new Linux server with PHP and MySQL. I have a BIG problem that I am not quite sure how to fix. None of my if, elseif, or else statements are evaluating expressions. They worked on the previous servor using php 4.1.2, now none of them work on php5. Here is an example page.

<!-- m --><a class="postlink" href="http://www.humsci.auburn.edu/test/phptest.php">http://www.humsci.auburn.edu/test/phptest.php</a><!-- m -->

Here is the code for the page.
<!-- m --><a class="postlink" href="http://www.humsci.auburn.edu/test/phptest.pdf">http://www.humsci.auburn.edu/test/phptest.pdf</a><!-- m -->

Any help would be greatly appreciated.
ChrisWhere is $pagenum set? If you're expecting it to come from a form value or URL query string, then you should reference it as $_POST['pagenum'] or $_GET['pagenum'] as applicable, since you should not count on register_globals being activated (especially since it is not the default setting any more).

PS: copying your code into your post between [ php] and [/php ] tags (without the spaces I typed here), instead of an external link to a PDF file, will make life easier on those who want to view your code.Was register_globals set to on in PHP 4.1.2? Because this script works in the old server as is.
Is there a security risk in turning register_globals on? I control this server so if turning it on fixes the problem without major risk then I am all for it. This is just a test page to see where the problem is, but I have some huge pages that don't work right now also that I really don't want to recode.Starting with PHP 4.2.0, the default setting became "off". Here's the info from the security portion of the manual as to why that decision was made: <!-- m --><a class="postlink" href="http://us2.php.net/manual/en/security.globals.php">http://us2.php.net/manual/en/security.globals.php</a><!-- m -->

You could make a sort of quick-fix by explicitly setting the variables in question at the start of your script(s):

<?php
$pagenum = $_GET['pagenum']; // or $_POST['pagenum'] if it comes from a Post form

// ... rest of script ...
?>
 
Back
Top