This drove me crazy. For some reason, in test_comment.php, $cssdir kept throwing this error: Warning: fopen(../examplecomment.css): failed to open stream: Permission denied in /home/user/public_html/comments/class_comment.php on line 206
Warning: fwrite(): supplied argument is not a valid stream resource in /home/user/public_html/comments/class_comment.php on line 207
COMMENT::install() Can not write CSS file [../examplecomment.css]
I had to actually hard code the path into line 206 -- looked as if this->$cssdir had some other value than what I declared on line 23? Anyway, hard coding the path ran cleanly and the script then installed the correct table, fields, and css.
Randy Ahn - 2006-09-04 16:58:15 - In reply to message 2 from Peter Klauer
When I'm evaluating a new class, I tend to place all files within the same directory. So the only change I made to class.comment.php was on line 23:
var $cssdir = './'; to point to the current directory. This caused test_comment.php to throw the error, so I tried other directories, tried an string empty, created a css subdirectory, etc. I completely opened up permissions on the current directory and parent directory to 777. I also checked that the scripts were owned by nobody.
Then on line 206, I commented out "$this->cssdir" and replaced it with my path, and it worked!
$handle = fopen( /*$this->cssdir*/'./'.$this->code_for.'comment.css', 'w' );
I thought I must have made a mistake somewhere, so I untarred the package again and went through the steps a second time with the same result. I still think it's something silly that I'm doing wrong. I appreciate your help and this great class.
Peter Klauer - 2006-09-04 18:03:33 - In reply to message 3 from Randy Ahn
Changing line 23 does not work, because comment::cssdir will be overwritten from the constructor.
Then you changed row 206 and hard coded your css-path instead of $this->cssdir ?
Not great at all.
You have changed a class simply to hardcode a parameter which could easily be changed from outside the class: Big Mistake. Next time, when I upload a new version and you happily upgrade then Comment will again not work anymore. If you copy this class to a new project, it will not work anymore, because the path is not the same. You will be angry with me for distributing such a %$§&. You will have forgotten that you hardcoded your path into it.
- - - - - - - - - - - - - -
The 4th argument of the "new comment()" constructor is the path to set. I strongly recommend to reload the class, not change it and put the
css path argument
a) as 4th arg of "new comment()" or
b) after $comment = new comment(...);
$comment->cssdir = 'my hard coded path here';