I'm running a script to insert data in my table, but I also want to run the same one, but not duplicate the data that is inserted:
here is my code, for some reason it's not working when I run it, it still add more of the same data.
$query = 'INSERT IGNORE INTO tbl_scrape_main (
`scrape_main_id`,
`tbl_sc_date`,
`tbl_sc_date_added`,
`tbl_sc_url`,
`tbl_sc_url_title`,
`tbl_sc_new`,
`tbl_sc_title`,
`tbl_sc_town`,
`tbl_sc_state`
) VALUES (
'.sql_val($scrape_main_id).',
'.sql_val($temp['date']).',
'.sql_val($date_added).',
'.sql_val($temp['url']).',
'.sql_val($temp['url_title']).',
'.sql_val($temp['new_entry']).',
'.sql_val($temp['title']).',
'.sql_val($temp['town']).',
'.sql_val($temp['state']).'
)
ON DUPLICATE KEY UPDATE
`scrape_main_id` = '.sql_val($scrape_main_id).',
`tbl_sc_date_added` = '.sql_val($temp['date']).',
`tbl_sc_date` = '.sql_val($date_added).',
`tbl_sc_url` = '.sql_val($temp['url']).',
`tbl_sc_url_title` = '.sql_val($temp['url_title']).',
`tbl_sc_new` = '.sql_val($temp['new_entry']).',
`tbl_sc_title` = '.sql_val($temp['title']).',
`tbl_sc_town` = '.sql_val($temp['town']).',
`tbl_sc_state` = '.sql_val($temp['state']).'
';
$result = mysql_query($query) or die("<b>A fatal MySQL error occured</b>.<br />Query: ".$query."<br />Error: (".mysql_errno().") ".mysql_error());
What could be the issue.