Обсуждение: Problem with pg_connect() in PHP

Поиск
Список
Период
Сортировка

Problem with pg_connect() in PHP

От
James Kitambara
Дата:
<table border="0" cellpadding="0" cellspacing="0"><tr><td style="font: inherit;" valign="top"><p class="MsoNormal"
style="MARGIN:0in 0in 10pt"><font face="Calibri" size="3">Dear Members of </font><p class="MsoNormal" style="MARGIN:
0in0in 10pt"><font face="Calibri" size="3">I have installed the Apache 2.0.61,<span style="mso-spacerun: yes"> 
</span>PHP5.2.4 and PostgreSQL 8.1 on my local computer.</font><p class="MsoNormal" style="MARGIN: 0in 0in 10pt"><font
face="Calibri"size="3">All three software were successfully tested. I changed “<i style="mso-bidi-font-style:
normal">;extension=php_pgsql.dll”</i><span style="mso-spacerun: yes"> </span>to </font><p class="MsoNormal"
style="MARGIN:0in 0in 10pt"><font size="3"><font face="Calibri"><i style="mso-bidi-font-style:
normal">“extension=php_pgsql.dll”</i><span style="mso-spacerun: yes">   </span>in the php.ini file in order to enable
PostgreSQLin PHP.</font></font><p class="MsoNormal" style="MARGIN: 0in 0in 10pt"><font face="Calibri" size="3">The
problemcomes when I try to connect to the PostgreSQL Database using php function pg_connect</font><p class="MsoNormal"
style="MARGIN:0in 0in 10pt"><span style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #7f9fbf; LINE-HEIGHT: 115%;
FONT-FAMILY:'Courier New'; mso-highlight: white">$dbconn</span><span style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR:
black;LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-highlight: white"> = </span><span style="FONT-SIZE: 10pt;
BACKGROUND:white; COLOR: #7f7f9f; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-highlight:
white">pg_connect</span><spanstyle="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; LINE-HEIGHT: 115%; FONT-FAMILY:
'CourierNew'; mso-highlight: white">(</span><span style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #2a00ff;
LINE-HEIGHT:115%; FONT-FAMILY: 'Courier New'; mso-highlight: white">"host="</span><span style="FONT-SIZE: 10pt;
BACKGROUND:white; COLOR: black; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-highlight:
white">.PG_HOST_NAME.</span><spanstyle="FONT-SIZE: 10pt;BACKGROUND: white; COLOR: #2a00ff; LINE-HEIGHT: 115%;
FONT-FAMILY:'Courier New'; mso-highlight: white">" port="</span><span style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR:
black;LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-highlight: white">.PG_PORT_NUM.</span><span style="FONT-SIZE:
10pt;BACKGROUND: white; COLOR: #2a00ff; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-highlight: white">" <span
style="mso-spacerun:yes"> </span>dbname="</span><span style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black;
LINE-HEIGHT:115%; FONT-FAMILY: 'Courier New'; mso-highlight: white">.PG_DB_NAME.</span><span style="FONT-SIZE: 10pt;
BACKGROUND:white; COLOR: #2a00ff; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-highlight: white">"
user="</span><spanstyle="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier
New';mso-highlight: white">.PG_USER.</span><span style="FONT-SIZE: 10pt; BACKGROUND: white;COLOR: #2a00ff; LINE-HEIGHT:
115%;FONT-FAMILY: 'Courier New'; mso-highlight: white">" password="</span><span style="FONT-SIZE: 10pt; BACKGROUND:
white;COLOR: black; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-highlight: white">.PG_PASSWORD);</span><font
face="Calibri"size="3"> </font><p class="MsoNormal" style="MARGIN: 0in 0in 10pt"><span lang="EN"
style="mso-ansi-language:EN; mso-bidi-font-weight: bold"><font size="3"><font face="Calibri">All the arguments in the
functionpg_connect() are defined.</font></font></span><p class="MsoNormal" style="MARGIN: 0in 0in 10pt"><font
size="3"><fontface="Calibri"><span lang="EN" style="mso-ansi-language: EN; mso-bidi-font-weight: bold">Unfortunately I
amgetting the Fatal error</span><span lang="EN" style="mso-ansi-language: EN">: “<i style="mso-bidi-font-style:
normal">Callto undefined function pg_connect() in <span style="mso-bidi-font-weight:
bold">C:\Web\html\Staff_Management\example1.php</span>on line <span style="mso-bidi-font-weight:
bold">23</span></i><spanstyle="mso-bidi-font-weight: bold">”</span></span></font></font><p class="MsoNormal"
style="MARGIN:0in 0in 10pt"><span lang="EN" style="mso-ansi-language: EN; mso-bidi-font-weight: bold"><font
size="3"><fontface="Calibri">C:\Web\html is my document root.</font></font></span><p class="MsoNormal" style="MARGIN:
0in0in 10pt"><span lang="EN" style="mso-ansi-language: EN; mso-bidi-font-weight: bold"><font size="3"><font
face="Calibri">Whatcould be the possible mistake? </font></font></span><p class="MsoNormal" style="MARGIN: 0in 0in
10pt"><spanlang="EN" style="mso-ansi-language: EN; mso-bidi-font-weight: bold"><font size="3"><font
face="Calibri">Anyoneto assist me!</font></font></span><p class="MsoNormal" style="MARGIN: 0in 0in 10pt"><span
lang="EN"style="mso-ansi-language: EN; mso-bidi-font-weight: bold"><font size="3"><font face="Calibri">Best
regards,</font></font></span><pclass="MsoNormal" style="MARGIN: 0in 0in 10pt"><span lang="EN" style="mso-ansi-language:
EN;mso-bidi-font-weight: bold"><font face="Calibri" size="3">James Kitambara</font></span></td></tr></table><br /> 

Re: Problem with pg_connect() in PHP

От
Robert Edwards
Дата:
Looks like you are missing the php_pgsql extension (I assume you
are running on a Windows server). On Debian GNU/Linux, it is called
php5-pgsql (or php4-pgsql, as appropriate). Not sure what it would
be called for Windows, but something similar.

Simply enabling it (by uncommenting the line in your php.ini file)
is not sufficient - the actual library needs to be installed as well.

Cheers,

Bob Edwards.

James Kitambara wrote:
> Dear Members of
> 
> I have installed the Apache 2.0.61,  PHP 5.2.4 and PostgreSQL 8.1 on my 
> local computer.
> 
> All three software were successfully tested. I changed 
> “/;extension=php_pgsql.dll”/  to
> 
> /“extension=php_pgsql.dll”/    in the php.ini file in order to enable 
> PostgreSQL in PHP.
> 
> The problem comes when I try to connect to the PostgreSQL Database using 
> php function pg_connect
> 
> $dbconn = pg_connect("host=".PG_HOST_NAME." port=".PG_PORT_NUM." 
>  dbname=".PG_DB_NAME." user=".PG_USER." password=".PG_PASSWORD);
> 
> All the arguments in the function pg_connect() are defined.
> 
> Unfortunately I am getting the Fatal error: “/Call to undefined function 
> pg_connect() in C:\Web\html\Staff_Management\example1.php on line 23/”
> 
> C:\Web\html is my document root.
> 
> What could be the possible mistake?
> 
> Anyone to assist me!
> 
> Best regards,
> 
> James Kitambara
> 
> 



Re: Problem with pg_connect() in PHP

От
"Edward W. Rouse"
Дата:
<div class="Section1"><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D">Can I assume the missing ‘.”’ From the end of PG_PASSWORD is a cut and paste error?</span><p
class="MsoNormal"><spanstyle="font-size:11.0pt;font-family:"Calibri","sans-serif"; 
color:#1F497D"> </span><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D">Edward W. Rouse</span><p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D"> </span><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in"><p
class="MsoNormal"><b><spanstyle="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span
style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">pgsql-sql-owner@postgresql.org
[mailto:pgsql-sql-owner@postgresql.org]<b>On Behalf Of </b>James Kitambara<br /><b>Sent:</b> Friday, September 26, 2008
1:22AM<br /><b>To:</b> pgsql-sql<br /><b>Cc:</b> Kenichiro Arakaki; Ken Arakaki<br /><b>Subject:</b> [SQL] Problem with
pg_connect()in PHP</span></div><p class="MsoNormal"> <table border="0" cellpadding="0" cellspacing="0"
class="MsoNormalTable"><tr><tdstyle="padding:0in 0in 0in 0in" valign="top"><p class="MsoNormal"
style="margin-bottom:10.0pt"><spanstyle="font-family: "Calibri","sans-serif"">Dear Members of </span><p
class="MsoNormal"style="margin-bottom:10.0pt"><span style="font-family: "Calibri","sans-serif"">I have installed the
Apache2.0.61,  PHP 5.2.4 and PostgreSQL 8.1 on my local computer.</span><p class="MsoNormal"
style="margin-bottom:10.0pt"><spanstyle="font-family: "Calibri","sans-serif"">All three software were successfully
tested.I changed “<i>;extension=php_pgsql.dll”</i>  to </span><p class="MsoNormal"
style="margin-bottom:10.0pt"><i><spanstyle="font-family:
"Calibri","sans-serif"">“extension=php_pgsql.dll”</span></i><spanstyle="font-family:"Calibri","sans-serif"">    in the
php.inifile in order to enable PostgreSQL in PHP.</span><p class="MsoNormal" style="margin-bottom:10.0pt"><span
style="font-family:"Calibri","sans-serif"">The problem comes when I try to connect to the PostgreSQL Database using php
functionpg_connect</span><p class="MsoNormal" style="margin-bottom:10.0pt"><span style="font-size:10.0pt;
font-family:"CourierNew";color:#7F9FBF;background:white;mso-highlight:white">$dbconn</span><span
style="font-size:10.0pt;font-family:"CourierNew";color:black;background: white;mso-highlight:white"> = </span><span
style="font-size:10.0pt;font-family:"Courier
New";color:#7F7F9F;background:white;mso-highlight:white">pg_connect</span><span
style="font-size:10.0pt;font-family:"CourierNew";color:black;background: white;mso-highlight:white">(</span><span
style="font-size:10.0pt;font-family:"Courier
New";color:#2A00FF;background:white;mso-highlight:white">"host="</span><span
style="font-size:10.0pt;font-family:"CourierNew";color:black;background:
white;mso-highlight:white">.PG_HOST_NAME.</span><spanstyle="font-size:10.0pt; font-family:"Courier
New";color:#2A00FF;background:white;mso-highlight:white">"port="</span><span
style="font-size:10.0pt;font-family:"CourierNew";
color:black;background:white;mso-highlight:white">.PG_PORT_NUM.</span><spanstyle="font-size:10.0pt;font-family:"Courier
New";color:#2A00FF;background:white;mso-highlight:white">"  dbname="</span><span
style="font-size:10.0pt;font-family:"CourierNew";color:black;background:
white;mso-highlight:white">.PG_DB_NAME.</span><spanstyle="font-size:10.0pt; font-family:"Courier
New";color:#2A00FF;background:white;mso-highlight:white">"user="</span><span
style="font-size:10.0pt;font-family:"CourierNew";
color:black;background:white;mso-highlight:white">.PG_USER.</span><spanstyle="font-size:10.0pt;font-family:"Courier
New";color:#2A00FF;background:white;mso-highlight:white">" password="</span><span
style="font-size:10.0pt;font-family:"CourierNew";color:black;background:
white;mso-highlight:white">.PG_PASSWORD);</span><spanstyle="font-family: "Calibri","sans-serif""> </span><p
class="MsoNormal"style="margin-bottom:10.0pt"><span lang="EN" style="font-family:"Calibri","sans-serif"">All the
argumentsin the function pg_connect() are defined.</span><p class="MsoNormal" style="margin-bottom:10.0pt"><span
lang="EN"style="font-family:"Calibri","sans-serif"">Unfortunately I am getting the Fatal error</span><span lang="EN"
style="font-family:"Calibri","sans-serif"">:“<i>Call to undefined function pg_connect() in
C:\Web\html\Staff_Management\example1.phpon line 23</i>”</span><p class="MsoNormal" style="margin-bottom:10.0pt"><span
lang="EN"style="font-family:"Calibri","sans-serif"">C:\Web\html is my document root.</span><p class="MsoNormal"
style="margin-bottom:10.0pt"><spanlang="EN" style="font-family:"Calibri","sans-serif"">What could be the possible
mistake?</span><p class="MsoNormal" style="margin-bottom:10.0pt"><span lang="EN"
style="font-family:"Calibri","sans-serif"">Anyoneto assist me!</span><p class="MsoNormal"
style="margin-bottom:10.0pt"><spanlang="EN" style="font-family:"Calibri","sans-serif"">Best regards,</span><p
class="MsoNormal"style="margin-bottom:10.0pt"><span lang="EN" style="font-family:"Calibri","sans-serif"">James
Kitambara</span></td></tr></table><pclass="MsoNormal"><span
style="font-size:10.0pt;font-family:"Calibri","sans-serif""> </span></div>

Re: Problem with pg_connect() in PHP

От
ries van Twisk
Дата:

On Sep 26, 2008, at 12:23 PM, Edward W. Rouse wrote:

Can I assume the missing ‘.”’ From the end of PG_PASSWORD is a cut and paste error?
 
Edward W. Rouse
 
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of James Kitambara
Sent: Friday, September 26, 2008 1:22 AM
To: pgsql-sql
Cc: Kenichiro Arakaki; Ken Arakaki
Subject: [SQL] Problem with pg_connect() in PHP
 
Dear Members of
I have installed the Apache 2.0.61,  PHP 5.2.4 and PostgreSQL 8.1 on my local computer.
All three software were successfully tested. I changed “;extension=php_pgsql.dll”  to
“extension=php_pgsql.dll”    in the php.ini file in order to enable PostgreSQL in PHP.
The problem comes when I try to connect to the PostgreSQL Database using php function pg_connect
$dbconn = pg_connect("host=".PG_HOST_NAME." port=".PG_PORT_NUM."  dbname=".PG_DB_NAME." user=".PG_USER." password=".PG_PASSWORD);
All the arguments in the function pg_connect() are defined.
Unfortunately I am getting the Fatal error: “Call to undefined function pg_connect() in C:\Web\html\Staff_Management\example1.php on line 23
C:\Web\html is my document root.
What could be the possible mistake?
Anyone to assist me!
Best regards,
James Kitambara
 

Did you re-start apache after you made the changes to the php.ini file?

Ries








Re: Problem with pg_connect() in PHP

От
Lennin Caro
Дата:


--- On Fri, 9/26/08, Edward W. Rouse <erouse@comsquared.com> wrote:

> From: Edward W. Rouse <erouse@comsquared.com>
> Subject: Re: [SQL] Problem with pg_connect() in PHP
> To: "'pgsql-sql'" <pgsql-sql@postgresql.org>
> Date: Friday, September 26, 2008, 5:23 PM
> Can I assume the missing ‘.”’ From the end of
> PG_PASSWORD is a cut and paste error?
>
>
>
> Edward W. Rouse
>
>
>
> From: pgsql-sql-owner@postgresql.org
> [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of James
> Kitambara
> Sent: Friday, September 26, 2008 1:22 AM
> To: pgsql-sql
> Cc: Kenichiro Arakaki; Ken Arakaki
> Subject: [SQL] Problem with pg_connect() in PHP
>
>
>
>
> Dear Members of
>
> I have installed the Apache 2.0.61,  PHP 5.2.4 and
> PostgreSQL 8.1 on my local computer.
>
> All three software were successfully tested. I changed
> “;extension=php_pgsql.dll”  to
>
> “extension=php_pgsql.dll”    in the php.ini file in
> order to enable PostgreSQL in PHP.
>
> The problem comes when I try to connect to the PostgreSQL
> Database using php function pg_connect
>
> $dbconn = pg_connect("host=".PG_HOST_NAME."
> port=".PG_PORT_NUM."
> dbname=".PG_DB_NAME." user=".PG_USER."
> password=".PG_PASSWORD);
>
> All the arguments in the function pg_connect() are defined.
>
> Unfortunately I am getting the Fatal error: “Call to
> undefined function pg_connect() in
> C:\Web\html\Staff_Management\example1.php on
> line 23”
>
> C:\Web\html is my document root.
>
> What could be the possible mistake?
>
> Anyone to assist me!
>
> Best regards,
>
> James Kitambara

first create a file that contains this

<? phpinfo(); ?>

save this with php extension, run this file from the browser and seek for the directory extension, then look if the
filephp_pgsql.dll is there