blueman378 Posted December 25, 2007 Share Posted December 25, 2007 hi guys, well heres the error, Error: Unknown column 'boo' in 'where clause' heres the code function doSomething() { global $cat; global $action; global $database; // delete script here $q = ("DELETE FROM gsubcat WHERE cName = $cat")or die("Your have an error because:<br />" . mysql_error()); $result = $database->query($q) or die("Error: " . mysql_error()); header("Location: Category manager.php?action=$action&cat=$cat&run=y");} } heres the url http://localhost/admin/catprocess.php?action=Delete&cat=boo heres the table exported, -- phpMyAdmin SQL Dump -- version 2.11.2.1 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Dec 25, 2007 at 10:14 PM -- Server version: 5.0.45 -- PHP Version: 5.2.5 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Database: `game` -- -- -------------------------------------------------------- -- -- Table structure for table `gsubcat` -- CREATE TABLE `gsubcat` ( `cId` tinyint(3) unsigned NOT NULL auto_increment, `cName` varchar(50) NOT NULL, UNIQUE KEY `cId` (`cId`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=21 ; -- -- Dumping data for table `gsubcat` -- INSERT INTO `gsubcat` (`cId`, `cName`) VALUES (1, 'Action / Adventure'), (2, 'Beat em up'), (3, 'Other'), (4, 'Puzzle'), (5, 'Racing'), (6, 'Retro'), (7, 'Shoot em up'), (8, 'Sports'), (20, 'boo'); any ideas? oh and merry xmas to you too red arrow btw the reason for so many questions is i am working on many parts of the site Quote Link to comment https://forums.phpfreaks.com/topic/83127-solved-possibly-a-bad-sql-statment/ Share on other sites More sharing options...
Daniel0 Posted December 25, 2007 Share Posted December 25, 2007 You need to enclose the value in single quotes. Otherwise it will be looking for a column name instead of a value. I.e. DELETE FROM gsubcat WHERE cName = '$cat' Quote Link to comment https://forums.phpfreaks.com/topic/83127-solved-possibly-a-bad-sql-statment/#findComment-422827 Share on other sites More sharing options...
blueman378 Posted December 25, 2007 Author Share Posted December 25, 2007 thanks, so many simple things, guess im just too tired at the moment but i need to get it done Quote Link to comment https://forums.phpfreaks.com/topic/83127-solved-possibly-a-bad-sql-statment/#findComment-422829 Share on other sites More sharing options...
blueman378 Posted December 25, 2007 Author Share Posted December 25, 2007 oh and what does that thing in your sig do? .. oh very clever Quote Link to comment https://forums.phpfreaks.com/topic/83127-solved-possibly-a-bad-sql-statment/#findComment-422830 Share on other sites More sharing options...
redarrow Posted December 25, 2007 Share Posted December 25, 2007 Daniel0 code says hello world using array and other php statements..... Quote Link to comment https://forums.phpfreaks.com/topic/83127-solved-possibly-a-bad-sql-statment/#findComment-422832 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.