Jump to content

[SOLVED] Displaying GD Images Inline Help


Wes1890

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.