www.webdeveloper.com
Results 1 to 4 of 4

Thread: Image locating

  1. #1
    Join Date
    Oct 2007
    Posts
    113

    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

    Code:
    		$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">
    			'.$urun->kod.'';
    			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
    Posts
    316
    At first I thought it was:

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

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

    -----
    UPDATE:

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

    images/products/2610501.jpg
    images/products/2610601.jpg
    images/products/2610602.jpg

    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:

    http://www.omega-intertrade.com/imag...ts/2610501.jpg
    http://www.omega-intertrade.com/imag...ts/2610601.jpg
    http://www.omega-intertrade.com/imag...ts/2610602.jpg

    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 05:05 AM.
    David Walker
    Software Engineer
    - C++ guru
    - C# guru
    - PHP guru
    - Testing guru
    Theatatrical Tech
    - Sound Engineer
    - Lighting Designer
    - Stage manager

  3. #3
    Join Date
    Oct 2007
    Posts
    113
    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 08:15 AM.

  4. #4
    Join Date
    Nov 2007
    Posts
    316
    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.
    David Walker
    Software Engineer
    - C++ guru
    - C# guru
    - PHP guru
    - Testing guru
    Theatatrical Tech
    - Sound Engineer
    - Lighting Designer
    - Stage manager

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