I have an SQL file I created from a CSV file. It includes the names of all metropolitan areas in the United States, along with some statistics about their populations. I wrote a PHP script that takes the population data, turns it into a chart, and sticks it back in the city's row, in a different column. This script ran fine until it came to Coeur d'Alene, Idaho. I assume it's because of the apostrophe (single quote) in the city's name. Here's the code:
$query = "UPDATE population SET `$columnname`='$chart_url' WHERE name = '$cityname'";
mysql_query($query) or die;
So it's finding the row by matching it up with the city's name. There isn't any other way to do this, because of the data. Is there a way to deal with data that already has unescaped characters in the SQL file?