errno=2

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bogdani
Forum Newbie
Posts: 5
Joined: Wed Jan 14, 2004 10:02 pm

errno=2

Post by bogdani »

Hello everybody,

Can you help me with this? From where is generated this error (having in mind that the code is okay and it worked nicely on my localhost server and on another remote server). :roll:

Warning: filesize() [function.filesize]: Stat failed for (errno=2 - No such file or directory) in /usr/home/admin/sites/my/_admin/do_upload.php on line 4

Warning: fread(): supplied argument is not a valid stream resource in /usr/home/admin/sites/my/_admin/do_upload.php on line 4

Thanks!
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

show us line 4.

the first warning message is very obvious.. the file or directory does not exists...

that error generate the second warning because the script didnt generate de right resource.
bogdani
Forum Newbie
Posts: 5
Joined: Wed Jan 14, 2004 10:02 pm

Post by bogdani »

Line 4: $data2 = addslashes(fread(fopen($form_data2, "r"), filesize($form_data2)));

It is a form that uploads an image into database...
bogdani
Forum Newbie
Posts: 5
Joined: Wed Jan 14, 2004 10:02 pm

Post by bogdani »

I'ts very weird. It seems to have something to do with that hosting provider ? Some settings to database / server ?
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

how do you fetch #form_data2, using $_POST or $_GET?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

When you echo $form_data2 what to you get?

Mac
bogdani
Forum Newbie
Posts: 5
Joined: Wed Jan 14, 2004 10:02 pm

Post by bogdani »

I am using POST to submit data,..

twigletmac -> I remind you that the script is 100% okay on other 2 servers, but on this FreeBSD hosted server it gives me this error,..

Thanks
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

bogdani wrote:Twigletmac -> I remind you that the script is 100% okay on other 2 servers, but on this FreeBSD hosted server it gives me this error,..
Doesn't make a difference, what if there are different configurations and/or versions of PHP on each server? You really should check what is in $form_data2 - the error message doesn't seem to give a file name. Unless you purposefully removed that then it's kinda suspicious.

Mac
bogdani
Forum Newbie
Posts: 5
Joined: Wed Jan 14, 2004 10:02 pm

Post by bogdani »

the problem was from register globals which was off,... now I upload the image using $_FILES and it's okay.

but when I'm trying to display it, it just give me "Array" instead of content of the image,.. do you know what code should I use ?

I use:

Code: Select all

<?php
if($id) {
    mysql_select_db($database_ft, $ft);
    $query = "select id,photo_small1 from products where id=$id";
    $result = @MYSQL_QUERY($query);
    $data = @MYSQL_RESULT($result,0,"photo_small1");
    Header( "Content-type: image/JPEG");
    echo $data;
};
?>
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

The MySQL result is returning an array.

Instead of echo $data, do something like:

Code: Select all

<?php
foreach ($data as $key => $value) {
   echo "Key: $key; Value: $value<br>\n";
}
?>
Obviously this will need reformatting to fit the way you would like it, but its a start. If you don't know what arrays are I suggest you do some reading.

http://www.php.net/manual/en/language.types.array.php
http://lineman.net/article98.html
http://www.devshed.com/c/a/PHP/Array-Ma ... With-PHP4/
Post Reply