debug Posted April 2, 2009 Share Posted April 2, 2009 Hi- Yesterday I wrote a quick script to generate an image using the GD graphics library and it works great however now when I try to put the code into a Div tag I'm getting a error stating that the header has already been set and then it churns out a load of garbage (which I assume is the png file in its raw format). any ideas how I could embed my generated image into a div tag? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/152229-generated-images-within-div-tag/ Share on other sites More sharing options...
Adam Posted April 2, 2009 Share Posted April 2, 2009 If you look in the PHP that generates your image, you should see a line similar to: header("Content-Type: image/png"); This is defining the content type as an image, half way through the file, which obviously the surrounding HTML is definitely not. You need to include the generated image externally, which you can do using the HTML <img> tag, like so: <img src="gen_img.php" alt="" /> Just place the PHP that generates the image within the "gen_img.php" file (or whatever you wish to call it). By the way this isn't a JavaScript problem... Adam Quote Link to comment https://forums.phpfreaks.com/topic/152229-generated-images-within-div-tag/#findComment-799465 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.