LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-21-2009, 03:00 AM   #1
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,466
Blog Entries: 6

Rep: Reputation: 51
Needed Help in PHP?


I have the following error messages in apache logs :
Code:
[Sat Nov 21 14:25:12 2009] [error] [client 10.14.236.140] PHP Warning:  fgets(): supplied argument is not a valid stream resource in /var/www/notice.php on line 70, referer: http://<IP>/notice.php
any idea what is this all about?

Last edited by your_shadow03; 11-24-2009 at 10:12 PM.
 
Old 11-21-2009, 03:14 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hi,

Open /var/www_81/watch2.php in an editor, copy what's on line 70 and post it here. What's the program you're trying to run through apache when you get the error? Is it something you coded or did you get it from the web? If you got it from the web what is it?

Kind regards,

Eric
 
Old 11-21-2009, 03:34 AM   #3
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,466

Original Poster
Blog Entries: 6

Rep: Reputation: 51
Script Deleted---
Please ignore

Last edited by your_shadow03; 11-22-2009 at 05:45 AM.
 
Old 11-21-2009, 03:47 AM   #4
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,466

Original Poster
Blog Entries: 6

Rep: Reputation: 51
Line 70 is:
Code:
Deleted

Last edited by your_shadow03; 11-24-2009 at 10:12 PM.
 
Old 11-21-2009, 04:07 AM   #5
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,466

Original Poster
Blog Entries: 6

Rep: Reputation: 51
Lemme explain you few things Eric..
I have those rrd and log files under /home/john/gra.
Whenever I browse to http://<IP>/filename it opens up:


All the output shows 0.00.
I wonder it was permission issue but I have put john and apache in same group.

Last edited by your_shadow03; 11-22-2009 at 12:24 AM.
 
Old 11-21-2009, 04:13 AM   #6
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
No clue whatsoever what might be wrong, but then again I'm not the PHP Guru neither. Someone will have a look soon, I'm sure.

Kind regards,

Eric
 
Old 11-21-2009, 04:13 AM   #7
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
A few comments.

I can't see what the each(handles);statement is doing (line 66), I'd remove it unless you can explain why it is there.

The earlier block of code (around line 57) sets up the file handlers but doesn't check that they are working correctly. If the fopen() failed then it will return false, it should also raise a warning.

PHP Code:
if ($_GET['mode']=='row') {
   
$handles = array();
   foreach (
$files as $log_file) {
      
$fh fopen("$base_dir/$log_file",r);
      
fseek($fh,0,SEEK_END);
      
$handles[] = $fh;
   } 
and where does the close brace for the first if occur?
 
Old 11-21-2009, 04:15 AM   #8
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,466

Original Poster
Blog Entries: 6

Rep: Reputation: 51
EricTra ...Can yu hint me what generally causes this error:
Code:
fgets(): supplied argument is not a.....
 
Old 11-21-2009, 04:26 AM   #9
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
It is expecting a handle to an open file, so that it (fgets) can then read data from this file. The block of code above this opens the file, but it never checks to see if the file has been opened successfully.
 
Old 11-21-2009, 04:27 AM   #10
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Have you looked at what graemef posted? He might be on to something. Also have a look a this. Like graemef states, the file opening doesn't get handled completely when failing what might result in this error.

Fix what graemef indicated and try again.

Kind regards,

Eric
 
Old 11-21-2009, 04:29 AM   #11
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,466

Original Poster
Blog Entries: 6

Rep: Reputation: 51
May I know which file its trying to see?
 
Old 11-21-2009, 04:30 AM   #12
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,466

Original Poster
Blog Entries: 6

Rep: Reputation: 51
graemef..What line I need to modify?
Can yu pls dictate the same?
 
Old 11-21-2009, 06:05 AM   #13
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
As a starter change:

PHP Code:
if ($_GET['mode']=='row') {
   
$handles = array();
   foreach (
$files as $log_file) {
      
$fh fopen("$base_dir/$log_file",r);
      
fseek($fh,0,SEEK_END);
      
$handles[] = $fh;
   } 
to:

PHP Code:
if ($_GET['mode']=='row') {
   
$handles = array();
   foreach (
$files as $log_file) {
      
$fh fopen("$base_dir/$log_file",r);
      if (
$fh === false)
         echo 
"Failed to open file $base_dir/$log_file";
      
fseek($fh,0,SEEK_END);
      
$handles[] = $fh;
   } 
 
Old 11-21-2009, 06:09 AM   #14
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
By the way your concern about permission could be the problem (Post #5). You need to make sure that the Apache user has access to not just the files but the path to the files. A common problem would be that it doesn't by default have access to the directory /home/john/
 
Old 11-21-2009, 08:23 AM   #15
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,466

Original Poster
Blog Entries: 6

Rep: Reputation: 51
No I tried changing the code ..
No Help..Same Error.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Errors installing Q, which is needed for Lex, which is needed for PHP Virtuality Linux - Software 1 05-29-2007 04:47 PM
PHP5 Upgrade Error: Missing Dependency: php = 4.3.x is needed by package php-pear vsystems Linux - Server 1 05-02-2007 07:17 AM
Needed Help in PHP essoft478 Programming 1 05-21-2005 12:31 PM
PHP help needed. BigFred Programming 3 10-09-2003 01:07 AM
OS X PHP mysql help needed iJasonT Linux - Software 1 05-04-2003 09:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration