MySQL ON DUPLICATE KEY UPDATE issue

Posted by user644347 on Stack Overflow See other posts from Stack Overflow or by user644347
Published on 2011-03-08T00:05:43Z Indexed on 2011/03/08 0:10 UTC
Read the original article Hit count: 195

Filed under:
|

Hi could some one look at this and tell me where I am going wrong. I have an SQL statement that when I echo using php I get this to screen

INSERT INTO 'moviedb'.'genre' SET 'GenreID' = '18' , 'GenreName' = 'Drama' ON DUPLICATE KEY UPDATE 'GenreName' = 'Drama' WHERE 'GenreID' = '18'
INSERT INTO 'moviedb'.'genre' SET 'GenreID' = '16' , 'GenreName' = 'Animation' ON DUPLICATE KEY UPDATE 'GenreName' = 'Animation' WHERE 'GenreID' = '16'

And here is the statement

$sql="INSERT INTO 'moviedb'.'genre' SET 'GenreID' = '{$genresID[$i]}' , 'GenreName' = '{$genreName[$i]}' ON DUPLICATE KEY UPDATE 'GenreName' = '{$genreName[$i]}' WHERE 'GenreID' = '{$genresID[$i]}'";

This is the error I recieve:

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 ''moviedb'.'genre' SET 'GenreID' = '18' , 'GenreName' = 'Drama' ON DUPLICATE KEY ' at line 1

Any help would be greatly appreciated, thanks in advance.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql