Results 1 to 4 of 4

Thread: Image locating

  1. #1
    Join Date
    Oct 2007

    Image locating

    As i am developing the site offline on my computer, i dont have any problem with file locating.
    To put images on the page first i check if the respective image exsits

    		$sql = mysql_query("SELECT * FROM urunler order by kod") or die(mysql_error());
    		if(mysql_num_rows($sql) == 0) { echo'<tr><td>Yazar bulunamadi!</td></tr>'; }
    		else {
    		while($urun = mysql_fetch_object($sql)) {
    		$filename = '/images/products/'.$urun->kod.'.jpg';	
    		echo '<div id="box">
    			if (file_exists($filename)) {
    			echo '
    			<p align = "center"><a href="/images/products/'.$urun->kod.'.jpg" rel="lightbox" title="'.$urun->tanim.'" width="100">
    			<img src="images/products/'.$urun->kod.'.jpg" width="90" border="0" align="top"></a></p>'; }
    			else {
    			echo '
    			<p align = "center"><a href="images/products/no_image.jpg" rel="lightbox" title="'.$urun->tanim.'" width="100">
    			<img src="images/products/no_image.jpg" width="90" border="0" align="top"></a></p>'; }
    I check the existence of the image if the image doesnt exist then i print the 'no_image.jpg' file.

    Although i have images for most of the entries, for all the entries page prints 'no_image.jpg' file.

    It means that it can access the directory ''images/products'. But
    why i cant access and check existence of image with
    $filename = '/images/products/'.$urun->kod.'.jpg';

    As i told you it works offline fine on my computer.

    my website is http://www.omega-intertrade.com/

    You can also check it here.

  2. #2
    Join Date
    Nov 2007
    At first I thought it was:

    $filename = 'images/products/'.$urun->kod.'.jpg';

    But I'm not sure. Give me 5minutes.


    As far as I can see from the code and the website the images you are trying to dectect if they exist are:


    Attempting to find these on your site in the same folder as the no image (as implied by the code) results in no files being found:


    Either the files aren't there or you are creating the wrong file name/path in the code.
    Last edited by TheRave; 12-06-2007 at 06:05 AM.

  3. #3
    Join Date
    Oct 2007
    Thanks for your attention. I found the solution.

    The extensions of the images which i uploaded was capital letters like '.JPG'

    This was the problem. My code was checking 2610501.jpg and found nothing because the image i was looking for was saved as 2610501.JPG with an extension formed by capital letters.

    But i have another question :

    my site doesnt seem to be Valid XHTML 1.0 Transitional. Where it fails to be valid. What should i do to make it valid?
    Last edited by mrtblt; 12-06-2007 at 09:15 AM.

  4. #4
    Join Date
    Nov 2007
    Ahhh yes. That's happened to me before.

    These days I always sanitise all my data and files. For example make all file paths, file names, file extensions lower case.

    Its always better to use one method across the whole site.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles