Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Banalny problem z imagecolorallocate()
Forum PHP.pl > Forum > Przedszkole
PiNkOs
Witam,

Mam dosyć dziwny problem z uruchomieniem tego skryptu:

  1. <?php
  2. $im = imagecreate(100, 100) or die("Błąd! Identyfikator błędu: #01");
  3. $bg = imagecolorallocate($im, 255, 0, 0) or die("Błąd! Identyfikator błędu: #02");
  4. ?>


Wyświetla mi: Błąd! Identyfikator błędu: #02, a powinno wyświetlić kwadrat 100x100 w kolorze czerwonym

Jeżeli chodzi o bibliotekę GD na serwerze:

GD Version: bundled (2.0.28 compatible)
FreeType Support: Enabled
FreeType Linkage: with freetype
T1Lib Support: Enabled
GIF Read Support: Enabled
GIF Create Support: Enabled
JPG Support: Enabled
PNG Support: Enabled
WBMP Support: Enabled
XBM Support: Enabled
JIS-mapped Japanese Font Support: Disabled
zordon
  1. header ('Content-type: image/png');
  2. $im = imagecreate(100, 100) or die("Błąd! Identyfikator błędu: #01");
  3.  
  4. $bg = imagecolorallocate($im, 255, 0, 0);
  5.  
  6. $img = imagepng($im);


to już działa. nie jestem pewien, ale wydaje mi się, że przez zmianę w funkcji imagecollorallocate:
Changelog
Version Description
Prior to 5.1.3 Returns -1 if the allocation failed.

czyli po prostu funkcja zwraca ci 0, a kod błędu to -1
PiNkOs
THX, niby takie proste...
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.