Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
No PHP output at all on large generated GIF files
Old 02-14-2008, 09:19 AM No PHP output at all on large generated GIF files
Junior Talker

Posts: 3
Trades: 0
Hi

I am trying to make an php script that would make me an nice animated GIF image, with variable texts scrolling all over the image and random photos on background each time the script is executed.

The problem is that there is absolutely no output from PHP when the generated GIF size is over ~500KB. This only happens on my localhost (apache 2.2.8/WINDOWS 2000 SP4 and PHP 5.2.5). On an free webhosting service i tried, the script works perfectly (but it is too slow for me to develop the application, i prefer localhost).

I am researching this issue for over two days now and have pinned-out the problem and made an simple test script that demonstrates the problem on my localhost:
PHP Code:
<?
$i
=0;
$x=array();
header("Content-type:text/plain");
while(
$i<4000)
{
    
array_push($x,"ABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCD\n");
    
$i++;
}
$i=0;
$test=null;
while(
$i<4000)
{
    
$test.=$x[$i];
    
$i++;
}
echo(
"YOU WILL SEE NOTHING IF LEN IS ABOVE ~500000 BYTES!!\n\n");
echo(
substr($test,0,((is_numeric($_GET['len']) && $_GET['len']>0)?$_GET['len']:strlen($test))));
echo(
"\n\nYOU WILL SEE NOTHING IF LEN IS ABOVE ~500000 BYTES!!");
?>
the method of building my gif animation is the very same as in the sample script. First, a image resource is allocated. Each frame is drawn on this resource in a loop, with every frame data stored into an ARRAY by the means of ob_start and imagegif. Then the animated gif is constructed step-by-step from separate gif frames and its data are held in a string variable $gifdata. Everything is fine when i try to output like this:
PHP Code:
echo(substr($gifdata,0,500)); 
or like this
PHP Code:
echo(substr($gifdata,0,500000)); 
but if i pass certain value here, the script wont return absolutely nothing.
....so, if generated gif is bigger than this certain value, this will fail:
PHP Code:
echo($gifdata); 
bringing down the WHOLE script, it does not matter if there are echoes before or after this line, simply said if $gifdata is large and the php program contains a line to print $gifdata out, or to var_dump it or anything like that, the while php program wont return nothing.

Error reporting in php.ini on my localhost is set to E_ALL and memory limit for script is 128MB.

Here is the script running on my computer:
http://78.98.181.169/test/test2.php?len=ENTER-NUMBER

for comparison, here is the exact same script running on the free webhosting server and WORKING:
http://goosemaster.ic.cz/test/test2....n=ENTER-NUMBER

Maybe just some apache/php misconfiguration, i am really desperate with this one. Any help would be very appreciated.

...and just for fun the animated gif
working (notice the image size is only 589 kb, so $gifdata is also only 589kb, thats the only thing print out) and not working (on localhost)

Last edited by kbs1; 02-14-2008 at 09:20 AM..
kbs1 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-15-2008, 12:58 PM Re: No PHP output at all on large generated GIF files
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
Ask your host you edit the PHP configuration file under the memory limit. Most likely as they are a free host they don't like sharing too much RAM

Though, for bandwidth and CPU reasons I would recommend you don't let the server build the gif for you, unless it's whats intended for the site in question.
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE

Last edited by rogem002; 02-15-2008 at 12:59 PM..
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 02-16-2008, 05:32 AM Re: No PHP output at all on large generated GIF files
Junior Talker

Posts: 3
Trades: 0
yes, i was thinking of building one static gif too, but the customer wants the banner (this gif will be the main logo) to display four newest photos from the gallery, and add the gallery name and some scrolling text to it, so my hands are tied here.

however the problem is not only the gif, but whole php configuration on my pc, not on the free host, there it works fine(despite their 8MB menory limit, i have 128MB limit)

if i do this
PHP Code:
echo($this_is_BIG); 
the whole response from my machine (127.0.0.1) is 0 bytes, nothing, no error message. test script in my first post illustrates this problem perfectly. i really dont know what i am missing here
kbs1 is offline
Reply With Quote
View Public Profile
 
Old 02-20-2008, 09:41 AM Re: No PHP output at all on large generated GIF files
Junior Talker

Posts: 3
Trades: 0
please...anybody?? no one ever encountered this?

updated ip on my machine:
http://78.98.177.173/test/test2.php?len=ENTER-NUMBER

Last edited by kbs1; 02-20-2008 at 09:42 AM..
kbs1 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to No PHP output at all on large generated GIF files
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.56876 seconds with 12 queries