file_put_contents无法打开流:没有这样的文件或目录

时间:2017-03-20 14:01:43

标签: php-5.6

我创建了一个需要通过file_put_contents创建另外两个文件的php文件。运行此代码时,无法创建lastinsert.txt和newinsert.txt的问题。我改变了这些文件的路径,但我遇到了同样的问题。我尝试在我的网络存储库下手动创建文件,它工作正常。 这是我的代码:

function sendPushNotification($registration_ids, $message) {

$url = 'https://android.googleapis.com/gcm/send';
$fields = array(
    'registration_ids' => $registration_ids,
    'data' => $message,
);

define('GOOGLE_API_KEY', 'AIzaSyC36gV0pWJgP61mS0JYHadTB66Lz92_1RU');

$headers = array(
    'Authorization:key=' . GOOGLE_API_KEY,
    'Content-Type: application/json'
);
echo json_encode($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));

$result = curl_exec($ch);
if($result === false)
    die('Curl failed ' . curl_error());

curl_close($ch);
return $result;

     }

  echo $crc1=(int)file_get_contents('http://mywebsite/public_html/CodeIgniter/lastinsert.txt');

     $pushStatus = '';
   $querycount="SELECT id_relation FROM relations ORDER BY id_relation DESC LIMIT 1";

     if($query_run= mysqli_query($querycount)){
    while($query_rowcount = mysql_fetch_row($query_run)) {
     $res=print_r($query_rowcount[0]);

    file_put_contents("http://mywebsite/public_html/CodeIgniter/lastinsert.txt",$query_rowcount[0]);


   echo $crc2= (int)file_get_contents('http://mywebsite/public_html/CodeIgniter/lastinsert.txt' );


   if($crc1!="" && $query_rowcount[0]>$crc1){

$queryres="SELECT distinct push.title as 'title' from relations join etablissement push on ref_local=push.id where id_relation>".$crc1."";
if($query_run1= mysqli_query($queryres)){
        $gcmMylocation = array();

    while($query_row1 = mysql_fetch_array($query_run1)) {
        $gcmMylocation[]=$query_row1['title'];


       $result=print_r($query_row1);

foreach ($gcmMylocation as $value) {

  echo  $query = "SELECT regId FROM users where company='".$value."'";

if($query_run = mysqli_query($query)) {

    $gcmRegIds = array();
    while($query_row = mysql_fetch_assoc($query_run)) {

        array_push($gcmRegIds, $query_row['regId']);
        //$res=print_r($query_row);

    }

}

      etablissement push on ref_relation=push.id join etablissement mypush on ref_local=mypush.id where id_relation>857 and mypush.title='maison' order by ref_local";




        echo $query_title="SELECT push.title as 'title' from relations join etablissement push on ref_relation=push.id join etablissement mypush on ref_local=mypush.id where id_relation>".$crc1." and mypush.title='".$value."'";


if($query_run_tit= mysqli_query($query_title)){
            while($query_row_tit = mysql_fetch_array($query_run_tit)) {
        $gcmMylocationtit[]=$query_row_tit['title'];

foreach ($gcmMylocationtit as $valuetit) {

$pushMessage=$valuetit;
 if(isset($gcmRegIds)) {

    $message = array('m' => $pushMessage);
    $pushStatus = sendPushNotification($gcmRegIds, $message);

}
 }
     }
     }
        }
      }
    }
     }
      }
     file_put_contents("http://mywebsite/public_html/CodeIgniter/newinsert.txt",$query_rowcount[0]);

    }

0 个答案:

没有答案