bbreslauer wrote:The mysql_fetch_object() error means that it couldn't get the data from the database. A couple possibilities are: 1) your SQL query is malformed (to check this, echo $sql and then try that query in the mysql command line or phpMyAdmin, for example) or 2) you didn't connect to the database first.
The header error is because headers must be the first thing sent to the browser. This could be cleared up after fixing the other error, as that sent an error message to the browser before the header was sent.
Thanks for the reply. I tried to run the sql query from phpmyadmin, now I only ran line 31, is that correct or should I have ran the entire script? I got an error when I tried to run it. Also, I don't know what you mean by echo $sql first......Here is the entire script:
<?php
//+++++++++++++++++++++++++++++
//Fill in your Database details
//+++++++++++++++++++++++++++++
$dbhost="localhost"; //mysql host address
$dbuname="xxxxx_xxx";//mysql user name
$dbpass="xxxxxx"; //mysql user pass
$dbname="xxxx_xxxx"; //babstats db name
mysql_connect($dbhost, $dbuname, $dbpass) or die ("SQL server down");
$db=mysql_select_db($dbname) or die ("Unable to select database");
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//If you want to edit this for chronos, edit the query below
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$sql = mysql_db_query($dbname,"SELECT id, player_name, total_kills, last_played, total_deaths, total_knives, total_headshots, total_games FROM bab_stats where id = $id");
//++++++++++++++++++++++++++++++++++
//filename of the background picture
//++++++++++++++++++++++++++++++++++
$image = "signature.png";
$im = imagecreatefrompng($image);
//++++++++++++++++++++++
//RGB Colour of the Text
//++++++++++++++++++++++
$tc = ImageColorAllocate ($im, 255, 225, 119);
while ($i!=1 && $data = mysql_fetch_object($sql)) {
//++++++++++++++++++++++
//change yoursite.com to your website url
//++++++++++++++++++++++
ImageString($im, 3, 105, 5, "Player stats for $data->player_name", $tc);
ImageString($im, 2, 105, 20, "Total kills: $data->total_kills | Total deaths: $data->total_deaths", $tc);
ImageString($im, 2, 105, 30, "Total Knives: $data->total_knives | Total Headshots: $data->total_headshots", $tc);
ImageString($im, 2, 105, 43, " Last Played: $data->last_played", $tc);
ImageString($im, 2, 105, 55, "Total Games: $data->total_games www.deltaforceraiders.net", $tc);
$i++;
}echo "";
$db=mysql_close ();
header("Content-Type: image/png");
Imagepng($im,'',100);
ImageDestroy ($im);
?>
thanks again!