gergy008 Posted January 18, 2011 Share Posted January 18, 2011 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. Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/224875-file-reading-error-im-guessing/ Share on other sites More sharing options...
AbraCadaver Posted January 18, 2011 Share Posted January 18, 2011 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". Link to comment https://forums.phpfreaks.com/topic/224875-file-reading-error-im-guessing/#findComment-1161498 Share on other sites More sharing options...
gergy008 Posted January 18, 2011 Author Share Posted January 18, 2011 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 https://forums.phpfreaks.com/topic/224875-file-reading-error-im-guessing/#findComment-1161514 Share on other sites More sharing options...
BlueSkyIS Posted January 18, 2011 Share Posted January 18, 2011 the code is first parsed, then executed. is it actually not parsing (you get parse errors)? or is it parsing but failing in the code during execution? does 's_status.sta' exist in the same directory as the script? Link to comment https://forums.phpfreaks.com/topic/224875-file-reading-error-im-guessing/#findComment-1161538 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.