Jump to content

Disable error possible?


minimad

Recommended Posts

Hi,

 

I have found a log on script (just php) for my website which works well.

The script generates a message to a user who should browse to the secure page without logging in, although this appears before it which is not required:

 

Warning: fread() [function.fread]: Length parameter must be greater than 0. in /home/account/public_html/website/secure.php on line 7

 

I guess this is generated by the server and not the script itself. Is there any way I can disable this?

 

Thanks for looking.

Link to comment
Share on other sites

we'll need to see the call to fread (note: i've linked to the function so you can see its documentation and try to spot the error yourself). presumably fread() is being used for some reason related to the script, and therefore it would be better to diagnose why the error is being caused, rather than simply suppressing it and potentially breaking the script.

Link to comment
Share on other sites

well, it's telling you it can't have a 0 length. that means that filsize($filename) is returning 0, which most likely means that the file is not found. where is $filename coming from? if it will only exist when the user logs on, you should move the check on whether the user is logged in to above the fread() call.

Link to comment
Share on other sites

hi,

the log on process compiles of 3 files: dataprocess.php, secure.php, user.log - the form integrated in with index.php

when secure.php loads it opens the log file to see if a valid user name is found. it also erases the log and display the content. The reason the code wipes the log clear is so no one (including the original visitor) can access the page again without re-logging on.

If someones goes directly to secure.php without signing in the code will read an empty log and display an error to the visitor.  It is not this error in the script I am trying to get rid off, but the one above it (shown in attachment)

 

Thanks for looking!

 

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

if it's erasing the log every time the file is accessed, you'll want to add an if() statement to check if the file is empty before running fread():

 

if (filesize($filename) == 0)
{
  exit('Viewing this page requires logging in.');
}
else
{
  // run the fread() stuff to check if there's anything in there
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.