I'm using cURL to pull selected data out of web pages, until recently I've been recording the output to plain text files but now that I have a better appreciation of MySQL/SQLite I've decided to make the full switch to relational databases, just makes managing data so much easier.
But I've run into a couple of issues I haven't been able to solve on my own:
1) EDIT: problem solved by simply using sqlite_escape_string individually.
However the other problem remains:
2) The content that gets inserted into the database appears to have it's encoding messed up e.g. ™ becomes â„¢, ' becomes ’ and so forth. This happens ONLY when it is being processed by SQLite, if I otherwise echo the exact same data out or save it to text file the encoding (UTF-8) is preserved and everything renders properly.
I've tried using utf8_encode(); prior to insertion but that just messes things up even more. I should note that manual editing after insertion works so the issue is clearly not with the DB itself but with the way the data is being inserted into it
Here's the current code:
$name = sqlite_escape_string($name);
$category = sqlite_escape_string($category);
$html = sqlite_escape_string($html);
$db = new SQLiteDatabase('DB.sqlite');
$query = 'INSERT INTO Table (Name, Category, Html)' . "VALUES ('$name', '$category', '$html')";
$db->queryExec($query);
Apparently others are having similar issues with this: