Jump to content

Recommended Posts

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);




?>

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']);

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.