2014-04-18 20 views
1

第一個錯誤的錯誤:嚴格的標準:只有變量應該通過參考/home/user/public_html/ref/hhhhh_hhhhh/index.php第15行遇到了下列行

通過點擊提交按鈕後:

警告:無法修改標頭信息 - /home/user/public_html/ref/hhhhh_hhhhh/index.php中已由(位於/home/user/public_html/ref/hhhhh_hhhhh/index.php:3處開始的輸出)發送的標頭在線28

<?php  
require_once 'jsonRPCClient.php'; 
$api_key = 'apikey'; 
$api_url = 'url'; 
$client = new jsonRPCClient($api_url); 
$campaigns = $client->get_campaigns(
    $api_key, 
    array (
     # find by name literally 
     'name' => array ('EQUALS' => 'test') 
    ) 
); 
$CAMPAIGN_ID = array_pop(array_keys($campaigns)); 
if(isset($_POST['submit'])) 
{ 
    $result = $client->add_contact(
    $api_key, 
    array (
     'campaign' => $CAMPAIGN_ID, 
     'name'  => 'Test', 
     'email'  => '[email protected]', 
    ) 
    ); 
$cid = "infod"; 
$site_url = $cid.".pokemon.com";  
header("Location: http://$site_url") ; 
} 

?> 
+0

由於'E_STRICT'是您的默認'error_reporting'的一部分,因此您需要將php.ini修改爲error_reporting = E_ALL&〜E_NOTICE&〜E_STRICT'以進行錯誤報告。 – Ohgodwhy

+0

@Ohgodwhy,好吧,我模糊了那部分。你有回答@。@? – user3546239

+0

我剛纔說什麼答案是解決嚴格的標準。你的'不能修改標題信息'是因爲你的空白空間被返回到某處的瀏覽器,並且導致了這種情況。 – Ohgodwhy

回答

0

我從你看過的評論中看到嚴格的錯誤報告婷關 - 這不是一個很好的事情 - 基本上你只是被隱藏了真正的錯誤,你現在得到了一個空白頁面,並沒有錯誤,幫助你...

的第一個錯誤:

Only variables should be passed by reference in 
/home/user/public_html/ref/hhhhh_hhhhh/index.php on line 15 

表示您正在調用一個函數並通過引用傳遞一個非變量。 '按引用傳遞'意味着函數獲取對原始變量(而不是副本)的引用,並且可以對其進行修改,以便對可在調用代碼中看到的變量進行更改。

所以,哪來的錯誤,以及15行看起來是這樣的:

$result = $client->add_contact(
    $api_key, 
    array (
     'campaign' => $CAMPAIGN_ID, 
     'name'  => 'Test', 
     'email'  => '[email protected]', 
    ) 
); 

我猜,這add_contact通過引用以第二個參數的定義(不知道爲什麼)和你沒有給它一個「真正的」變量來處理,因爲你基本上構建了一個會被拋棄的臨時數組。

先嚐試構建陣列:

$camp_arr = array (
    'campaign' => $CAMPAIGN_ID, 
    'name'  => 'Test', 
    'email'  => '[email protected]', 
); 

$result = $client->add_contact($api_key, $camp_arr); 

您可能還希望(以後)看看$ camp_arr內容,看看發生了什麼。

你的第二個錯誤意味着頭已經發送,這是因爲您在調用header,之前只要你發短信的頭被髮送,你不能重新發送它們已經輸出一些文字 - 這幾乎是肯定是由錯誤消息引起的,它將計算爲輸出文本並導致頭文件被髮送。請注意,另一個常見原因是在<?php ... ?>塊之外有文本或空白。

+0

現在我有這個錯誤, 解析錯誤:語法錯誤,意外的'$ CAMPAIGN_ID'(T_VARIABLE)在/home/user/public_html/ref/hhhhh_hhhhh/index.php 13行 – user3546239

+0

你有一個語法錯誤的地方 - 檢查你的分號和括號在此之前是一致的。 – SpaceDog