oskare100 Posted February 2, 2007 Share Posted February 2, 2007 Hello, I've this PHP script that should be able to identify; $mysql = mysql_connect($host, $username, $password)or die(mysql_error()); mysql_select_db($db_name, $mysql)or die(mysql_error()); $item_name= mysql_real_escape_string($item_name); $query="SELECT * FROM `items` WHERE `price` = $mc_gross AND ('$item_name' LIKE `identify_pos` AND '$item_name' LIKE `identify_pos2`) AND ('$item_name' NOT LIKE `identify_neg` AND '$item_name' NOT LIKE `identify_neg2`) "; $result = mysql_query($query) or die(mysql_error()); if ( false===($ident_row=mysql_fetch_assoc($result)) ) { // No row found die; } else { echo 'item_id: ', $ident_row['item_id'], "<br />\n"; } Here is the current database structure: -- -- 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(10) NOT NULL default '0', `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', `list_id` int(5) 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`, `list_id`) VALUES (1, 'Package 1', '2.95', '%15GB%', '%templates%', '', '', 0, 1, 0), (2, 'Package 2', '2.95', '', '', '%15gb%', '%templates%', 0, 2, 0); In other words, package 1 has the words %15GB% and %templates% as positive identify words (that the title should contain to be package 1) and Package 2 has the words as negative indentify words (words that the title shouldn't contain to be package 2. I hoped that the above structure would result in that all titles that contain 15GB and Templates are identified as Package 1 (and that works good) and that all other item titles that doesn't include the words 15GB and templates would automaticly be identified as Package 2 but that's the problem. If a title doesn't cotain 15gb or templates the script dies without any result. I really need help with this so any info is appreciated. Best Regards Oskar R Link to comment https://forums.phpfreaks.com/topic/36789-help-with-a-mysql-php-script-that-should-identify-a-title/ Share on other sites More sharing options...
fenway Posted February 5, 2007 Share Posted February 5, 2007 Well, first, why the column name as the rvalue? and second, I don't see any percent signs. Link to comment https://forums.phpfreaks.com/topic/36789-help-with-a-mysql-php-script-that-should-identify-a-title/#findComment-177198 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.