Peanut Posted February 20, 2008 Share Posted February 20, 2008 I have the following script, howeber when moving server recently it no longer works, I am a basic programmer so I am assuming this is because of a change from php4 to php5 on the new server Below is the code if anyone could help me by telling me or showing me what is wrong with this for php 5 I would be for ever in your debt <?php //Config section\\ $search_for = 'Yes'; //search phrase $search_field = 'NewHomePage'; //field to search in $filepath = '/home/pat95/public_html/inventory/'; //flat file path, with traling slash $filename = 'data.log'; //flat file name $divider = '::'; //fields divider $cols = 5; //columns number per page $rows = 1; //rows number per page //fields to get from flat file, pay attenton to their order! $fields = Array ( 'id', 'Ref', 'Ownercontactinfo', 'Commissionrateprice', 'KeysWherearetheykeys', 'ownersphoneemail', 'SalePrice', 'MonthlyRental', 'LandSize', 'LivingArea', 'Bedrooms', 'Bathrooms', 'Location', 'LongDescription', 'Category', 'Storeyfloors', 'SituatedonFloor', 'Type', 'Image1Thumbnail', 'Image1Large', 'Image1medium', 'Image2Thumbnail', 'Image2Large', 'Image3Thumbnail', 'Image3Large', 'Image4Thumbnail', 'Image4Large', 'Image5Thumbnail', 'Image5Large', 'Image6thumbnail', 'Image6Large', 'NewHomePage', 'QuickHomePage', 'Swimming Pool', 'Views', 'Garden', 'Car Parking', 'Furnished', 'EnSuite', 'AirConditioning', 'Kitchen', 'Laundryroom', 'Maidsroom', 'Storageroom', 'ReserveWaterTank', 'Sauna', 'TerraceBalcony', 'DirectTelephone', 'ADSLInternet', 'TVservice', 'SecuritySystem', 'Jacuzzi', 'TennisCourts', 'Restaurant', 'Shop', '24HourSecurity', 'Live', 'Sold', 'Ownership', ); /* TEMPLATE HERE*/ //prints result template, use $variable as data filed, mentioned in $fields array //replace code in print clause, better use DIV tags to enclose result template //don't forget to write \" if you want to see a qoute in your html output function print_result($arr){ extract($arr); print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" id=\"table1\"> <!--DWLayoutTable--> <tr> <td valign=\"top\" bgcolor=\"#FFFFE1\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" id=\"table2\"> <tr> <td width=\"163\" height=\"110\" align=\"center\" valign=\"middle\"> <a href='http://www.xxx.org/cgi-bin/inv.pl?fid=$id&cgifunction=form'><img border=\"0\" src=\"$Image1Thumbnail\" width=130 height=100></a></td> </tr> <tr> <td height=\"15\" valign=\"top\"><div align=\"center\"> <font face=\"Verdana\" size=\"2\"> $SalePrice $MonthlyRental Baht</font></div></td> </tr> <tr> <td height=\"18\" valign=\"top\"><div align=\"center\"><font face=\"Verdana\" size=\"2\"> $Bedrooms <br>$Bathrooms</font></div></td> </tr> </table></td> </tr> <tr> <td height=\"8\" bgcolor=\"#FFFFE1\"></td> </tr> </table>"; }; //End of Config section\\ // -- internal variables -- error_reporting(E_NONE); //security reason, change to E_ALL to debug script $qty = 0; //how many results found $founded = array(); //selected lines $raw = array(); //global array containing flat file splitted //Begin main script $raw = make_array(); //get all records $founded = search_array($raw); //get array with selected items $qty = count($founded); //how many results we have if ($qty<1) {die("No results found");}; unset($raw); //del initial array $showperpage=$cols*$rows; $countedpages=ceil($qty/$showperpage); // number of pages $currentpage=0; if (isset($HTTP_GET_VARS['page'])) { $currentpage=(int)$HTTP_GET_VARS['page']; } if ($currentpage>$countedpages) { $currentpage=$countedpages; } if ($currentpage<1) { $currentpage=1; } $start_pos=($currentpage-1)*$showperpage; //1st record number $end_pos=$start_pos+$showperpage-1; //last record number if ($end_pos>$qty) { $end_pos=$qty-1; } // echo "<center>" . $qty . " items. Page " . $currentpage . " from " . $countedpages . "<center>"; // print_nav(); build_table($rows,$cols,$start_pos,$end_pos); // print_nav(); //Functions here //buil invisible table and show results function build_table($rows,$cols,$start_pos,$end_pos){ global $founded; $curr = $start_pos; //echo $start_pos," - ",$end_pos; print " <table border=0 cellSpacing=0 cellPadding=0>"; for ($i=1;$i<=$rows;$i++) { if ($curr>$end_pos){break;}; print "<tr>\n"; for ($j=1;$j<=$cols;$j++) { print "<td>\n"; if ($curr<=$end_pos) { print_result($founded[$curr]); //show result }; $curr++; print "</td>\n"; }; print "</tr>\n"; }; print " </table> "; }; //navigation links build function print_nav(){ global $countedpages,$currentpage; print "<CENTER><br> <table> <tr> <td><font face=\"verdana\" size=\"1\" color=\"#000000\">go to page >> "; for ($i = 1; $i <= $countedpages; $i++) { if ($currentpage!=$i) { echo "<a class=\"cgilink\" href=\"".$_SERVER['PHP_SELF']."?page=".$i."\">".$i."</a>"; } else { echo $i; } echo " "; }; print "</font> </td> </tr> </table> </CENTER><br>\n"; }; //searches for the value in a field function search_array($input){ global $search_for, $search_field; $num=0; foreach($input as $val) { if ($val[$search_field]==$search_for) {$res[]=$val;}; }; return $res; }; //makes an array from flat file function make_array(){ global $filepath,$filename; $flat = file($filepath . $filename); foreach($flat as $line) { $all[] = divide($line); }; return $all; }; //splits line into $vars function divide($input){ global $divider,$fields; $tmp = split($divider,$input); foreach($fields as $key=>$fl) { ${$fl} = $tmp[$key]; }; return compact($fields); }; ?> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 20, 2008 Share Posted February 20, 2008 The only thing that stands out is $HTTP_GET_VARS are depreciated, turned off by default in php5, and eliminated in php6. Change all occurrences of $HTTP_GET_VARS to $_GET The above problem and perhaps other reasons why it is not working would be exposed if you turn on full php error reporting. Quote Link to comment Share on other sites More sharing options...
Peanut Posted February 20, 2008 Author Share Posted February 20, 2008 Thanks With error reporting on I get the following Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 97 bytes) in /home/pat95/public_html/home.php on line 249 Any ideas? Chears Rob Quote Link to comment 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.