Wes1890 Posted October 17, 2007 Share Posted October 17, 2007 I've created a script that allows someone to create an Image using variables that they define. After filling out the fields, they click preview. And it all works! ...except for 1 thing. I want to be able to generate the image with PHP and display it within the same page as the form (right below it), but when the user clicks preview, it shows nothing on the page, except the image. Heres my sample code: ........... // output the image header("Content-type: image/png"); imagepng($image); imagedestroy($image);...... With or without the imagedestroy function does the same thing... any help? Im runnin php5 if that makes a difference. Quote Link to comment https://forums.phpfreaks.com/topic/73708-solved-displaying-gd-images-inline-help/ Share on other sites More sharing options...
MadTechie Posted October 17, 2007 Share Posted October 17, 2007 thats code will have to be in another php script and your need to call it like an image.. ie <img src="GDStuff.php?id=12"> now the id = 12 tell that script where to get the details to draw that image.. i hope that helps Quote Link to comment https://forums.phpfreaks.com/topic/73708-solved-displaying-gd-images-inline-help/#findComment-371932 Share on other sites More sharing options...
Wes1890 Posted October 17, 2007 Author Share Posted October 17, 2007 Thanks for the reply.. but I'm wanting that method to be a last resort because I don't want a user to be able to set the image vars in the url. I have it set to where when the user saves the image, it generates a code (IE: 5555) and inserts a new row in the Image DB with the image's var details (colors and whatnot).. so when someone want to see the image, they run ..../image/5555.png (which is actually img.php?id=5555.png). The script then gets the info from the DB and displays the correct image. Do you think this would bog down my bandwidth bad? Anyways, i want it to preview, without saving to the DB... so is there a way to generate the image and display it like I explained above? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/73708-solved-displaying-gd-images-inline-help/#findComment-371940 Share on other sites More sharing options...
MadTechie Posted October 17, 2007 Share Posted October 17, 2007 okay.. what about setting a $_SESSION['GDCode']..and the GDimage.php read that instead? Quote Link to comment https://forums.phpfreaks.com/topic/73708-solved-displaying-gd-images-inline-help/#findComment-371953 Share on other sites More sharing options...
Wes1890 Posted October 17, 2007 Author Share Posted October 17, 2007 ^ Hey man good thinking... ill try it out Quote Link to comment https://forums.phpfreaks.com/topic/73708-solved-displaying-gd-images-inline-help/#findComment-371990 Share on other sites More sharing options...
Wes1890 Posted October 18, 2007 Author Share Posted October 18, 2007 Ok, I set the session, working good. But.. here's my code for extracting the VARS from the SESSIONdata and using it: if ( isset($_GET['preview']) ) // If we're previewing an image { // Get the vars with an atom bomb $preview = explode(";",$_SESSION['img_preview']); $styleid = $preview[0]; $bgcolor = $preview[1]; $fcolor = $preview[2]; $string = $preview[3]; } else // If we're LOADING A SAVED IMAGE { //-------------// //* We're In! *// //-------------// // Get IMG ID $img_id = substr($_GET['img'], 0, -4); // Get it out of the DB $sql = "SELECT * FROM images WHERE img_id=".$img_id." LIMIT 1"; $result = mysql_query($sql); $img = @mysql_fetch_array($result); //--------------// //* Load image *// //--------------// $styleid = $img['img_style']; $bgcolor = $img['img_bgcolor']; $fcolor = $img['img_fcolor']; $string = $img['img_string']; } // Get Style Settings Frm DB $sql = "SELECT * FROM styles WHERE style_id=$styleid LIMIT 1"; $result = mysql_query($sql) or die("Couldnt get the style information...<br />".mysql_error()); $stylerow = mysql_fetch_array($result); I keep getting this error: Couldnt get the style information... You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 1 btw, the session reads: 1;ffffff;000000;wes Why am i getting this error? Quote Link to comment https://forums.phpfreaks.com/topic/73708-solved-displaying-gd-images-inline-help/#findComment-372014 Share on other sites More sharing options...
Wes1890 Posted October 18, 2007 Author Share Posted October 18, 2007 GOT IT! I wasn't calling session_start() in the seperate img generator file.. Im such a retard.. thanks for the good idea.. it's working now Quote Link to comment https://forums.phpfreaks.com/topic/73708-solved-displaying-gd-images-inline-help/#findComment-372031 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.