A friend just changed servers with her web site. The new server uses PHP
4.3.2 as opposed to the old server that had one of the 4.0.x's (don't
remember exactly which one). Now I know all about the register globals
change but one of the pages is suddenly throwing me an error I can't
figure out. It is not on a form. It is a script to include a random
quote on a page once every 50 page loads. It worked fine on the old
server but is throwing an error on the new one. Can anyone tell me what
I need to do to correct this?
The error:
Warning: fopen(displayqu ote.inc): failed to open stream: Permission
denied in /usr/local/apache/htdocs/WD/witw/week5.htm on line 129
Warning: fputs(): supplied argument is not a valid stream resource in
/usr/local/apache/htdocs/WD/witw/myform.htm on line 130
Here is the script for it:
<?
/* Config Part
--------------------------------------------------------------------------------------------------------------*/
$random = false; //true for random, false for sequential $directory = "";
$quotefile = "randomquote5.i nc"; // The Random Quote file
$quotecountfile = "displayquote.i nc"; // The Display Quote count file
that keeps track of what number page load it is
/* End of Config Part
-------------------------------------------------------------------------------------------------------*/
$quotes = file($directory .$quotefile);
$number = count($quotes);
if($random){
$num = rand(0,$number-1);
}
else{
$num = file($directory .$quotecountfil e);
$num = $num[0]+1;
if($num>$number-1){ // If ran out of quotes, start again!
$num=0;
}
if (file_exists($d irectory.$quote countfile)) {
$nu = fopen ($directory.$qu otecountfile, "w"); //This is line 129
fputs($nu,$num) ; //This is line 130
}
else {
die("Cant Find $quotecountfile ");
}
}
// display the quote on the page
?>
<br>
<p align="center"> <font face="Verdana, Arial, Helvetica, sans-serif"
size="2"><b><?p hp print "$quotes[$num]"; ?></b></font></p>
4.3.2 as opposed to the old server that had one of the 4.0.x's (don't
remember exactly which one). Now I know all about the register globals
change but one of the pages is suddenly throwing me an error I can't
figure out. It is not on a form. It is a script to include a random
quote on a page once every 50 page loads. It worked fine on the old
server but is throwing an error on the new one. Can anyone tell me what
I need to do to correct this?
The error:
Warning: fopen(displayqu ote.inc): failed to open stream: Permission
denied in /usr/local/apache/htdocs/WD/witw/week5.htm on line 129
Warning: fputs(): supplied argument is not a valid stream resource in
/usr/local/apache/htdocs/WD/witw/myform.htm on line 130
Here is the script for it:
<?
/* Config Part
--------------------------------------------------------------------------------------------------------------*/
$random = false; //true for random, false for sequential $directory = "";
$quotefile = "randomquote5.i nc"; // The Random Quote file
$quotecountfile = "displayquote.i nc"; // The Display Quote count file
that keeps track of what number page load it is
/* End of Config Part
-------------------------------------------------------------------------------------------------------*/
$quotes = file($directory .$quotefile);
$number = count($quotes);
if($random){
$num = rand(0,$number-1);
}
else{
$num = file($directory .$quotecountfil e);
$num = $num[0]+1;
if($num>$number-1){ // If ran out of quotes, start again!
$num=0;
}
if (file_exists($d irectory.$quote countfile)) {
$nu = fopen ($directory.$qu otecountfile, "w"); //This is line 129
fputs($nu,$num) ; //This is line 130
}
else {
die("Cant Find $quotecountfile ");
}
}
// display the quote on the page
?>
<br>
<p align="center"> <font face="Verdana, Arial, Helvetica, sans-serif"
size="2"><b><?p hp print "$quotes[$num]"; ?></b></font></p>
Comment