donatello Posted February 25, 2011 Share Posted February 25, 2011 I have had a problem with some scripts I wrote (Screenscrapers) that worked great in PHP4, but stopped working the minute I upgraded to PHP5. I can change all of my filenames to have the .PHP4 extension and this solves the problem, but since this encompasses a number of sites, internal links and hundreds of files, this is not my first choice solution. Here is the scraper, what it does, is it takes items from the zazzle Results Page by category, strips out the formatting, adds my affiliate ID and then I can present these items on my page. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Test of scrape</title> <link rel="stylesheet" type="text/css" href="/css/scraper.css" /> <script type='text/javascript' src='http://www.zazzle.com/js/logging/omniture/s_code.zjs/r-52.78223/site-zazzle.js'></script> </head> <body> <div class="gridCell " id="page_productsGrid_assetCell1"> <?php $page = file_get_contents("http://www.zazzle.com/cool+smiley+gifts"); //comment out the <span> tags completely $page = preg_replace('/<span/', "<!-- <span", $page); $page = preg_replace('/<\/span>/', "<\/span> -->", $page); $page = preg_replace('/<a /', "<a rel=\"nofollow\" ", $page); $rf_id="238219236805025733"; // Regular expression to parse "&rf=" and the $rf_id into the existing link $page=preg_replace("/(.*?)(href\s*=+\s*[\"\'])(.*?)([\"\'])(.*?)/is","$1$2$3?rf=$rf_id$4$5",$page); $test = explode('<div style="position:relative" class="clearfix">',$page); for($t=1;$t<=count($test)-2;$t++){ print "<div class=\"gridCellInfo\" id=\"page_products\">"; print $test[$t]; } ?> </body> </html> This works find in PHP4; not at all in PHP5. My ideal solution would be an .htaccess file that I could put in any directory under PHP5 to make it default to php4. I have tried this, to no avail (.htaccess): <IfModule mod_rewrite.c> RewriteEngine On AddType text/html .php4 AddHandler php4-script .php .html php5 </IfModule> I have also tried a few alternatives... this appears to be a common problem and I have scoured the web and found no solution. Here are the two pages in PHP4 and PHP5: php4: http://www.killersmiley.com/test/cool-smiley.php4 php5: http://www.killersmiley.com/test/cool-smiley.php Quote Link to comment https://forums.phpfreaks.com/topic/228784-php4-to-php5-upgrade-broke-scripts-not-working-now/ Share on other sites More sharing options...
isedeasy Posted February 25, 2011 Share Posted February 25, 2011 have you tried turning error reporting on and working your way through the errors? Quote Link to comment https://forums.phpfreaks.com/topic/228784-php4-to-php5-upgrade-broke-scripts-not-working-now/#findComment-1179480 Share on other sites More sharing options...
donatello Posted February 25, 2011 Author Share Posted February 25, 2011 Actually, no... I'm a total novice with PHP as this is a hobby... Can I do that for a single directory? Quote Link to comment https://forums.phpfreaks.com/topic/228784-php4-to-php5-upgrade-broke-scripts-not-working-now/#findComment-1179483 Share on other sites More sharing options...
donatello Posted February 25, 2011 Author Share Posted February 25, 2011 OK. I turned on the error reporting like so: ini_set('display_errors',1); error_reporting(E_ALL|E_STRICT); No help. Here is the page: http://www.killersmiley.com/test/error.php Quote Link to comment https://forums.phpfreaks.com/topic/228784-php4-to-php5-upgrade-broke-scripts-not-working-now/#findComment-1179486 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.