-1

i have a worning massege only on localhost...

"Warning: getimagesize(images/cat/) [function.getimagesize]: failed to open stream: No such file or directory in C:\xampp\htdocs\gifts\libraries\leftmenu.php on line 104"

while($cat=mysql_fetch_object($cats))
    {


        $maincatname = str_replace("&","--",$cat->name);
        $image=$cat->image; 
        $catid=$cat->categoryID;
            $image_upload_path = "images/cat/";
                $url = $image_upload_path.$cat->image;              
                    $www = getimagesize($url);          

                    if (getimagesize($url))
                { 
                    $www = getimagesize($url);   //echo print_r($www). "<br>"; 
                    $width=$www[0]; //echo $width."...<br>";

                    if ($www[0] > 120)
                    { 
                        $www = "181";
                    }
                }
Haim Evgi
  • 123,187
  • 45
  • 217
  • 223
  • 4
    `$cat->image` seems to be empty. – Pekka Jun 12 '11 at 10:13
  • Please don't be offended, but you should improve on you coding style. Here's a few things to start: 1) you do `$image=$cat->image;` but continue to use `$cat->image`; 2) `$www` is a terrible name for variable that stores image size! 3) you store `$www = getimagesize($url);` but in later code call this funtion at least 2 more times, which goes to open/read the file each time - a terrible waste of execution time. – mkilmanas Jun 12 '11 at 10:19

1 Answers1

4

Display the value of $url using echo $url directly ablove the first getimagesize($url) and confirm if the image exist on your local server.

Ogugua Belonwu
  • 2,111
  • 6
  • 28
  • 45
  • @ogugua,i echo the $url but same problem.. – shoaib akhunzada Jun 12 '11 at 10:24
  • @shoaib akhunzada: Does the file exists on the server? – hakre Jun 12 '11 at 10:38
  • @hakre same worning massege like..."Warning: getimagesize(images/cat/) [function.getimagesize]: failed to open stream: No such file or directory in: – shoaib akhunzada Jun 12 '11 at 10:48
  • @hakre i check with this – shoaib akhunzada Jun 12 '11 at 10:52
  • $url = $image_upload_path.$cat->image; echo $url ; exit(); and the massege is IMAGE/CAT/ – shoaib akhunzada Jun 12 '11 at 10:53
  • 1
    @shoaib akhunzada: To quote pekka: `$cat->image` seems to be empty. You should first check if the data you process contains valid values. In case of invalid values, don't process further on. That will prevent errors. – hakre Jun 12 '11 at 11:02
  • @shoaib akhunzada, you actually get that error when the image does not exist, i just wanted you to confirm is the file name echoed really exists. That is you have to check the folder where the file is and confirm. echo $url will not solve your problem, it will only assist you in finding out if the filename is even valid – Ogugua Belonwu Jun 12 '11 at 11:49
  • @Ogugua there is images in folder... but $url is not present in table i will try to fix.. thanks – shoaib akhunzada Jun 13 '11 at 04:43