2016-04-29 84 views
0

您好,我有將文件保存到數據庫的cron作業。當cron作業工作時,它將文件保存到根目錄。我不明白爲什麼它會保存文件。比我從godaddy問。他們告訴我這不是服務器問題,請檢查您的代碼。可以停止保存文件嗎?在我的代碼是:cron作業將文件保存在根目錄

<?php 
header('Content-type: text/plain; charset=utf-8'); 
require_once "lib/connect.php"; 
if(isset($_GET['page_id'])){ 

function savezar1($name,$video) { 
     $sql = "INSERT INTO videos (`video` , `name`,`yes`)  
      VALUES ('$video', '$name','1')"; 
    mysql_query($sql)or die ("MySQL Error :".mysql_error()); 

     } 



$page_id = $_GET['page_id']; 
$access_token = 'facebook access token'; 

$json_object = @file_get_contents('https://graph.facebook.com/' . $page_id . 
'/feed?access_token=' . $access_token); 

    $fbdata = json_decode($json_object); 


foreach ($fbdata->data as $post) 
{ 
    $content=$post->message; 
    $title=$content; 
    $title=strip_tags($title); 
    $title=trim($title); 
    $title=mysql_real_escape_string($title); 
    $l=$post->id; 
    $q=explode("_", $l); 
    $l='<div id="fb-root"></div><script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3"; fjs.parentNode.insertBefore(js, fjs);}(document, "script", "facebook-jssdk"));</script><div class="fb-video" data-allowfullscreen="1" data-href="https://www.facebook.com/'.$q[0].'/videos/'.$q[1].'/"><div class="fb-xfbml-parse-ignore"><blockquote cite="https://www.facebook.com/'.$q[0].'/videos/'.$q[1].'/"><a href="https://www.facebook.com/'.$q[0].'/videos/'.$q[1].'/"></a><p>'.$title.'</p></blockquote></div></div>'; 


$video=htmlspecialchars($l, ENT_QUOTES); 


$rsurl=isHaveUrl($title); 

    if($rsurl==0) 
{ 
    savezar1($title,$video); 

    } 



     } 




    } 
     ?> 

回答

0

編輯: 你可以找到你的答案在這裏

Cron job creating empty file each time it runs

也將其保存到數據庫中正確與否?

+0

是保存正確。你認爲如何解決編碼isue? php會像俄文單詞一樣保存cr cr。 – ganaa

+0

看看編輯答案 –