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
https://forums.phpfreaks.com/topic/224875-file-reading-error-im-guessing/
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;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.