Page 1 of 1

(done) Postgres - undefined function pg_escape_string

PostPosted: May 31st, 2018, 1:48 pm
by KCarterSr
Im trying to use the postgres database in my VS, project and im getting the error, undefined function pg_escape_string(). apparently/MAYBE it needs the Postgres version of libpq.dll.

Note: the web app is working fine in VS, until it get's to that function call.

I FOUND THIS COMMENT VIA GOOGLE,
-------------------------------
The PHP extension will look for libpq.dll which is found of your PostgreSQL installation. The simple fix is to add the path than contains that file to your environment PATH.

add to your enviroment variable "PATH" the bin folder of PostgreSQL installation: C:\Program Files\PostgreSQL\9.2\bin; (for example)
--------------------------------------

I tried that, but it didn't work. At least for IIS Express. I don't know.

Can anybody help?

K. Carter Sr.

Re: Postgres - undefined function pg_escape_string

PostPosted: July 31st, 2018, 2:36 pm
by emsmith
The postgresql functions need the postgresql extension enabled. This is not turned on by default. So a couple of questions.

Did you edit your php.ini file to enable the extension? (Tools Menu -> options -> PHP Tools -> Interpreter gives you an easy way to get to your php.ini file from visual studio)

Are any of the other postgresql functions available?

Are you using at least Postgresql database version 7.2?

When you run php -m from the command line what do you see? Is pgsql on the modules list from that command?

All of this is related to how you installed and set up PHP :)

Re: Postgres - undefined function pg_escape_string

PostPosted: August 6th, 2018, 1:18 pm
by Jakub Misek
HI,

indeed;

IntelliSense and the editor knowns `pg_*` functions however you have to enable it in your php.ini in order get it enabled in run time.

I hope it helps,