Skip to content
Advertisement

PHP Insert into PostgreSQL

So it’s probably a really stupid/basic question, but i have this simple PHP function (which works) and inserts data into a PostgreSQL DB.

My issue is when it encounters specific data;

JavaScript

And while this works, it falls over with a surname such as:

O’hare

And obviously this occurs because then the PHP code comes out as:

…VALUES (‘john@example.com’, ‘John’, ‘O’hare’)”;

but im not sure of how i should be structuring the PHP to allow for this.

Advertisement

Answer

Try this:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement