willboudle Posted March 13, 2010 Share Posted March 13, 2010 I'm trying to update a site for a friend but it seems to be written in php4 and Im on a php5 server. there are several pages that insert information into the database (add days, add techs etc) that 'appear' to work. but the rows created in MySql are blank. I've tried researching the difference between php4 and php5, but am having a hard time understanding what I need to change on all these pages to make it work. I found a pehp4 to php5 converter but it's been discontinued and doesn't seem to even work on my windows 7. I'm wondering if anyone can help me understand what is causing this so I can update it across 20-30 different pages. Thanks include("../../dbinfo.inc.php"); if (isset($_POST['submit'])) { $query=mysql_query("INSERT into areas values('','$name')") or die("Cannot add record.<br>" . mysql_error()); $id = mysql_insert_id(); if ($query != '') { print $name.' was inserted into the areas table<br><br><a class="selects" href="edit_areas.php" onFocus="this.blur();">Add zipcodes to this area</a>'; } else { echo "We had a problem with that last technician add, please contact tech support"; } } else { and this one, because its empty, returns the 'We had a problem with that last calendar insert, please contact tech support' error. include("../../dbinfo.inc.php"); if(isset($_POST['submit'])) { $z=0; for($p=0;$p<count($area);$p++) { if(strcmp($area[$p], 'Choose') != 0 && !empty($quantity[$p]) ) { //print $area[$p].':'.$quantity[$p].'<br>'; $query=mysql_query("INSERT into calendar values('','$month','$day', '$year', '$quantity[$p]', '$area[$p]')") or die("Cannot add record.<br>" . mysql_error()); $id = mysql_insert_id(); $z++; } else $error = '<br><br>Please go back and select at least one <b><I>Area</I></b> and input the <b><I>quantity</I></b> for that area.<br><br>'; } if($z == 0) print $error; if ($query != '') print 'Successfully added the region to the calendar on '.$month.'/'.$day.'/'.$year; else print 'We had a problem with that last calendar insert, please contact tech support'; } else { Quote Link to comment https://forums.phpfreaks.com/topic/195121-php4-to-php5-issues/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 13, 2010 Share Posted March 13, 2010 There are very few incompatible differences going from php4 to php5 (there's a list in the php.net documentation.) Most php4 code will work under php5, given the same php.ini configuration. Most problems are due to code that is not using the current recommend php.ini settings, in some cases features that were turned off almost 8 years ago (and which will be removed in php6.) The code you posted appears to be dependent on register_globals to 'magically' populate program variables from external (and session data if you were using them) data. In your case, the $_POST data from a form. Don't turn on register_globals (even if the web host permits it.) Now is the time to get the code up to current standards so that it will work under current and future php versions. You should be debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON so that php will help you. You will get undefined errors for each variable that you need to set in your code. You are using $_POST['submit'] to detect if the form has been submitted. You need to use $_POST variables for all the other form fields. Quote Link to comment https://forums.phpfreaks.com/topic/195121-php4-to-php5-issues/#findComment-1025626 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.