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 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条