Jump to content

Help with a MySQL PHP script that should identify a title


oskare100

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.