gpt4 book ai didi

PHP - imagepng 无法正常工作

转载 作者:可可西里 更新时间:2023-11-01 13:47:14 26 4
gpt4 key购买 nike

各位,首先,这是我的代码:

<?php

ob_start();

$pilot_id = $_GET['id'];

//-- Server Variables
$dbServer = 'localhost';
$dbUser = 'root';
$dbPassword = '*************';
$dbName = 'bla_tracker';

//-- Server Connection >>> DO NOT CHANGE <<<
$sql = mysql_connect("$dbServer", "$dbUser", "$dbPassword") or die(mysql_error());
$select_db = mysql_select_db("$dbName", $sql);

$query = mysql_query("SELECT * FROM acars_users WHERE `id`='".$pilot_id."' ") or die (mysql_error());
$row = mysql_fetch_array($query);
$nome = $row['nome'];
$patente = $row['rank'];
$admin = $row['admin'];
$checador = $row['checador'];

$query_horas = mysql_query("SELECT SUM(flighttime) AS `total` FROM acars_pirep WHERE iduser='".$pilot_id."'") or die (mysql_error());
$row2 = mysql_fetch_assoc($query_horas);
$total_min = $row2['total'] + ($row['horas'] * 60);
$total = round($total_min/60);

if($admin == 1) {
$data = "Comandante Master - $nome";
} else {
if($checador == 1) {
$data = "Comandante Checador - $nome";
} else {
if($patente == '4') {
$data = "Comandante Sênior - $nome";
} else {
if($patente == '3') {
$data = "Comandante Instrutor - $nome";
} else {
if($patente == '2') {
$data = "Comandante - $nome";
} else {
if($patente == '1') {
$data = "Primeiro Oficial - $nome";
} else {
if($patente == '0') {
$data = "Copiloto - $nome";
}}}}}}}


$rand = rand(1, 8);

$my_img = imagecreatefrompng("images/background_$rand.png");
$background = imagecolorallocate($my_img, 0, 0, 255);
$text_colour = imagecolorallocate($my_img, 255, 255, 255);


imagettftext($my_img, 11, 0, 4, 12, $text_colour, "calibril.ttf", "$data");
imagettftext($my_img, 11, 0, 340, 12, $text_colour, "calibril.ttf", "$total hrs");
imagettftext($my_img, 11, 0, 4, 98, $text_colour, "calibril.ttf", "Brasil Linhas Aéreas");
imagettftext($my_img, 11, 0, 323, 98, $text_colour, "calibril.ttf", "voebla.com");

imagesetthickness ($my_img, 5 );


header("Content-type: image/png");
imagepng($my_img);
imagecolordeallocate( $text_color );
imagecolordeallocate( $background );
imagedestroy($my_img);

?>

我们更改了服务器,现在,我明白了:

enter image description here

发生了什么事?

编辑

将 PHP 错误设置为 ON,我收到此警告:

Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\vhosts\voebla.com\httpdocs\BLAtracker\sessoes\pilotos\modules\dados\assinatura\assinatura.php:1) in C:\Inetpub\vhosts\voebla.com\httpdocs\BLAtracker\sessoes\pilotos\modules\dados\assinatura\assinatura.php on line 68

在第 68 行我们有:

header( "Content-type: image/png" );

编辑 2

深入查看 assinatura.php,我发现了 PHP 标记之前的 BOM,但现在如何删除它?

enter image description here

最佳答案

找到了!!!

嗯! PHP标签之前有一个BOM。如何删除它,非常非常简单。我使用的是 Adob​​e Dreamweaver,所以步骤如下:

1 - 按 CTRL + J(页面属性);

2 - 转到标题/编码选项卡,取消选中“包括 Unicode 签名”复选框;

enter image description here

保存文档,奇迹发生了。不知道为什么我没有在其他服务器上收到此错误!


如果您不使用 Adob​​e Dreamweaver,Notepad++ 可以转换为没有 BOM(字节顺序掩码)的 UTF-8:

Notepad++: Convert to UTF-8 without BOM

关于PHP - imagepng 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23258010/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com