可能重复:
参考-这个错误在PHP中意味着什么?
我有如下PHP
代码:
<?php
$PMTA = $_GET['PMTA'];
//Get current date
$date = date('Y-m-d');
// Declare variables
$chart = array();
$title = "";
$domain = "";
$total = array();
$fail = array();
$cate = array();
$orderChart = array();
$container ="";
$dormain_str = array();
// End declare variable
//Use switch for getting the text files
switch($PMTA){
case 1:
if(file_exists('../pmta/stats_domain_emetteur_recepteur.unitead.info.'.$date.'.txt'))
{
$file = '../pmta/stats_domain_emetteur_recepteur.unitead.info.'.$date.'.txt';
}
else
{
$file = 'file_exits/stats_domain_sender_blank.txt';
}
break;
case 2:
if(file_exists('../pmta/stats_domain_emetteur_recepteur.frdcrp.com.'.$date.'.txt'))
{
$file = '../pmta/stats_domain_emetteur_recepteur.frdcrp.com.'.$date.'.txt';
}
else
{
$file = 'file_exits/stats_domain_sender_blank.txt';
}
break;
case 3:
if(file_exists('../pmta/stats_domain_emetteur_recepteur.affinitead.net.'.$date.'.txt'))
{
$file = '../pmta/stats_domain_emetteur_recepteur.affinitead.net.'.$date.'.txt';
}
else
{
$file = 'file_exits/stats_domain_sender_blank.txt';
}
break;
case 4:
if(file_exists('../pmta/stats_domain_emetteur_recepteur.switchcall.com.'.$date.'.txt'))
{
$file = '../pmta/stats_domain_emetteur_recepteur.switchcall.com.'.$date.'.txt';
}
else
{
$file = 'file_exits/stats_domain_sender_blank.txt';
}
break;
case 5:
if(file_exists('../pmta/stats_domain_emetteur_recepteur.unitead.eu.'.$date.'.txt'))
{
$file = '../pmta/stats_domain_emetteur_recepteur.unitead.eu.'.$date.'.txt';
}
else
{
$file = 'file_exits/stats_domain_sender_blank.txt';
}
break;
}
// Open the file and read data
$files = fopen($file,'r');
// Start i = 0
$i = 0;
// Check for the end of file has been reached,if have any error or end of file it will return true, other will return false
while(!feof($files)){
// It breaks the string in file that seperate by ; into array, so $data will become an array
$data = explode(";",fgets($files));
// Determind wheather the data is not empty or not
if(!empty($data[6])){
$domain = $data[6];
if(!empty($_POST['txt_order_blue'])){
$orderChart[$domain][] =array("success" => (100 - $data[9]),"fail" =>(float)$data[9],"cate" => $data[5]);
}
// Else if click on button order by % failed
else{
$orderChart[$domain][] =array("fail" =>(float)$data[9],"success" => (100 - $data[9]),"cate" => $data[5]);
}
$i++;
}
}
?>
当我在本地运行时,它运行良好,但当我在服务器上运行时,会显示消息
[Thu Dec 27 09:12:37 2012] [error] [client 103.23.136.12] PHP Warning: feof() expects parameter 1 to be resource, boolean given in /home/uniteadpro/www/kama/stats/unitead_chart/bar_chart_ratio_recepteur_emetteur.php on line 89
和
[Thu Dec 27 09:12:37 2012] [error] [client 103.23.136.12] PHP Warning: fgets() expects parameter 1 to be resource, boolean given in /home/uniteadpro/www/kama/stats/unitead_chart/bar_chart_ratio_recepteur_emetteur.php on line 90, referer: http://www.unitead.pro/kama/stats/unitead_chart/
在日志文件中
我不知道怎么解决这个问题。
文件"file_exits/stats_domain_sender_blank.txt"是否与"bar_chart_ratio_cepter_emetteur.php"位于同一位置。
我想你的两个文件一定在"/home/uniteadpro/www/kama/stats/unitead_chart/"位置。对于第二个错误,只需删除while循环。