I am a newbie at PHP and was looking through codes and made something up today.
The problem is it doesn't work at all and doesn't show any errors too.
This is supposed to generate a gamer tag after taking values from the db.
Please check and tell me how to correct the errors.
This is my first time here 🙂
Thanks in advance🙂
<?php
// mySQL information
$server = 'localhost'; // MySql server
$dbusername = 'ixxxxx'; // MySql Username
$password = 'xxxx' ; // MySql Password
$database = 'xxxxx'; // MySql Database
// The following should not be edited
$con = mysql_connect("$server","$dbusername","$password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("intergal_arcade", $con);
$user = $_GET['name']; //sets the name specified after name= as variable '$user'
$q = mysql_query("SELECT username, plays, points, avatar,favourites FROM ava_users WHERE username='$user' LIMIT 1"); //this will need modified to fit your setup
//$r = @mysqli_query($con,$q); //this will need modified to fit your setup
$row = mysql_fetch_array($q);
$cardname = $row['username'];
$cardplays = $row['exp'];
$cardpoints = $row['points'];
$cardavatar = '<?php echo $setting['site_url'];?>/uploads/avatars'$row['avatar'];
$cardfavourite = $row['favourites'];
$rImg = ImageCreateFromPNG('<?php echo $setting['site_url'];?>/cardback.png');
$white = imagecolorallocate($rImg, 255, 255, 255);
$grey = imagecolorallocate($rImg, 128, 128, 128);
$black = imagecolorallocate($rImg, 0, 0, 0);
$font = '<?php echo $setting['site_url'];?>/arial.ttf';
$src = ImageCreateFromPNG($cardavatar); //loads avatar image to be edited (from the variable)
imagecopyresized($rImg, $src, 4, 4, 0, 0, 30, 30, 60, 60);
// Add the username
imagettftext($rImg, 20, 0, 129, 88, $white, $font, $cardname);
// Add the EXP
imagettftext($rImg, 20, 0, 129, 112, $white, $font, $cardplays);
// Add the rank
imagettftext($rImg, 20, 0, 129, 136, $white, $font, $cardpoints);
// Add the scores
imagettftext($rImg, 20, 0, 129, 161, $white, $font, $cardfavourite);
header('Content-type: image/png');
imagepng($rImg);
if (!mysql_query($q,$con))
{
die('Error: ' . mysql_error());
}
mysql_close($con);
?>