Can not find the problem in this MySQL query. Can't insert rows. Have checked the script many times but can not find out what's wrong.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'hashtag1,('hashtag1','751','1','2015-11-20 11:37:48','1448019468'), hashtag2,('hashtag2','751','1' at line 2
My script:
$hashtags = array();
preg_match_all("/(#\w+)/", $text, $matches);
if(!empty($matches[0]) ){
foreach( $matches[0] as $hashtag ){
$hashtag = strtolower(str_replace('#', '', $hashtag));
array_push($hashtags, "('$hashtag','$publi','1','".TM1."','".TM2."')");
}
$hashtags = array_unique($hashtags);
$result = mysqli_query($dcon1,'INSERT INTO w_hashtags(htag,publicat,numbr,tm1,tm2)
VALUES ('.implode(',', $hashtags).')
ON duplicate KEY UPDATE numbr=numbr+1, tm1='.TM1.', tm2='.TM2.'') or die(mysqli_error($dcon1));