2013-07-31 4 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); 
    } 

에 오류 인쇄하기 -을 선택하는 경우, 나는 내 파일의 대부분을 가지고 있기 때문에 URL에 디버그를 추가하고 오타 또는 뭔가를 만들면 즉시 문제를 볼 수 있습니다.

0

로그를 확인하면 유용 할 수 있습니다.

<?php phpinfo(); ?> 

을하고 PHP GD 라이브러리가 설치되어 있는지 확인 - 코드와 PHP 정보 페이지를 만들어보십시오. 또한 php.ini 파일을 편집하거나이 코드를 파일에 추가하여 오류를 표시하는 페이지를 만들 수도 있습니다.

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