php - What is the difference between double quotes and single quotes in mysql query -


i found issue , insert query works, don't understand why. here current working query:

$add_movie = mysql_query("insert ownedmovies values ('', '{$movie_data['title']}', '{$movie_data['year']}', '{$movie_data['rated']}', '{$movie_data['runtime']}', '{$movie_data['genre']}', '{$movie_data['director']}', '{$movie_data['writer']}', '{$movie_data['actors']}', \"{$movie_data['plot']}\", '{$movie_data['imdbrating']}')"); 

notice used double quotes around plot field , normal around else. when did plot field same way others, not error nothing inserted table... works perfectly.

could enlighten me on why is?

thank you

i suspect plot string contains single quote. avoid problem should escaping string values using mysql_real_escape_string, or (better) use parameterized queries.

your "solution" of changing single quote double quote may appear work in case, fail if plot string contains double quote.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -