PHP: foreach insert into, a exploded-list

Insert statements use VALUES, update statements use SET.

"INSERT IGNORE INTO product_keywords SET product_id='".$res_id[$i]."', keyword='".$keyword."";

Should be

"INSERT IGNORE INTO product_keywords(product_id,keyword) VALUES ('{$res_id[$i]}', '{$keyword}')";

Also, you should be using prepared statements to protect from sql injection attacks.

How can I prevent SQL injection in PHP?

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top