deathadder Posted May 26, 2012 Share Posted May 26, 2012 ok i have a code that goes to a database and gets the info, and puts it on an image, the user can change the color of this image from the cpanel, only problem is it displays the image url not found icon here is my code sc.php <?php $color = "red"; include('statuscheckercheck.php'); if($color == "red"){ $image = imagecreatefrompng("img/Red.png"); } else if($color == "blue") { $image = imagecreatefrompng("img/Blue.png"); } else if($color == "golden") { $image = imagecreatefrompng("img/Golden.png"); } else if($color == "green") { $image = imagecreatefrompng("img/Green.png"); } else if($color == "orange") { $image = imagecreatefrompng("img/Orange.png"); } else if($color == "purple") { $image = imagecreatefrompng("img/Purple.png"); } else { $image = imagecreatefrompng(" img/Red.png"); } $foreground = imagecolorallocate($image, 255, 255, 255); $font = 'Kimbalt.ttf'; $message = $sn; imagettftext($image,15, 0, 10, 27, $foreground, $font ,$message); $message = $v; imagestring($image,20,90, 65,$message,$foreground); header("Content-type: image/png"); imagepng($image); ?> statuscheckercheck.php <?php include('config.php'); if ($db_found) { if(isset($_GET['server'])){ $ServerName = $_GET['server']; $SQL = "SELECT Name,Votes,colour FROM server WHERE Name='$ServerName'"; $result = mysql_query($SQL); while ($db_field = mysql_fetch_assoc($result)) { $sn = $db_field['Name']; $v = $db_field['Votes']; $color = $db_field['colour']; } } else { } } else { } ?> config.php <?php //######################################## //############Created By Dartz############ //######################################## //######I Do NOT Expect Credit this########## //##########Is free open source.############# //##Some Vulnerabilities exist for those####### //#############script kiddies.############### //######################################## //#######DO NOT DELETE THIS MESSAGE#### //######################################## //extrmind(); $exists = true; // Security //ADVERTS $currentadv = 1; $advertspaceI = array("http://rune-logic.weebly.com/uploads/8/8/7/2/8872672/header_images/1327709161.jpg, http://i41.tinypic.com/2liet7k.jpg");//Advert image links $advertspaceL = array("http://rune-logic.weebly.com, http://3mberscape.webs.com");//Advert hyperlinks //END OF ADVERTS $user_name = "u215204170_sss"; $password = "ssssss"; $database = "u215204170_sss"; $server = "mysql.nazuka.net"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); ?> Quote Link to comment https://forums.phpfreaks.com/topic/263160-displaying-content-from-database-on-image-code-not-working/ Share on other sites More sharing options...
Oreo Posted May 26, 2012 Share Posted May 26, 2012 Comment out this line: header("Content-type: image/png"); Then visit the URL of the generated image directly in your browser and see if it spits out any intelligible error messages. Alternatively, save the generated image to your local drive and open it in a text editor. Some other comments: - else branches are not required, if you have nothing to put in them you can omit them completely - there is no particular reason to loop over mysql_fetch_assoc if you're only fetching one result - escape your input to avoid SQL injection exploits: $ServerName = mysql_real_escape_string($_GET['server']); Quote Link to comment https://forums.phpfreaks.com/topic/263160-displaying-content-from-database-on-image-code-not-working/#findComment-1348733 Share on other sites More sharing options...
deathadder Posted May 26, 2012 Author Share Posted May 26, 2012 i get this error when i removed that line Warning: Wrong parameter count for imagettftext() in /home/u215204170/public_html/sss/sc.php on line 23 Quote Link to comment https://forums.phpfreaks.com/topic/263160-displaying-content-from-database-on-image-code-not-working/#findComment-1348734 Share on other sites More sharing options...
PFMaBiSmAd Posted May 26, 2012 Share Posted May 26, 2012 Did you look at line 23 in your code and TRY to figure out what is wrong with the parameters you are supplying to the imagettftext() function? Quote Link to comment https://forums.phpfreaks.com/topic/263160-displaying-content-from-database-on-image-code-not-working/#findComment-1348770 Share on other sites More sharing options...
Oreo Posted May 26, 2012 Share Posted May 26, 2012 Are you sure the code you posted is the same as the code you're running? Because in the code you posted imagettftext has the right number of parameters. Quote Link to comment https://forums.phpfreaks.com/topic/263160-displaying-content-from-database-on-image-code-not-working/#findComment-1348785 Share on other sites More sharing options...
deathadder Posted June 2, 2012 Author Share Posted June 2, 2012 coder of the script says my webhost doesen't support it Quote Link to comment https://forums.phpfreaks.com/topic/263160-displaying-content-from-database-on-image-code-not-working/#findComment-1350535 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.