Confused! This [simple] code works in PHP4 but not PHP5


#1

Hi
I’m confused about the following code. What it should do (and it does in PHP4) is show info from a template.

It starts with $i==‘1’, which is general info, if you click the ‘photo’ button it sets $i==‘2’ and should show that data. Again, it does that fine in PHP4, but not in PHP5.

Can anyone please help me out, I’m lost on this one :confused:
PM me if you need to see an online sample, I have two domains setup, one with PHP4 and one with PHP5, both runnng the same code.

The info page:
[php]

<?php require_once("conn.php"); require_once("includes.php"); if(empty($_GET[id])) { header("location:index.php"); exit(); } $q1 = "select * from re2_agents, re2_listings where re2_listings.ListingID = '$_GET[id]' and re2_listings.AgentID = re2_agents.AgentID "; $r1 = mysql_query($q1) or die(mysql_error()); $a1 = mysql_fetch_array($r1); ////////////////////////////////////////////////////// ////////////////// Home View Counter Start ////////////////////////////////////////////////////// if($a1[AgentID] != $_SESSION[AgentID]) { if(!empty($_COOKIE[RealEstates])) { $CookieArray = explode("|", $_COOKIE[RealEstates]); array_unique($CookieArray); $rev = count($CookieArray); if(!in_array($_GET[id], $CookieArray)) { $NewValue = $_COOKIE[RealEstates]."|".$_GET[id]; setcookie ("RealEstates", $NewValue); $ch = '1'; } } else { setcookie ("RealEstates", $_GET[id]); } if($rev == '0' || empty($rev)) { $HomeCount = 1; } else { if(isset($ch)) { $HomeCount = $rev + 1; } else { $HomeCount = $rev; } } $HomeViews = $HomeCount." listings viewed this visit."; } ////////////////////////////////////////////////////// ////////////////// Home View Counter End ////////////////////////////////////////////////////// if(empty($i) || $i == '1') { $Image1 = "infobalk_01_sel.gif"; $desc = nl2br($a1[DetailedDesc]); $MyPrice = number_format($a1[Price], 2, ".", ","); $ShowInfo = "ntntntnnnntntn"; if($a1[AgentID] == $_SESSION[AgentID]) { $ShowInfo .= "ntnnn"; } $ShowInfo .= "n
$a1[city], $a1[state], $a1[country]
$a1[address]
Price: $$MyPrice

Property ID: $a1[ListingID]

$desc

$a1[rooms] br, $a1[bathrooms] ba, $a1[garage] gr

Neighbourhood:
$a1[neighbourhood]

$a1[SquareMeters] sq.m.
Lot Size: $a1[LotSize] sq.m.
Age: $a1[HomeAge]
"; if($a1[fireplace] == 'y') { $ShowInfo .= "Fireplace
n"; } if($a1[NearSchool] == 'y') { $ShowInfo .= "Near school
n"; } if($a1[NearTransit] == 'y') { $ShowInfo .= "Near transit
n"; } if($a1[NearPark] == 'y') { $ShowInfo .= "Near park
n"; } if($a1[OceanView] == 'y') { $ShowInfo .= "Ocean view
n"; } if($a1[LakeView] == 'y') { $ShowInfo .= "Lake view
n"; } if($a1[MountainView] == 'y') { $ShowInfo .= "Mountain view
n"; } if($a1[OceanWaterfront] == 'y') { $ShowInfo .= "Ocean waterfront
n"; } if($a1[LakeWaterfront] == 'y') { $ShowInfo .= "Lake waterfront
n"; } if($a1[RiverWaterfront] == 'y') { $ShowInfo .= "River waterfront
n"; } if(!empty($a1[image])) { $im_array = explode("|", $a1[image]); $FirstImage = ""; } if($a1[AccountType] == '2') { if(!empty($a1[cellular])) { $int[] = "Cellular: $a1[cellular]"; } if(!empty($a1[pager])) { $int[] = "Pager: $a1[pager]"; } if(!empty($int)) { $int2 = implode("
", $int); $int2 = "
".$int2; } } $ShowInfo .= "
$FirstImage

For more information call
$a1[FirstName] $a1[LastName]
Phone: $a1[phone]$int2

or click here to email.

"; if($a1[AccountType] == '1') { $ShowInfo .= "More properties by this agent

"; } else { $ShowInfo .= "More properties by $a1[FirstName] $a1[LastName]

"; } if($a1[AccountType] == '1') { if(!empty($a1[logo])) { $ShowInfo .= ""; } else { $ShowInfo .= "$a1[FirstName] $a1[LastName] Resume"; } } $ShowInfo .= "
edit | delete
"; } else { $Image1 = "infobalk_01.gif"; } if($i == '2') { $Image2 = "infobalk_02_sel.gif"; if(!empty($a1[image])) { $MyImages = explode("|", $a1[image]); $ShowInfo .= "nnt
"; while(list(,$v) = each($MyImages)) { $ShowInfo .= "   nnt"; } $ShowInfo .= "


"; if(!empty($f)) { $ShowInfo .= "
"; } else { $ShowInfo .= "
"; } // afbeeldingsgrootte wordt bepaald door class=plaatje in de headertemplate! } else { $ShowInfo .= "
"; } } else { $Image2 = "infobalk_02.gif"; } $MyAddress = str_replace(" ", "+", $a1[address]); $MyAddress = str_replace(",", "", $MyAddress); $Image3 = ""; //$Image3 = ""; $ListingID = $a1[ListingID]; require_once("templates/HeaderTemplate.php"); require_once("templates/InfoTemplate.php"); require_once("templates/FooterTemplate.php"); //update the stats $q1 = "update re2_listings set visits = visits + '1' where ListingID = '$_GET[id]' "; mysql_query($q1) or die(mysql_error()); ?>[/php]

and the template (that works perfectly in PHP4)

[code]

<?=$HomeViews?> Tell a friend!
<?=$_LANG['GEGEVENS'];?> <?=$_LANG['INFOFOTO'];?> " target=_blank>Printer friendly version [/code]

#2

Could you please show me the page(s) on both servers (PHP4 and PHP5 version), but after you’ve put the following at the top of your PHP scripts:

[php]error_reporting(E_ALL);[/php]


#3

Hi Zyppora

http://www.heymans.name/info.php?id=19&i=2 is the php4 version and

http://re.heymans.name/info.php?id=19&i=2 is php5 (with only the images modified)

I have included the line you said in the info.php

the ‘photo’ button is giving me problems… and i get alot of notices too now.

thanks
JP


#4

I’d say you’ve got your work cut out for you: Start fixing the notices :slight_smile: