Page 1 of 1

Fatal error: Call to undefined function pg_escape_string()

Posted: Thu Jun 03, 2010 3:51 am
by swraman
I get this error when I run a webapp Im trying to use:

Fatal error: Call to undefined function pg_escape_string() in ...

I know the application works, as Ive been developing and modifying it for a while now. Im trying to get it running on my Linux desktop so editing will be easier.

My server setup:

-Apache2 on Linux (Ubuntu)
-PHP 5.3.2
-PostgreSQL 8.4

PHP IS CONFIGURED to use postgres, I know thats the most obvious thing that stands out with this problem, but I did configure PHP with:

'./configure' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-pgsql=/opt/PostgreSQL/8.4/'

and in phpinfo It has a section for "PostgreSQL Support"; and if I run php -m pgsql is on the list of installed modules.

Im completely baffled. If it makes any difference, I had PHP 5.3.1 installed earlier, and I got this error; then I downloaded/compiled/installed 5.3.2 to see if it fixed it, but it didn't.

Thanks, any help appreciated.

Re: Fatal error: Call to undefined function pg_escape_string

Posted: Fri Jun 04, 2010 4:05 am
by markusn00b
It sounds like your configuration isn't finding PQescapeString in your PG libraries. Are you sure the libraries on your system (/usr/local/lib, most likely) are the same version as your development files?

Re: Fatal error: Call to undefined function pg_escape_string

Posted: Fri Jun 04, 2010 1:31 pm
by swraman
Hi,

I php from source, so I assume it has the correct versions of everything. How do I check to make sure?

I did a complete format of my Ubuntu system and reinstalled everything - postgres, apache, and php.

I installed postgres from the postgres .bin installer, and apache and php from source; and the problem is still there.

I can read and write to the database from php, and my entire app works fine if I comment out the pg_escape_string() call.

thanks, any other sugestions? or (as a last resort) is there anywhere that I can find out what pg_escape_string does to a string so I can rewrite it myself in php?

Re: Fatal error: Call to undefined function pg_escape_string

Posted: Fri Jun 04, 2010 1:49 pm
by swraman
I pg_escape_string() with addslashes(), are there any particular cases anyone knows of where addslashes will not function as desired? Why is pg_escape_string() recommended over the other?

This seems like it is a but in either the latest php or postgresql...since it exists after a fresh install. Any thoughts on that?

Thanks,

Raman