Jump to content

File reading error I'm guessing...


gergy008

Recommended Posts

function GetStatus(){
$fd=read_file('s_status.sta');
list($perf, $msg, $rest) = explode('\n', $fd, 3);
if(isset($perf) && isset($msg)){
	return '<p class="status"><img src="/images/sta/'.$perf.'.png" /> $msg</p>';
} else {
	return '';
}
}

 

Hi everyone, Thanks for reading.

 

I'm having a problem with my script, I would love to know why it's just stopping parsing and no errors are getting diplayed when I call this function. I'm using E_ALL, Highly annoying when still no errors come up... When the function is called the page stops parseing, The function returns nothing.

 

The files content does like this:

 

ERROR
This is an error

Som other stuff I don't need hence $rest in the explode

As you can tell it's a status file I checked the contents and it's all in the right format.  :shrug:

 

Thanks in advance!

Link to comment
Share on other sites

Not sure what other problems there may be, but read_file() just outputs the file to the browser.  You probably want file_get_contents().  Also read on single versus double quotes.  '\n' should be "\n".

 

Thanks, I forgot to mention that read_file() is a custom function

 

function read_file($filename) {
  $f=fopen($filename,"r");
  $data=fread($f,filesize($filename));
  fclose($f);  
  return $data;
}

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.