Jump to content

[SOLVED] Php GD Problem


zackcez

Recommended Posts

Ok, I have this code:

<?php 

$bd_host = "";     // Database host
$bd_usuario = "";       // Database username
$bd_password = "";      // Database password
$bd_base = "";            // Database name
$con = mysql_connect($bd_host, $bd_usuario, $bd_password); mysql_select_db($bd_base, $con);



$user = $_GET['name'];
$sql = "SELECT * FROM user WHERE pet_name='$user'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);



$level = $row["level"];
$new_level = $level + 1;
$pet_name = $row["pet_name"];
//UPDATE VIEW/LEVEL
mysql_query("UPDATE user SET level = '$new_level' WHERE pet_name = '$pet_name'");
//END OF UPDATE
$color = $row["color"];
$browser = $_SERVER['HTTP_USER_AGENT'];
$realip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ?
$_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];


if ($level == null) 
{ 
$back = 'http://deluzion-gaming.net/pixelplushies/pets/error.jpg';
}
else if ($level <= 26)
{ 
$back = 'http://deluzion-gaming.net/pixelplushies/pets/1to25_$color.jpg';
}
else if ($level <= 76)
{ 
$back = 'http://deluzion-gaming.net/pixelplushies/pets/26to75_$color.jpg';
}
else if ($level <= 125)
{ 
$back = 'http://deluzion-gaming.net/pixelplushies/pets/76to125_$color.jpg';
}
else if ($level >= 125)
{ 
$back = 'http://deluzion-gaming.net/pixelplushies/pets/126up_$color.jpg';
}
else
{ 
$back = 'http://deluzion-gaming.net/pixelplushies/pets/erorr.jpg';
}



$red = imagecolorallocate($back, 0, 0, 0);

header ("Content-type: image/Jpeg");

$back = imagecreatefromjpeg ("$back");

$textcolor = ImageColorAllocate ($back, 000000, 000000, 000000); 
ImageString ($back, 2, 2, 2, "Pet Name: $pet_name", $textcolor);
ImageString ($back, 2, 2, 13, "Pet Level: $level", $textcolor);
ImageString ($back, 2, 2, 24, "Your IP: $realip", $textcolor);
ImageString ($back, 2, 2, 13, "Your Broser: $browser", $textcolor);
ImageGif ($back);
ImageDestroy ($back);
?> 

 

When that is viewed on my web site (it has php gd) it just shows up like this:

colorallocate($back, 0, 0, 0);

header ("Content-type: image/Jpeg");

$back = imagecreatefromjpeg ("$back");

$textcolor = ImageColorAllocate ($back, 000000, 000000, 000000); 
ImageString ($back, 2, 2, 2, "Pet Name: $pet_name", $textcolor);
ImageString ($back, 2, 2, 13, "Pet Level: $level", $textcolor);
ImageString ($back, 2, 2, 24, "Your IP: $realip", $textcolor);
ImageString ($back, 2, 2, 13, "Your Broser: $browser", $textcolor);
ImageGif ($back);
ImageDestroy ($back);
?> 

If anyone has any way they even think could fix this, I'd really appreciate a replay!

Thank you for your time,

Zack

Link to comment
https://forums.phpfreaks.com/topic/107353-solved-php-gd-problem/
Share on other sites

for one, you need to double-quote strings if you're going to use a variable in them as you have:

 

$back = "http://deluzion-gaming.net/pixelplushies/pets/1to25_$color.jpg";

 

otherwise, you'll get exactly what you single-quoted:

 

http://deluzion-gaming.net/pixelplushies/pets/1to25_$color.jpg

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.