jsciarrino Posted December 9, 2008 Share Posted December 9, 2008 A client moved his host acct. New host runs php 5.2.5, old host was 4.4.8. The following code worked on the old host but not on the new one. I'm a php novice, really trenched down and figured this out when I first worked with the client to get this working but am in a pinch here to get them back up asap. Trying to figure this out, hope someone could help. For all I know it could be a simple fix, hope so Thanks in advance for any help/explanation. I don't want to just have somebody debug for me, if somebody sees the problem and could take the time to explain I would appreciate that even more. <?php $page_title="attorney"; include('header.php'); ?> <? if ( $bio == "attorney 1 name" ) { $MyArray = array( "Attorney 1", "email: <a href=\"mailto:attorney1@attorney.com\">attorney1@attorney.com</a>","Attorney 1 description, hooray."); } else if ( $bio == "attorney 2 name" ) { $MyArray = array( "Attorney 2", "email: <a href=\"mailto:attorney2@attorney.com\">attorney2@attorney.com</a>","Attorney 2 description, hooray."); } ?> <h2 id="title"><?echo $MyArray[0]?></h2> <p class="cinfo"><?echo $MyArray[1]?></p> <p class="cinfo"> phone: 1234567<br> fax: 1234567 </p> <p><?echo $MyArray[2]?> </p> <? include("footer.php") ?> Quote Link to comment https://forums.phpfreaks.com/topic/136229-solved-php-working-in-448-but-not-525/ Share on other sites More sharing options...
darkfreaks Posted December 9, 2008 Share Posted December 9, 2008 is it throwing erros ??? <?php ini_set('error_reporting',E_ALL); ?> Quote Link to comment https://forums.phpfreaks.com/topic/136229-solved-php-working-in-448-but-not-525/#findComment-710633 Share on other sites More sharing options...
revraz Posted December 9, 2008 Share Posted December 9, 2008 Would help if you explained what doesn't actually work. One thing that happens on a update is the php.ini file is set to default. Are short tags enabled? If not, change your <? to <?PHP If this is all your code, where do you set your variables? $bio isn't defined. Quote Link to comment https://forums.phpfreaks.com/topic/136229-solved-php-working-in-448-but-not-525/#findComment-710636 Share on other sites More sharing options...
premiso Posted December 9, 2008 Share Posted December 9, 2008 Short tags could be disabled (if that is possible) <?php if ( $bio == "attorney 1 name" ) { $MyArray = array( "Attorney 1", "email: <a href=\"mailto:attorney1@attorney.com\">attorney1@attorney.com</a>","Attorney 1 description, hooray."); } else if ( $bio == "attorney 2 name" ) { $MyArray = array( "Attorney 2", "email: <a href=\"mailto:attorney2@attorney.com\">attorney2@attorney.com</a>","Attorney 2 description, hooray."); } ?> <h2 id="title"><?php echo $MyArray[0];?></h2> <p class="cinfo"><?php echo $MyArray[1];?></p> <p class="cinfo"> phone: 1234567<br> fax: 1234567 </p> <p><?php echo $MyArray[2];?> </p> <?php include("footer.php"); ?> Also where is BIO set? If it is from GET or POST you need to access with $_GET, $_POST. Since PHP 5 has register_globals turned off by default for security reasons. Edit: Fixed assuming $bio is coming from a form <?php $bio = isset($_REQUEST['bio'])?$_REQUEST['bio']:null; if ( $bio == "attorney 1 name" ) { $MyArray = array( "Attorney 1", "email: <a href=\"mailto:attorney1@attorney.com\">attorney1@attorney.com</a>","Attorney 1 description, hooray."); } else if ( $bio == "attorney 2 name" ) { $MyArray = array( "Attorney 2", "email: <a href=\"mailto:attorney2@attorney.com\">attorney2@attorney.com</a>","Attorney 2 description, hooray."); } ?> <h2 id="title"><?php echo $MyArray[0];?></h2> <p class="cinfo"><?php echo $MyArray[1];?></p> <p class="cinfo"> phone: 1234567<br> fax: 1234567 </p> <p><?php echo $MyArray[2];?> </p> <?php include("footer.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/136229-solved-php-working-in-448-but-not-525/#findComment-710637 Share on other sites More sharing options...
jsciarrino Posted December 9, 2008 Author Share Posted December 9, 2008 Not throwing any errors, just not displaying the arrays. Will do a quick check using that snippet to see if it returns anything. Quote Link to comment https://forums.phpfreaks.com/topic/136229-solved-php-working-in-448-but-not-525/#findComment-710639 Share on other sites More sharing options...
jsciarrino Posted December 9, 2008 Author Share Posted December 9, 2008 Would help if you explained what doesn't actually work. One thing that happens on a update is the php.ini file is set to default. Are short tags enabled? If not, change your <? to <?PHP If this is all your code, where do you set your variables? $bio isn't defined. What is not working is the part where the MyArrays should display, they display nothing. Bio is defined in the links to this page, ie, <a href=attorney_bio.php?bio=Attorney1> Quote Link to comment https://forums.phpfreaks.com/topic/136229-solved-php-working-in-448-but-not-525/#findComment-710642 Share on other sites More sharing options...
premiso Posted December 9, 2008 Share Posted December 9, 2008 Would help if you explained what doesn't actually work. One thing that happens on a update is the php.ini file is set to default. Are short tags enabled? If not, change your <? to <?PHP If this is all your code, where do you set your variables? $bio isn't defined. What is not working is the part where the MyArrays should display, they display nothing. Bio is defined in the links to this page, ie, <a href=attorney_bio.php?bio=Attorney1> So you need to access it with $_GET, since register_globals is off. Also check the if statement, it should be == "Attorney1" ?php $bio = isset($_GET['bio'])?$_GET['bio']:null; if ( $bio == "Attorney1" ) { $MyArray = array( "Attorney 1", "email: <a href=\"mailto:attorney1@attorney.com\">attorney1@attorney.com</a>","Attorney 1 description, hooray."); } else if ( $bio == "Attorney2" ) { $MyArray = array( "Attorney 2", "email: <a href=\"mailto:attorney2@attorney.com\">attorney2@attorney.com</a>","Attorney 2 description, hooray."); } ?> <h2 id="title"><?php echo $MyArray[0];?></h2> <p class="cinfo"><?php echo $MyArray[1];?></p> <p class="cinfo"> phone: 1234567<br> fax: 1234567 </p> <p><?php echo $MyArray[2];?> </p> <?php include("footer.php"); ?> Give that a try and see if it works. I would read up on register_globals so you can fix the rest of the code that assumes it is on. Quote Link to comment https://forums.phpfreaks.com/topic/136229-solved-php-working-in-448-but-not-525/#findComment-710644 Share on other sites More sharing options...
jsciarrino Posted December 9, 2008 Author Share Posted December 9, 2008 Would help if you explained what doesn't actually work. One thing that happens on a update is the php.ini file is set to default. Are short tags enabled? If not, change your <? to <?PHP If this is all your code, where do you set your variables? $bio isn't defined. What is not working is the part where the MyArrays should display, they display nothing. Bio is defined in the links to this page, ie, <a href=attorney_bio.php?bio=Attorney1> So you need to access it with $_GET, since register_globals is off. Also check the if statement, it should be == "Attorney1" ?php $bio = isset($_GET['bio'])?$_GET['bio']:null; if ( $bio == "Attorney1" ) { $MyArray = array( "Attorney 1", "email: <a href=\"mailto:attorney1@attorney.com\">attorney1@attorney.com</a>","Attorney 1 description, hooray."); } else if ( $bio == "Attorney2" ) { $MyArray = array( "Attorney 2", "email: <a href=\"mailto:attorney2@attorney.com\">attorney2@attorney.com</a>","Attorney 2 description, hooray."); } ?> <h2 id="title"><?php echo $MyArray[0];?></h2> <p class="cinfo"><?php echo $MyArray[1];?></p> <p class="cinfo"> phone: 1234567<br> fax: 1234567 </p> <p><?php echo $MyArray[2];?> </p> <?php include("footer.php"); ?> Give that a try and see if it works. I would read up on register_globals so you can fix the rest of the code that assumes it is on. This worked! Why would this have worked before without declaring $bio? Thank you so much to all for replying, and so quickly! I'll certainly be spending more time here in the future. There is another part not working right now but I'm going to give that a try before asking for more help. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/136229-solved-php-working-in-448-but-not-525/#findComment-710648 Share on other sites More sharing options...
revraz Posted December 9, 2008 Share Posted December 9, 2008 Because register globals was turned on in your old php.ini Quote Link to comment https://forums.phpfreaks.com/topic/136229-solved-php-working-in-448-but-not-525/#findComment-710652 Share on other sites More sharing options...
premiso Posted December 9, 2008 Share Posted December 9, 2008 This worked! Why would this have worked before without declaring $bio? Thank you so much to all for replying, and so quickly! I'll certainly be spending more time here in the future. There is another part not working right now but I'm going to give that a try before asking for more help. Thanks again. Umm did you read my reply? Register_globals is a security risk. In PHP5 it is defaulted to off. What register_globals would do is take global variables, such as $_GET and $_POST and convert the arrays to actual variables. So $_GET['bio'] was the same as $bio. But this could cause major issues. So because of that they decided to make the user define the variable to prevent a security breach, thus you now have to set variables, which is the way it should be or access them manually via the array of $_GET/$_POST. Read up on register_globals if you want more explanation, as I stated in the past 2 posts. Quote Link to comment https://forums.phpfreaks.com/topic/136229-solved-php-working-in-448-but-not-525/#findComment-710655 Share on other sites More sharing options...
jsciarrino Posted December 9, 2008 Author Share Posted December 9, 2008 Got it, thanks. The other problem I was having that I mentioned was along the exact same lines. I'm finished with this site now thanks to the help here and on to another project that I'm hoping to make all php with a mysql dbase. That should be a pretty good learning experience for me, will definitely be around here with some questions then. Thanks again guys (and gals?), you helped keep a few more dark hairs on my head Quote Link to comment https://forums.phpfreaks.com/topic/136229-solved-php-working-in-448-but-not-525/#findComment-710659 Share on other sites More sharing options...
revraz Posted December 9, 2008 Share Posted December 9, 2008 No problem, mark the topic solved. Quote Link to comment https://forums.phpfreaks.com/topic/136229-solved-php-working-in-448-but-not-525/#findComment-710663 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.