feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello,
Thanks, that solved that problem, Now when I run this script;
Code: Select all
$item_amount="2.95";
$item_title="Templates, test, ebooks";
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM `items` WHERE `price` = $item_amount AND ((`identify_pos` OR `identify_pos2`) LIKE '%$item_title%') AND ((`identify_neg` OR `identify_neg2`) NOT LIKE '%$item_title%') AND ((`identify_pos` OR `identify_pos2` OR `identify_neg` OR `identify_neg2`) != $item_title)";
$result = mysql_query($sql);
if (mysql_errno()) {
echo 'Error: ' . mysql_error();
} else {
$row=mysql_fetch_assoc($result);
echo $row['item_id'];
}
I get the error Error: Unknown column 'Templates' in 'where clause'. What does that mean?
Here is my database structure of the table with the items;
Code: Select all
--
-- Table structure for table `items`
--
CREATE TABLE `items` (
`item_id` int(11) NOT NULL auto_increment,
`item_name` varchar(100) NOT NULL default '',
`price` varchar(30) NOT NULL default '',
`identify_pos` varchar(50) NOT NULL default '',
`identify_pos2` varchar(50) NOT NULL default '',
`identify_neg` varchar(50) NOT NULL default '',
`identify_neg2` varchar(50) NOT NULL default '',
`file_id` int(10) NOT NULL default '0',
`pack_id` int(10) NOT NULL default '0',
PRIMARY KEY (`item_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `items`
--
INSERT INTO `items` (`item_id`, `item_name`, `price`, `identify_pos`, `identify_pos2`, `identify_neg`, `identify_neg2`, `file_id`, `pack_id`) VALUES
(1, '15GB package', '2.95', '15gb', 'templates', 'test', '', 0, 0),
(2, 'not 15gb package', '2.95', 'ebooks', 'templates', '15gb', '', 0, 0);
And;
volka wrote:This will not match lalalaTemplateslalala, only something like lalalaTemplates, test, ebookslalala
Volka, what do you mean with that? Can't it match the title if it contains , and is in several words?
Thanks in advance,
/Oskar R
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]