digi duck Posted March 29, 2007 Share Posted March 29, 2007 Hi I have a script that lets users pick an image and add text to it using this php script: <?php header("Content-type: image/jpeg"); $name = stripslashes($_GET['name']); $size = stripslashes($_GET['size']); $centre = stripslashes($_GET['centre']); $font = 'images/sig_maker/fonts/'.stripslashes($_GET['font']).'.ttf'; $fontcolor['r'] = stripslashes($_GET['color_r']); // font color - RED $fontcolor['g'] = stripslashes($_GET['color_g']); // font color - GREEN $fontcolor['b'] = stripslashes($_GET['color_b']); // font color - BLUE $lines = stripslashes($_GET['lines']); function arrow($im, $x1, $y1, $x2, $y2, $alength, $awidth, $color){ /// } if(is_numeric($_GET['color']) && $_GET['color'] >= '1' && $_GET['color'] <= '54') { $bgpic = 'images/sig_maker/' . $_GET['color'] . '.jpeg'; } $im = imagecreatefromjpeg($bgpic); //Calculate, the centre: for(;{ list($image_width, $image_height) = getimagesize($bgpic); list($left_x, , $right_x) = imagettfbbox($size, 0, $font, $name); $text_width = $right_x - $left_x; if($image_width > $text_width+5){ break; } $size = $size - .5; if($size == 1){ die('Script not responding to decreasing font size, in other words: try using less letters.'); } } $hpadding = ($image_width - $text_width)/2; $vpadding = ($image_height/2); $textcolor = imagecolorresolve($im, $fontcolor['r'], $fontcolor['g'], $fontcolor['b']); if($centre== 'y'){ imagettftext($im, $size, 0, $hpadding,$vpadding, $textcolor, $font, $name); }else{ imagettftext($im, $size, $angle, $x, $y, $textcolor, $font, $name); } imagegif($im); imagedestroy($im); ?> This works fine, however I want to automatically save each image that is created to a Mysql table and show the last 5 images created. I dont want to keep the images stored in the Mysql forever, just until 5 new sigs have been created. I have very basic knowledge of php and no knowledge of Mysql except a few tutorials i have read. So far i have created a table called sig and have fields in it that the image uses (i.e. $name, $font, $size etc and an ID field with increment set to 0??? and also primary?) I did this because when you create an image the url looks like this... http://gamesigs.co.uk/testgenerator.php?color=25&name=your+text+here¢re=y&x=2&y=30&angle=0&font=unreal&size=25&select=255%2C255%2C255&color_r=255&color_g=255&color_b=255&submit=Create+My+Sig%21 and i thought if i could save these variables when a user submits the form it could work. Any way I'm completely clueless By the way if you want to see my site here's the address: www.gamesigs.co.uk PLEASE HELP!!! Digi. Quote Link to comment Share on other sites More sharing options...
digi duck Posted March 29, 2007 Author Share Posted March 29, 2007 ok i have had an attempt but it aint worked. can you tell me why? <?php $user="joshuacottom_db"; $password=" "; $database="joshuacottom_db"; $color=$_POST['color']; $name=$_POST['name']; $centre=$_POST['centre']; $size=$_POST['size']; $x=$_POST['x']; $y=$_POST['y']; $angle=$_POST['angle']; $font=$_POST['font']; $color_r=$_POST['color_r']; $color_g=$_POST['color_g']; $color_b=$_POST['color_b']; mysql_connect('db4.awardspace.com','joshuacottom_db',' '; @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO sig VALUES ('','color','$name','$centre','$size','$x','$y','$angle','$font','','$color_r','$color_g','$color_b')"; mysql_query($query); mysql_close(); //End of database stuff header("Content-type: image/jpeg"); $name = stripslashes($_GET['name']); $size = stripslashes($_GET['size']); $centre = stripslashes($_GET['centre']); $font = 'images/sig_maker/fonts/'.stripslashes($_GET['font']).'.ttf'; $fontcolor['r'] = stripslashes($_GET['color_r']); // font color - RED $fontcolor['g'] = stripslashes($_GET['color_g']); // font color - GREEN $fontcolor['b'] = stripslashes($_GET['color_b']); // font color - BLUE $lines = stripslashes($_GET['lines']); function arrow($im, $x1, $y1, $x2, $y2, $alength, $awidth, $color){ /// } if(is_numeric($_GET['color']) && $_GET['color'] >= '1' && $_GET['color'] <= '54') { $bgpic = 'images/sig_maker/' . $_GET['color'] . '.jpeg'; } $im = imagecreatefromjpeg($bgpic); //Calculate, the centre: for(;{ list($image_width, $image_height) = getimagesize($bgpic); list($left_x, , $right_x) = imagettfbbox($size, 0, $font, $name); $text_width = $right_x - $left_x; if($image_width > $text_width+5){ break; } $size = $size - .5; if($size == 1){ die('Script not responding to decreasing font size, in other words: try using less letters.'); } } $hpadding = ($image_width - $text_width)/2; $vpadding = ($image_height/2); $textcolor = imagecolorresolve($im, $fontcolor['r'], $fontcolor['g'], $fontcolor['b']); if($centre== 'y'){ imagettftext($im, $size, 0, $hpadding,$vpadding, $textcolor, $font, $name); }else{ imagettftext($im, $size, $angle, $x, $y, $textcolor, $font, $name); } imagegif($im); imagedestroy($im); //show info $username="joshuacottom_db"; $password=" "; $database="joshuacottom_db"; mysql_connect('db4.awardspace.com','joshuacottom_db',' '); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM sig"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Last Signature</center></b><br><br>"; $i=0; while ($i < $num) { ?> <imgsrc="http://gamesigs.co.uk/testcreation.php?<? echo" $color=mysql_result($result,$i,"color");&$name=mysql_result($result,$i,"name");&$centre=mysql_result($result,$i,"centre");&$size=mysql_result($result,$i,"size");&$x=mysql_result($result,$i,"x");&$y=mysql_result($result,$i,"y");&$angle=mysql_result($result,$i,"angle");&$font=mysql_result($result,$i,"font");&$color_r=mysql_result($result,$i,"color_r");&$color_g=mysql_result($result,$i,"color_g");&$color_b=mysql_result($result,$i,"color_b")";?>" alt="the last sig created" <? $i++; } mysql_close(); ?> Quote Link to comment Share on other sites More sharing options...
fenway Posted April 4, 2007 Share Posted April 4, 2007 How is this a MYSQL issue? Quote Link to comment 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.