Results 1 to 5 of 5

Thread: PHP Error to be resolved

  1. #1
    Join Date
    Aug 2011
    Location
    Rep Of Ireland
    Posts
    126
    Thanks
    24
    Thanked 3 Times in 1 Post

    Default PHP Error to be resolved

    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

    I have line 421 marked in the code below.

    Code:
    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?

  2. #2
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    I don't see any error, is this resolved?
    - Josh

  3. #3
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    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.

  4. #4
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    What does flock() do, anyway?
    - Josh

  5. #5
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    flock() attempts to get an exclusive reading lock on the file, so no one else (no other script) can access it until you're done.
    Last edited by traq; 09-03-2011 at 08:18 PM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •