Log in

View Full Version : PHP Script - Failed to Open Stream



andy8828
09-11-2009, 08:45 PM
Hello,

I have a web page which people can post their messages on it. Now for some reasons, the script has errors, and it cannot open stream... Here is the error message:

Warning: fopen(data/) [function.fopen]: failed to open stream: Is a directory in /homepages/33/d138037059/htdocs/wish/show.php on line 21

Warning: flock() expects parameter 1 to be resource, boolean given in /homepages/33/d138037059/htdocs/wish/show.php on line 22

Warning: fclose(): supplied argument is not a valid stream resource in /homepages/33/d138037059/htdocs/wish/show.php on line 24
...

Here is the URL: http://www.uswebcity.com/wish/show.php?number=1237725546 (errors)

Here is the web page: http://www.uswebcity.com/wish/

The script did work fine before last month and I have not made any changes. I know the script(s) has no errors, and it will not cause any errors because today I did try the same(identical) scripts at other website that host by StartLogic.com host company, and the script works fine there. So the errors which are at my web site may cause by my current host company's server settings or some php configurations.

Could you please help me to fix(change) the script? So it will work fine with (both) my current host company(oneandone.com).
Here is part of the script that the errors refer to:


<?
include "config.inc";

$f=file("data/$number");
for($i=0; $i<count($f); $i++){
if($i== 8)$f[$i]=$f[$i]+1;
$message=$message.$f[$i];
$ff=explode("\n",$f[$i]);
$f[$i]=$ff[0];
}
$fp=fopen("data/$number","w"); ### Line # 21
flock($fp,3);
fwrite($fp,$message);
fclose($fp);
?>


Thanks.

Andy
__________________
Make A New Website --- USWebCity.com
>> Web Hosting Ratings and Reviews <<

andy8828
09-11-2009, 11:19 PM
After I defined the $number, the errors were fixed now.
$number = (int)$_GET['number'];

But I have one more question. When I click on the the link below which it should open a new submit form window for people to fill it out. But now it only reloads the current page. The submit form does not show up.



<?
if($do=='new'){
?>

Here is the URL: http://www.uswebcity.com/wish/wish.php?do=new

Thanks.

thetestingsite
09-12-2009, 02:24 AM
When I visit the link you posted, it seems to be working fine. Could you be more specific with your problem?

andy8828
09-12-2009, 09:03 PM
After I changed it to


if($_GET['do']=='new'){

The submit form shows up on the web site. But after I filled out the form and submited it, I don't get any data from the form. I don't see it created any data files in my web server DATA directory. Do you have anymoe suggestion?

Also, you can find part of the script. Thanks.

andy8828
09-14-2009, 12:03 AM
After I tuned on the php setting "register_globals = on", the form works fine now.

http://www.uswebcity.com/wish/wish.php

Thank you very much for your help. :)