--- kihmera_morgain <[EMAIL PROTECTED]> wrote:

> that doesnt really help my issue :x i never have white space before or
> after my opening/closing php tags :x what I need is the code for
> changing the browser output code into something that allows me to
> store the image and call it up in a variable on the page.. right now
> if i try to call it up, it just does a browser output instead.. and
> thats not what im looking for

The code which generates images cannot be mixed into a PHP program which
creates text output (ie HTML).  Instead, you use a standard <img> tag with a
src value which points to your PHP script.

<img src='script.php'>

If it were as simple as putting the binary image data into a variable, you
could do so with the output buffering (ob_*) functions.  However, this won't
work for the reasons I mentioned.  A browser is basically expecting a file to
be a certain type (ie text/html) and as those lines are processed, other MIME
types can be processed.

It sounds like your concern is that you do not want to calculate the image each
page request.  The way to accomplish this is to use the "filename" parameter of
the imagepng function and call it once.  The place where you save the file has
to be writeable by PHP (typically the webserver user).

http://php.net/imagepng

The whitespace (or any content at all) before and after the PHP tags comes up
quite a bit on beginner applications which make use of HTTP headers like this
one.  A problem in this area will generate a PHP error complaining that the
headers could not be written because they had already been sent.  It is easily
one of the top 5 errors related to code posted to this board.

James

Reply via email to