Log in

View Full Version : PHP Error to be resolved



Webiter
09-03-2011, 01:50 PM
I am trying to test the ArdGuest - Free PHP Guestbook Script on a production server before installing on website.
I get the following PHP Warning: flock() expects parameter 1 to be resource, boolean given in C:\CustomerData\shopdemo.webitry.net\index.php on line 421

View at www.shopdemo.webitry.net\index.php (http://www.shopdemo.webitry.net/index.php)

I have line 421 marked in the code below.


if (!is_spam($newdata)) {
$tambah = fopen($data_file,"a");
if (strtoupper($os)=="WIN") {
line 421 if (flock($tambah,LOCK_EX)) {
fwrite($tambah,$newdata);
flock($tambah,LOCK_UN);
}

What is causing the error and how can it be corrected?

JShor
09-03-2011, 02:29 PM
I don't see any error, is this resolved?

traq
09-03-2011, 04:39 PM
it means that two lines above, when you tried to open the file, it failed to open (fopen() returns FALSE when it fails). Make sure the file path and permissions are correct.

JShor
09-03-2011, 04:45 PM
What does flock() do, anyway?

traq
09-03-2011, 07:35 PM
flock() (http://us.php.net/manual/en/function.flock.php) attempts to get an exclusive reading lock on the file, so no one else (no other script) can access it until you're done.