Zach Ross-Clyne
Zach Ross-Clyne

Reputation: 799

PHP and Oracle - Getting ’ rather than single quote with insert

I am writing an engine so that I can read an RSS feed and post into my Oracle database however when getting an apostrophe from the RSS feed, and inserting into the database, I'm getting ’ when looking in the database after INSERThowever the initial string in PHP is . Is there any way in the Oracle insert to ensure that it stays as rather than changing to ’

I have tried using

$variable = "Someone’s String"


$sql = "INSERT INTO table (column) VALUES (q'[" . $variable. "]')"

I am also having the same issue with the characters £ and which are displaying as £ and –

However this doesn't seem to work - Please could you shed some light on the situation

Upvotes: 0

Views: 339

Answers (1)

Aleksei Matiushkin
Aleksei Matiushkin

Reputation: 121010

Your RSS feed contains entities, so you need to convert them to their string representations. html_entity_decode comes to the rescue:

INSERT INTO table (column) 
VALUES (html_entity_decode($variable, ENT_QUOTES | ENT_XML1))

Please note that the result drastically depends on flags (second parameter.) Hope this helps.

Upvotes: 1

Related Questions