2013-07-31 52 views
0

薩拉姆每個人身體php內部服務器錯誤

我主持這個腳本在fatcow但它給我一個「內部服務器錯誤」。

下面是腳本:

<?php 
    create_image(); 
    exit(); 

    function create_image() 
    { 
     // Set the content-type 

     // Create the image 
     $im = imagecreatefrompng('coupon.png'); 
     // Create red color 
     $red = imagecolorallocate($im, 120, 20, 20); 
     //get font arail 
     $font = 'font/arial.ttf'; 
     // Insert variables into coupon 

     imagettftext($im, 36, 0, 176, 695, $red, $font, $_POST['Tdesc']); 
     imagettftext($im, 36, 0, 176, 985, $red, $font, $_POST['Tclient']); 
     imagettftext($im, 40, 0, 176, 1145, $red, $font, $_POST['Texpire']); 
     imagettftext($im, 42, 0, 176, 1355, $red, $font, $_POST['Toffre']); 

     imagettftext($im, 55, 0, 1796, 422, $red, $font, $_POST['Tcommande']); 
     imagettftext($im, 36, 0, 1488, 1000, $red, $font, $_POST['Tadresse']); 
     imagettftext($im, 36, 0, 1488, 1290, $red, $font, 'Tél. '. $_POST['Ttel']); 
     imagettftext($im, 60, 0, 1488, 1590, $red, $font, $_POST['Tvaleur']); 
     imagettftext($im, 60, 0, 1488, 1840, $red, $font, $_POST['Tcode']); 

     // Using imagepng() results in clearer text compared with imagejpeg() 
     imagepng($im); 
     imagedestroy($im); 

    } 
?> 

和錯誤消息:

內部服務器錯誤

服務器遇到一個內部錯誤或配置錯誤, 無法完成您的請求。

請與服務器管理員聯繫,並通知他們發生錯誤的時間爲 ,並且您可能已經完成的任何操作可能會導致該錯誤,其中包括 。

有關此錯誤的更多信息可能在服務器錯誤 日誌中可用。

+7

您的PHP日誌將在這裏有所幫助。 – vee

+0

同時檢查服務器日誌(即Apache等)。 –

+0

您是否嘗試先聲明函數然後調用它? –

回答

0

易於修復: - 只需反轉你的定義和呼叫;

<?php 

    function create_image() 
    { 
     // Set the content-type 

     // Create the image 
     $im = imagecreatefrompng('coupon.png'); 
     // Create red color 
     $red = imagecolorallocate($im, 120, 20, 20); 
     //get font arail 
     $font = 'font/arial.ttf'; 
     // Insert variables into coupon 

     imagettftext($im, 36, 0, 176, 695, $red, $font, $_POST['Tdesc']); 
     imagettftext($im, 36, 0, 176, 985, $red, $font, $_POST['Tclient']); 
     imagettftext($im, 40, 0, 176, 1145, $red, $font, $_POST['Texpire']); 
     imagettftext($im, 42, 0, 176, 1355, $red, $font, $_POST['Toffre']); 

     imagettftext($im, 55, 0, 1796, 422, $red, $font, $_POST['Tcommande']); 
     imagettftext($im, 36, 0, 1488, 1000, $red, $font, $_POST['Tadresse']); 
     imagettftext($im, 36, 0, 1488, 1290, $red, $font, 'Tél. '. $_POST['Ttel']); 
     imagettftext($im, 60, 0, 1488, 1590, $red, $font, $_POST['Tvaleur']); 
     imagettftext($im, 60, 0, 1488, 1840, $red, $font, $_POST['Tcode']); 

     // Using imagepng() results in clearer text compared with imagejpeg() 
     imagepng($im); 
     imagedestroy($im); 

    } 

    create_image(); 
    exit(); 
?> 

您應該還可以添加一個header調用來設置內容類型。

在未來,如果你有這樣那樣的錯誤,你也可以只添加:

if (isset($_GET["debug"])){ 
    ini_set("display_errors", "1"); 
    error_reporting(E_ALL); 
    } 

打印出任何錯誤 - 中頻是可選的;我在大部分文件中都有這個功能,所以我可以在網址中添加?調試,並在出現拼寫錯誤時立即查看問題。

0

檢查你的日誌,他們可能會證明是有用的。試着做一個PHP的信息頁面的代碼 -

<?php phpinfo(); ?> 

,並檢查PHP GD庫已安裝完畢。您也可以嘗試通過編輯您的php.ini文件或將這段代碼添加到您的文件中來讓頁面顯示錯誤。

ini_set('display_errors',1); 
ini_set('display_startup_errors',1); 
error_reporting(-1);