Jump to content

Ie error images


Xagrik

Recommended Posts

Hi everyone!!

 

I'm developing a website in php/mysql.

The database have 4 image fields, but in some cases i just use 2 or 3, the other image fields are empty.

The page where i show the rows os the database was developed with the 4 fields in it.

In firefox everything is allright, but in IE the empty image fields are shown as the image below.

 

Can anyone help me to solve this problem?

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/114676-ie-error-images/
Share on other sites

The code:

 

<a href="<?php  echo $row_motos['img1']; ?>" rel="lightbox"><img src="<?php echo $row_motos['img1']; ?>" width="250" height="187" border="0" /></a> <a href="<?php  echo $row_motos['img2']; ?>" rel="lightbox"><img  src="<?php echo $row_motos['img2']; ?>" width="250" height="187" border="0" /></a>

 

The problem is when the img2 field is blank should not appear anything, in firefox works fine, but in IE shows that image :S

Link to comment
https://forums.phpfreaks.com/topic/114676-ie-error-images/#findComment-589721
Share on other sites

The reason your getting the "X" image with Internet Explorer is because the image doesn't exist (or your linking to it wrong). That's just the way the browser behaves.

 

Are you sure you aren't trying to display an image depending on whether it's set in your array?

 

You could do something like:

if (isset($row_motos['img1']))
{
// print the HTML for img1
}
else
{
// print the HTML for img2
}

 

??

Link to comment
https://forums.phpfreaks.com/topic/114676-ie-error-images/#findComment-589733
Share on other sites

I'm not sure, but i think that i could not use the code you gave me, because the structure of my code is already set to show all the image fields, and if i put a default image, it will link to a blank image (i'm using lightbox to enlarge the images).

I just don't finde a way to hide that image if it doesn't exist in the database :s

Link to comment
https://forums.phpfreaks.com/topic/114676-ie-error-images/#findComment-589741
Share on other sites

if i were you i would use a while statement.

 

<?php

$query = "";
$result = mysql_query($query);

while $row = mysql_fetch_array($result)) {
//gets vars
$image = $row['col'];
//display images here like so
?>
<img src="/images/<?php echo $image; ?>" alt="image" />
<?php
}
<?

 

and please, if your going to make the site standards compliant DO NOT forget to add the alt="" tag.

Link to comment
https://forums.phpfreaks.com/topic/114676-ie-error-images/#findComment-589743
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.