Re: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in public_html/games.php on line 16
Hello Bob,
I tried this again with syntax change to:
$query = 'SELECT * FROM games WHERE id=$id';
$game = mysql_query ($query)
or die ("Query failed: " . mysql_error() . " Actual query: " . $query);
This was the results I got:
Query failed: Unknown column '$id' in 'where clause' Actual query: SELECT * FROM games WHERE id=$id
It cant find the id anymore for some reason, I think the sql might have a error.
Here is a copy of the sql.
--
-- Table structure for table `cats`
--
CREATE TABLE `cats` (
`id` int(10) unsigned NOT NULL auto_increment,
`name` char(50) NOT NULL default '',
`status` int(11) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `cats`
--
INSERT INTO `cats` VALUES (1, 'Action', 1);
INSERT INTO `cats` VALUES (2, 'Adventure', 1);
INSERT INTO `cats` VALUES (3, 'Puzzels', 1);
INSERT INTO `cats` VALUES (4, 'Shooting', 1);
INSERT INTO `cats` VALUES (5, 'Sport', 1);
INSERT INTO `cats` VALUES (6, 'Strategy', 1);
-- --------------------------------------------------------
--
-- Table structure for table `games`
--
CREATE TABLE `games` (
`id` int(10) unsigned NOT NULL auto_increment,
`name` varchar(150) NOT NULL default '',
`summary` text NOT NULL,
`description` text NOT NULL,
`width` int(11) NOT NULL default '400',
`height` int(11) NOT NULL default '300',
`cat` int(11) NOT NULL default '0',
`thumb` varchar(150) NOT NULL default '',
`flash` varchar(150) NOT NULL default '',
`played` int(11) NOT NULL default '0',
`vote` int(5) NOT NULL default '0',
`sum` int(11) NOT NULL default '0',
`status` int(11) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `games`
--
INSERT INTO `games` VALUES (1, 'Hovertanks', '', 'A fast-paced, 3D, Tank-Shooting Game. Get them before they get you.', 800, 400, 4, 'hovertanks.jpg', 'hovertanks.swf', 6, 0, 0, 1);
INSERT INTO `games` VALUES (2, 'Prison Escape', '', 'It\\''s World War II and you\\''ve been captured by the German SS during a covert mission. You must escape - your country is depending on you! 27 levels in total, lots of puzzles and challenges to overcome.', 550, 477, 6, 'prisonescapebig.jpg', 'prisonescape.swf', 4, 0, 0, 1);
I see that two of the lines have unsigned in them, is this wrong?
Please can you help me again?
Thank you for all your help.
Best Regards, Phill
Bob Field Wrote:
-------------------------------------------------------
> > $query = "SELECT * FROM cats WHERE id=$id";
> $qr1 = mysql_query ($query)
> or die ("Query failed: " . mysql_error() . "
> Actual query: " . $query);
>