Hi guys..Good Day!

I just want a little help why my dynamic image from mySQL database will not display in firefox but with IE it will. Ive created a table to hold the image where i only save the image path which was located in the server folder img.

This is the code to get the image location/path in mySQL.

mysql_select_db($database_nmpc_web_conn, $nmpc_web_conn);
$query_rec_img = "SELECT * FROM images ORDER BY id ASC";
$rec_img = mysql_query($query_rec_img, $nmpc_web_conn) or die(mysql_error());
$row_rec_img = mysql_fetch_assoc($rec_img);
$totalRows_rec_img = mysql_num_rows($rec_img);

This is now the code where i load the image path and display it in a div..

<div class="right-pic medium-pic">
<a href="<?php echo $row_rec_homeheadlines_center['pic_zoom']; ?>" title="2011 General Assembly Program Cover" id="single_image" class="picture"><img src="<?php echo $row_rec_homeheadlines_center['pic_normal']; ?>" alt="GA Program Cover" />
<span class="zoom"></span></a>			
</div>

And this is the CSS

.right-pic {
	display:block;
	float:left;
	margin:6px 40px 30px 0;
	position:relative;
	width:100%;
}

.medium-pic {
height:170px; width:275px;
}

Image path view in MySQL DB is something like this pic\Pic_Mix\pic1_s.JPG

Thank you in advanced for helping.

God bless!

Dani AI

Generated

Nice catch by and good diagnostic prompt from . The practical symptom you saw (working in IE but not in Firefox) comes from mixing an OS file separator with a web URL. Web paths must use forward slashes; backslashes are a Windows filesystem convention and are not a valid URL path separator per the URI spec. Some browsers (historically IE) quietly tolerate backslashes, while others (like Firefox) follow the spec and fail to resolve the resource.

Fixes and best practices

  • Normalize paths before output: convert any backslashes to forward slashes when you build the URL for an <img> tag. Also escape the attribute to prevent XSS. For example:
$url = str_replace('\\', '/', $pathFromDb);
echo '<img src="' . htmlspecialchars($url, ENT_QUOTES, 'UTF-8') . '" alt="">';
  • Store web-relative paths or filenames in the database instead of OS-specific full filesystem paths. Keep filesystem operations (moving, checking files) using DIRECTORY_SEPARATOR, but always use "/" for anything you expose as a URL.
  • Do a one-time cleanup of existing DB values (scripted replace or a controlled update) so future output does not need on-the-fly fixes.

Quick troubleshooting checklist

  • View page source or use Inspect Element to see the actual src value.
  • Check the Network tab for 404/URL errors and try opening the image URL directly.
  • Verify case sensitivity (Linux hosts are case-sensitive).
  • If images are delivered by a script (BLOBs), ensure correct Content-Type headers.

Good work to everyone who helped; normalizing path format at save- or output-time will prevent this cross-browser issue going forward.

Recommended Answers

All 4 Replies

Of the code after you run your page? I would like to see what IE and Firefox are putting into the boxes where your PHP code is..

Also, are you looping through your images?

Yes im looping the table to get all the images..

But anaway guys, this solves the problem.. In IE the image with path pic\Pic_Mix\pic1_s.JPG is acceptable but in FF will not.. but if i changed all the \ to / both will work.

Thank you for giving time..

God bless!

Yes im looping the table to get all the images..

But anaway guys, this solves the problem.. In IE the image with path pic\Pic_Mix\pic1_s.JPG is acceptable but in FF will not.. but if i changed all the \ to / both will work.

Thank you for giving time..

God bless!

Glad it's working for you! / vs \ is http vs local ..

Glad it's working for you! / vs \ is http vs local ..

Hi,

Thanks for the nice comment.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.