drllqg2903 2016-04-04 22:01
浏览 113
已采纳

TCPDF服务器500错误 - 想要PHP中的详细错误

I've been trying to set up this php pdf script. I downloaded the code from the website and uploaded it as is from this page [https://sourceforge.net/projects/tcpdf/files/][1]

It works until the line that starts $pdf - I added echo $filename line to see if I could see errors (an idea found on this website - the page displays 1hello - I gather this probably means the require_once works OK.

    <?
// Include the main TCPDF library (search for installation path).
$filename = require_once('../tcpdf/examples/tcpdf_include.php');

echo $filename.'hello';
exit;
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false, true);

etc. etc.

If I remove $filename = and the echo / exit line (below) I get a generic server 500 error - any ideas how to get a detailed error I can actually use? I can see detailed errors on other pages.

    <?
// Include the main TCPDF library (search for installation path).
require_once('../tcpdf/examples/tcpdf_include.php');

// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false, true);

etc. etc.

EDIT: Found the error by adding ini_set('display_errors', 1); to the page - the error is Fatal error: Class 'TCPDF' not found...on line 31

Line 31 refers to:

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

If I look in the tcpdf_include.php include file it says some code that refers to some files I don't think my server has:

$tcpdf_include_dirs = array(
realpath('../tcpdf.php'),
'/usr/share/php/tcpdf/tcpdf.php',
'/usr/share/tcpdf/tcpdf.php',
'/usr/share/php-tcpdf/tcpdf.php',
'/var/www/tcpdf/tcpdf.php',
'/var/www/html/tcpdf/tcpdf.php',
'/usr/local/apache2/htdocs/tcpdf/tcpdf.php' );

/usr/share/php/ is empty. I'm guessing I should put the tcpdf.php file in all of those locations or does it not matter & I'm missing the point?

  • 写回答

2条回答 默认 最新

  • doupinge9055 2016-04-04 23:24
    关注

    You can find detailed 500 server error in your web server (Apache?) logs. The location of logs depends of your OS/installation.

    You gather fine: 1hello means that the required file is loaded correctly. You don't need to check it, because if require/require_once fails, you get a Fatal Error, and the script dies.

    If you can track down server error logs, probably you will see something like:

    Fatal error: Class 'TCPDF' not found

    because tcpdf/examples/tcpdf_include.php is intended to be used with provided examples, and it works correctly only if the main URL (or the current directory, if you execute the script via commandline) is in the same directory.

    To load TCPDF class, you have to

    require_once( '../tcpdf/tcpdf.php' );
    

    but I suggest you to indicate absolute path.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记