Page 1 of 1
Someone please tell me why this doesnt work??
Posted: Sat Nov 10, 2007 12:04 pm
by mkkay
This code is supposed to retrieve images from the specified folder.
Code: Select all
$Image2 = "bg_photos2.gif";
if(!empty($a1[image]))
{
$MyImages = explode("|", $a1[image]);
$ShowInfo .= "<table valign=top align=center width=\"100%\" height=50>\n<tr>\n\t<td align=center valign=top width=\"100%\" height=50>";
while(list(,$v) = each($MyImages))
{
$ShowInfo .= "<a href=\'info.php?id=$_GET[id]&i=$_GET[i]&f=$v\'><img src=\'cars_images/$v\' width=50 height=50 border=0></a> \n\n\t";
}
$ShowInfo .= "</table><hr size=1 width=\"95%\" color=#336699><br>";
if(!empty($f))
{
$ShowInfo .= "<center><img src=\'cars_images/$f\'></center><br>";
}
else
{
$ShowInfo .= "<center><img src=\'cars_images/$MyImages[0]\'></center><br>";
}
}
else
{
$ShowInfo .= "<br><center><img src=\'no_image.gif\'></center>";
}
}
Descriptive Subjects
Posted: Sat Nov 10, 2007 12:08 pm
by feyd
You really need to turn on E_NOTICE level errors.
error_reporting()
Posted: Sat Nov 10, 2007 2:08 pm
by mkkay
How do i do this? and why ]do you think the images are not being shown? Sorry im aliitle bit new at this, though i can say that the code was working fine till i moved servers.
Posted: Sat Nov 10, 2007 4:05 pm
by feyd
Whether your code works or not appears to pivot on $a1 being set correctly. Have you verified this is true?
Posted: Sat Nov 10, 2007 5:24 pm
by mkkay
Yes. a1 is fine. does the code change depending on whether a server supports php version 4 or not? because my new server does. The code was working perfectly on my old server. I think the code executes but it just doesnt seem to return what it has found....
Posted: Sat Nov 10, 2007 5:40 pm
by feyd
Where is $a1 coming from?
Posted: Sat Nov 10, 2007 5:54 pm
by Bogey
Dunno if this might help but try it...
Code: Select all
$Image2 = "bg_photos2.gif";
if(!empty($a1['image']))
{
$MyImages = explode("|", $a1['image']);
$ShowInfo .= "<table valign=top align=center width=\"100%\" height=50>\n<tr>\n\t<td align=center valign=top width=\"100%\" height=50>";
while(list(,$v) = each($MyImages))
{
$ShowInfo .= "<a href=\'info.php?id=$_GET[id]&i=$_GET[i]&f=$v\'><img src=\'cars_images/$v\' width=50 height=50 border=0></a> \n\n\t";
}
$ShowInfo .= "</table><hr size=1 width=\"95%\" color=#336699><br>";
if(!empty($f))
{
$ShowInfo .= "<center><img src=\'cars_images/$f\'></center><br>";
}
else
{
$ShowInfo .= "<center><img src=\'cars_images/$MyImages[0]\'></center><br>";
}
}
else
{
$ShowInfo .= "<br><center><img src=\'no_image.gif\'></center>";
}
}
Posted: Sat Nov 10, 2007 7:17 pm
by mkkay
I have tried to put the code but it is still not working, it says transferring data then just brings back the page, it basically refreshes. I think a1 is the id that was given to the specific item. It retrieves the id and gets the images that match that.
Posted: Sat Nov 10, 2007 10:52 pm
by Bogey
Yes, that's what I think what id is in the url id=$_GET['id'] if I'm not mistaken... I see there is also the same thing for "i" (i=&_GET['i']) in...
Code: Select all
$ShowInfo .= "<a href=\'info.php?id=$_GET[id]&i=$_GET[i]&f=$v\'><img src=\'cars_images/$v\' width=50 height=50 border=0></a> \n\n\t";
What I believe is that the $a1 is the image itself... I believe that the image stores itself into the variable $a1 seeing the following code...
Code: Select all
$MyImages = explode("|", $a1['image']);
Se how $a1 is flush against ['image']? I have no idea if this is right though... just trying to make sense of it. Although I bet you are right versus my jumble of junk here
If the first "$showInfo" that I see in this code is in fact the first "$ShowInfo" in the whole code, than try the following code...
Code: Select all
$Image2 = "bg_photos2.gif";
if(!empty($a1['image']))
{
$MyImages = explode("|", $a1['image']);
$ShowInfo = "<table valign=top align=center width=\"100%\" height=50>\n<tr>\n\t<td align=center valign=top width=\"100%\" height=50>";
while(list(,$v) = each($MyImages))
{
$ShowInfo .= "<a href=\'info.php?id=$_GET[id]&i=$_GET[i]&f=$v\'><img src=\'cars_images/$v\' width=50 height=50 border=0></a> \n\n\t";
}
$ShowInfo .= "</table><hr size=1 width=\"95%\" color=#336699><br>";
if(!empty($f))
{
$ShowInfo .= "<center><img src=\'cars_images/$f\'></center><br>";
}
else
{
$ShowInfo .= "<center><img src=\'cars_images/$MyImages[0]\'></center><br>";
}
}
else
{
$ShowInfo .= "<br><center><img src=\'no_image.gif\'></center>";
}
}
If it's not the first one then find the first one in the code and remove the '.' in front of the '='. That proved to solve some of my problems on some of my problems.
Posted: Tue Nov 13, 2007 7:06 am
by mkkay
The code is still not working. Here is the whole code for the whole page.....I hope this will help
Code: Select all
<?
require_once("conn.php");
require_once("includes.php");
if(empty($_GET[id]))
{
header("location:index.php");
exit();
}
$q1 = "select * from cars_agents, cars_listings, cars_vehicle where cars_listings.ListingID = '$_GET[id]' and cars_listings.AgentID = cars_agents.AgentID and cars_listings.VehicleMake = cars_vehicle.VehicleID";
$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[cars]);
array_unique($CookieArray);
$rev = count($CookieArray);
if(!in_array($_GET[id], $CookieArray))
{
$NewValue = $_COOKIE[cars]."|".$_GET[id];
setcookie ("cars", $NewValue);
$ch = '1';
}
}
else
{
setcookie ("cars", $_GET[id]);
}
if($rev == '0' || empty($rev))
{
$HomeCount = 1;
}
else
{
if(isset($ch))
{
$HomeCount = $rev + 1;
}
else
{
$HomeCount = $rev;
}
}
$HomeViews = $HomeCount." offers viewed this visit.";
}
//////////////////////////////////////////////////////
////////////////// Home View Counter End
//////////////////////////////////////////////////////
if(empty($i) || $i == '1')
{
$Image1 = "bg_info2.gif";
$desc = nl2br($a1[DetailedDesc]);
$MyPrice = number_format($a1[Price], 2, ".", ",");
$ShowInfo = "<table border=0 align=center width=\"100%\">\n\t<tr>\n\t<td width=\"60%\" valign=top align=left><font size=2 face=verdana color=black><b>$a1[VehicleName] $a1[VehicleModel]</b><br><b>Year:</b> $a1[VehicleYear]<br><b>Mileage:</b> $a1[mileage] Kilometres<br><b>Color:</b> $a1[VehicleColor]<br><b>Location:</b> $a1[address], $a1[city],<br>$a1[state], $a1[country]<br><b>Seller:</b> $a1[FirstName] $a1[LastName]</font></td>\n\t<td width=\"40%\" valign=top align=center><font size=2 face=verdana><B>Price:</b> $aset[Currencya]$MyPrice</td>\n</tr>\n\n<tr>\n\t<td valign=top align=left><br><b>Offer ID:</b> $a1[ListingID]<br><br>$desc<br>";
if(!empty($a1[image]))
{
$im_array = explode("|", $a1[image]);
$FirstImage = "<center><a href=\"cars_images/$im_array[0]\" target=_blank><img src=\"cars_images/$im_array[0]\" width=125 height=125 border=1><br>Enlarge</a></center>";
}
$ShowInfo .= "</td>\n\t<td align=center valign=top>$FirstImage<br><br>For more information call<br><b> $a1[FirstName] $a1[LastName]<br>$a1[phone]</b><br>or click <a class=RedLink href=\"email.php?AgentID=$a1[AgentID]&ListingID=$a1[ListingID]\">here</a> to email.<br><br><a class=BlackLink href=\"search.php?AgentID=$a1[AgentID]\" title=\"More offers by $a1[FirstName] $a1[LastName]\">More Offers by This Agent</a><br>";
if(!empty($a1[logo]))
{
$ShowInfo .= "<a href=\"resume.php?id=$a1[AgentID]\" title=\"$a1[FistName] $a1[LastName]'s profile\"><img src=\"cars_images/$a1[logo]\" border=0></a>";
}
else
{
$ShowInfo .= "<a class=BlackLink href=\"resume.php?id=$a1[AgentID]\" title=\"$a1[FistName] $a1[LastName]'s profile\">$a1[FirstName] $a1[LastName]'s Profile</a>";
}
$ShowInfo .= "</td>\n</tr>";
if($a1[AgentID] == $_SESSION[AgentID])
{
$ShowInfo .= "<tr>\n\t<td colspan=3 align=center><a class=RedLink href=\"edit.php?id=$a1[ListingID]\">edit</a> | <a class=RedLink href=\"delete.php?id=$a1[ListingID]\">delete</a></td>\n</tr>\n\n";
}
$ShowInfo .= "\n</table>";
}
else
{
$Image1 = "bg_info.gif";
}
if($i == '2')
{
$Image2 = "bg_photos2.gif";
if(!empty($a1[image]))
{
$MyImages = explode("|", $a1[image]);
$ShowInfo .= "<table valign=top align=center width=\"100%\" height=50>\n<tr>\n\t<td align=center valign=top width=\"100%\" height=50>";
while(list(,$v) = each($MyImages))
{
$ShowInfo .= "<a href=\"info.php?id=$_GET[id]&i=$_GET[i]&f=$v\"><img src=\"cars_images/$v\" width=50 height=50 border=0></a> \n\n\t";
}
$ShowInfo .= "</table><hr size=1 width=\"95%\" color=#336699><br>";
if(!empty($f))
{
$ShowInfo .= "<center><img src=\"cars_images/$f\"></center><br>";
}
else
{
$ShowInfo .= "<center><img src=\"cars_images/$MyImages[0]\"></center><br>";
}
}
else
{
$ShowInfo .= "<br><center><img src=\"no_image.gif\"></center>";
}
}
else
{
$Image2 = "bg_photos.gif";
}
$MyAddress = str_replace(" ", "+", $a1[address]);
$MyAddress = str_replace(",", "", $MyAddress);
$Image3 = "<a target=_blank href=\"http://www.mapquest.com/maps/map.adp?city=$a1[city]&state=$a1[state]&address=$MyAddress&country=$a1[country]&zoom=5\"><img src=\"myimages/bg_directions.gif\" width=150 height=20 border=0></a>";
//$Image3 = "<img src=\"myimages/no_directions.gif\">";
$ListingID = $a1[ListingID];
require_once("templates/HeaderTemplate.php");
require_once("templates/InfoTemplate.php");
require_once("templates/FooterTemplate.php");
//update the stats
$q1 = "update cars_listings set visits = visits + '1' where ListingID = '$_GET[id]' ";
mysql_query($q1) or die(mysql_error());
?>