Undefined pg_prepare() in 5.6.1

Undefined pg_prepare() in 5.6.1

am 01.11.2006 00:04:37 von Steve Mathias

Hello,

The following code:

// Connect to a database named "mary"
$dbconn = pg_connect("host=localhost port=5432 dbname=test user=test
password=test");
if(!$dbconn) {
echo "Unable to connect to test database\n";
echo pg_last_errror($dbconn);
exit;
}
$result = pg_prepare($dbconn, "my_query", 'SELECT * FROM users WHERE
username = $1');
....
?>

gives me this in the apache log:

[Tue Oct 31 15:11:42 2006] [error] [client xx.xxx.xxx.x] PHP Fatal error: Call to undefined function pg_prepare() in /usr/local/apache/htdocs/php/dbtest.php on line 10


Other than this, PHP and non-prepare related pg_* functions work
fine. php_info() reports that it sees version 8.0.3 of libpq. I've
done a fresh compile and install of apache and PHP. Versions are:
Apache: 2.2.3
PHP: 5.6.1
Postgres: 8.0.3
My configure line for PHP was: ./configure
--with-apxs2=/usr/local/apache/bin/apxs --with-pgsql=/usr/local/pgsql
--with-mysql=/usr/local/mysql --enable-force-cgi-redirect --disable-cgi
--with-zlib --with-gettext

I've not been able to find any help on this in the FAQ or by
searching the archives. It seems like this must be something really
stupid, but I'm stumped. Any help/pointers would be greatly appreciated.

-Steve
--
( Stephen L. Mathias, Ph.D. ( s m a t h i a s (
) Division of Biocomputing ) @ p o b l a n o )
( UNM School of Medicine ( . h e a l t h . (
) ) u n m . e d u )
( http://poblano.health.unm.edu/ (

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Undefined pg_prepare() in 5.6.1

am 01.11.2006 00:22:12 von Chris

Steve Mathias wrote:
> Hello,
>
> The following code:
>
> > // Connect to a database named "mary"
> $dbconn = pg_connect("host=localhost port=5432 dbname=test user=test
> password=test");
> if(!$dbconn) {
> echo "Unable to connect to test database\n";
> echo pg_last_errror($dbconn);
> exit;
> }
> $result = pg_prepare($dbconn, "my_query", 'SELECT * FROM users WHERE
> username = $1');
> ...
> ?>
>
> gives me this in the apache log:
>
> [Tue Oct 31 15:11:42 2006] [error] [client xx.xxx.xxx.x] PHP Fatal error: Call to undefined function pg_prepare() in /usr/local/apache/htdocs/php/dbtest.php on line 10
>
>
> Other than this, PHP and non-prepare related pg_* functions work
> fine. php_info() reports that it sees version 8.0.3 of libpq. I've
> done a fresh compile and install of apache and PHP. Versions are:

Well there is no php 5.6.1 ;) there is a 5.1.6 though and it should work
there.

What shows up if you do a simple:

print_r(get_extension_funcs("pgsql"));
?>

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Undefined pg_prepare() in 5.6.1

am 01.11.2006 03:41:42 von Chris

Steve Mathias wrote:
>>>>>> "Chris" == Chris writes:
>
> Chris> Steve Mathias wrote:
>>> Hello,
>>>
>>> The following code:
>>>
>>> >>> pg_connect("host=localhost port=5432 dbname=test user=test
>>> password=test"); if(!$dbconn) { echo "Unable to connect to test
>>> database\n"; echo pg_last_errror($dbconn); exit; } $result =
>>> pg_prepare($dbconn, "my_query", 'SELECT * FROM users WHERE username =
>>> $1'); ... ?>
>>>
>>> gives me this in the apache log:
>>>
>>> [Tue Oct 31 15:11:42 2006] [error] [client xx.xxx.xxx.x] PHP Fatal
>>> error: Call to undefined function pg_prepare() in
>>> /usr/local/apache/htdocs/php/dbtest.php on line 10
>>>
>>>
>>> Other than this, PHP and non-prepare related pg_* functions work
>>> fine. php_info() reports that it sees version 8.0.3 of libpq. I've
>>> done a fresh compile and install of apache and PHP. Versions are:
>
> Chris> Well there is no php 5.6.1 ;) there is a 5.1.6 though and it
> Chris> should work there.
>
> Ooops. Dyslexia sucks. Indeed, I am using 5.1.6
>
> Chris> What shows up if you do a simple:
>
> Chris>
>
> An array of function names, not including pg_prepare() ;-(



Might need to ask the -installs list (the -general one *may* have an
idea but the installs list would be better).

Looks like the stuff added after 5.1.0rc1 isn't showing up
(pg_query_params isn't there either).

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Undefined pg_prepare() in 5.6.1

am 01.11.2006 04:21:36 von Shuping Zhou

------=_Part_16993_14048003.1162351296244
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

>
>
> Apache: 2.2.3
> PHP: 5.6.1 -> 5.1.6
> Postgres: 8.0.3
>

I think the version is ok.

You can check this file "PHP_Source/ext/pgsql/config.h" ( after configure
but before make ) to look up if "HAVE_PQPREPARE" is defined or undefined.
If it's not, modify it to be defined munually, then launch another make.

I hope this dirty solution works.


--shuping zhou

------=_Part_16993_14048003.1162351296244--

Re: Undefined pg_prepare() in 5.6.1

am 02.11.2006 03:04:23 von Shuping Zhou

------=_Part_31960_32288219.1162433063768
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

>
>
> Thanks for the suggestion, Shuping. However, after configure
> "PHP_Source/ext/pgsql" does not have a config.h file. The contents are:


I installed PgSQL 8.0.8 (can't find 8.0.3) minutes ago, then rebuilt the
pgsql extension.
the result is good, i have pg_prepare:)

So, would you please try this:

1) copy the original /ext/pgsql to somewhere and cd to it;
2) run phpize;
3) run ./configure;
4) if step 3 succeeded, there must be config.h here; check HAVE_PQPREPARE in
it;
5) run make;
6) if step 5 succeeded, you will get ./modules/pgsql.so ; copy it to your
php's extension directory (backup before overwritting);
7) done.

waiting for your result:)


--shuping zhou

------=_Part_31960_32288219.1162433063768--