I'm trying to use PHP to output text strings as images ( a security measure) in a loop.
It works fine for up to 10,000 iterations but throws the wretched 500 Internal Server Error when I try 20,000.

It's like there's a memory leak but I've pared the code back and still have no idea what's wrong.
Here's an example - can anyone else try it?
Note - I've removed the code that uses the csv.png file containing the text as an image

<?php


function OutputToDataURI($text) {
$im = imagecreate(550,18);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 550, 18, $white);
imagestring($im, 3, 1, 1, $text, $black);
$imgdata = "csv.png";
imagepng($im,$imgdata,0,NULL);
imagecolordeallocate($im,$white);
imagecolordeallocate($im,$black);
imagedestroy($im);
// do something with the file csv.png here
}

$n = 0;
While($n < 20000)
{
$n = $n+ 1;
echo "<br>$n";
$text = "Hello $n";
OutputToDataURI($text);
}


echo "<p>Done n= $n";
exit();


?>



#####################################################################################

This correspondence is for the named person's use only. It may contain confidential
or legally privileged information, or both. No confidentiality or privilege is waived
or lost by any mistransmission. If you receive this correspondence in error, please
immediately delete it from your system and notify the sender. You must not disclose,
copy or rely on any part of this correspondence if you are not the intended recipient.
Any views expressed in this message are those of the individual sender, except where
the sender expressly, and with authority, states them to be the views of Veda.
If you need assistance, please contact Veda on either :-
Australia customerassistance@xxxxxxxxxxx or New Zealand +64 9 367 6200

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.