[PHP-DB] Inserting a php file into a mysql database
Hello, I am trying to insert a php page into a database. I need to know if there is something that I need to do when setting up the table, also is there something to do with the code. Thank You for your help Thomas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Postgre SQL query error with PHP
Thanks for the help. It is working like it should. Next on the query parameters. Again Thanks for the help. Thomas On 7/2/05, Martín Marqués martin@bugs.unl.edu.ar wrote: El Sáb 02 Jul 2005 14:21, John DeSoi escribió: On Jul 2, 2005, at 9:17 AM, Thomas Bonham wrote: If you wouldn't mind look over this error to I would be very nice. The error that I'm have now is the following. It is probely very sample, but I'm still learning php so not for me it not. There is an example here, that I think will help you. http://www.php.net/manual/en/function.pg-fetch-row.php And if that does not help try just printing out the entire array so you know what is there. See the var_dump function: http://us2.php.net/manual/en/function.var-dump.php I personally think he should start here: http://pear.php.net/manual/en/package.database.db.php -- select 'mmarques' || '@' || 'unl.edu.ar' AS email; - Martín Marqués | Programador, DBA Centro de Telemática| Administrador Universidad Nacional del Litoral - -- -- Thomas Bonham [EMAIL PROTECTED] bonhamlinux.org Cell 602-402-9786 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Postgre SQL query error with PHP
Thank. The grant work. If you wouldn't mind look over this error to I would be very nice. The error that I'm have now is the following. It is probely very sample, but I'm still learning php so not for me it not. Error: Connection to Data Base established Notice: Uninitialized string offset: 1 in /var/www/html/thomas/cis166ae/database/web_users/dan/newrow.php on line 27 Notice: Uninitialized string offset: 2 in /var/www/html/thomas/cis166ae/database/web_users/dan/newrow.php on line 28 Notice: Uninitialized string offset: 3 in /var/www/html/thomas/cis166ae/database/web_users/dan/newrow.php on line 29 Notice: Uninitialized string offset: 4 in /var/www/html/thomas/cis166ae/database/web_users/dan/newrow.php on line 30 Notice: Uninitialized string offset: 5 in /var/www/html/thomas/cis166ae/database/web_users/dan/newrow.php on line 31 Notice: Uninitialized string offset: 6 in /var/www/html/thomas/cis166ae/database/web_users/dan/newrow.php on line 32 Notice: Uninitialized string offset: 7 in /var/www/html/thomas/cis166ae/database/web_users/dan/newrow.php on line 33 Notice: Uninitialized string offset: 8 in /var/www/html/thomas/cis166ae/database/web_users/dan/newrow.php on line 34 Notice: Uninitialized string offset: 9 in /var/www/html/thomas/cis166ae/database/web_users/dan/newrow.php on line 35 data: 1, , , , , , , , , , It prints the first one then it errors. Thank agin Thomas On 7/2/05, John DeSoi [EMAIL PROTECTED] wrote: On Jul 1, 2005, at 9:37 PM, Thomas Bonham wrote: Error: Connection to Data Base established Warning: pg_query(): Query failed: ERROR: permission denied for relation property in /var/www/html/thomas/cis166ae/database/web_users/dan/newrow.php on line 20 Warning: Wrong parameter count for pg_num_rows() in /var/www/html/thomas/cis166ae/database/web_users/dan/newrow.php on line 21 As it show above I can connect to the database but no query. The part of the code that is error I Think is the following. $query = pg_query ( SELECT * FROM property ); The first error is telling you that you don't have permission to select from the property table. See the GRANT command and make sure you have the correct permissions to work with the table. The warning needs to be fixed also. The pg_num_rows command only takes one parameter. You need to remove the $dbconn parameter. John DeSoi, Ph.D. http://pgedit.com/ Power Tools for PostgreSQL -- -- Thomas Bonham [EMAIL PROTECTED] bonhamlinux.org Cell 602-402-9786 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Postgre SQL query error with PHP
Hello All, I'm having a problem setting up the query with postgreSQL. I can do what I won't for the command line but it error when I try it with the PHP functions. My errors and code are below. CODE: ?php /* Setting up connection to data base. */ $conn = dbname='cornerstone_property' user='stone' host='localhost'; /* Connecting to the data base */ $dbconn = pg_connect(dbname='cornerstone_property' user='stone' host='localhost'); /* Connecting to see if the connection is true */ if($dbconn == true) { echo Connection to Data Base established; } else { echo Connection to Data Base failed; } /* End of Connectting to the data base */ $query = pg_query ( SELECT * FROM property ); $rows = pg_num_rows($dbconn,$query); for ($i = 0; $i $rows; $i++) { $data = pg_fetch_result($query, $i); echo data: $data[0], $data[1], $data[2], $data[3], $data[4], $data[5], $data[6], $data[7], $data[8], $data[9], br\n; } pg_close($dbconn); ? Error: Connection to Data Base established Warning: pg_query(): Query failed: ERROR: permission denied for relation property in /var/www/html/thomas/cis166ae/database/web_users/dan/newrow.php on line 20 Warning: Wrong parameter count for pg_num_rows() in /var/www/html/thomas/cis166ae/database/web_users/dan/newrow.php on line 21 As it show above I can connect to the database but no query. The part of the code that is error I Think is the following. $query = pg_query ( SELECT * FROM property ); Thanks for the help. Thomas -- -- Thomas Bonham [EMAIL PROTECTED] bonhamlinux.org Cell 602-402-9786 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PostgreSQL error with php
Hello All, I’m trying to get php to connect to my PostgreSQL database. The code that I’m using is below. htmlheadtitleLogin/title /head body ?php $conn = dbname=auth user=auth; $db = pg_connect ( $conn ); ? /body /html Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT authentication failed for user auth in /var/www/html/thomas/cis166ae/database/secretdb.php on line 8 Below is how I set up my database. [EMAIL PROTECTED] # Su – postgres -bash-3.00$ createuser –D –A –E auth -bash-3.00$ createdb auth Thanks Helping -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PostgreSQL error with PHP
Hello All, I’m trying to get php to connect to my PostgreSQL database. The code that I’m using is below. htmlheadtitleLogin/title /head body ?php $conn = dbname=auth user=auth; $db = pg_connect ( $conn ); ? /body /html Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT authentication failed for user auth in /var/www/html/thomas/cis166ae/database/secretdb.php on line 8 Below is how I set up my database. [EMAIL PROTECTED] # Su – postgres -bash-3.00$ createuser –D –A –E auth -bash-3.00$ createdb auth Thanks Helping -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PostgreSQL error with PHP
Hello All, I’m trying to get php to connect to my PostgreSQL database. The code that I’m using is below. htmlheadtitleLogin/title /head body ?php $conn = dbname=auth user=auth; $db = pg_connect ( $conn ); ? /body /html Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT authentication failed for user auth in /var/www/html/thomas/cis166ae/database/secretdb.php on line 8 Below is how I set up my database. [EMAIL PROTECTED] # Su – postgres -bash-3.00$ createuser –D –A –E auth -bash-3.00$ createdb auth Thanks Helping -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PostgreSQL with php error
Hello All, I’m trying to get php to connect to my PostgreSQL database. The code that I’m using is below. htmlheadtitleLogin/title /head body ?php $conn = dbname=auth user=auth; $db = pg_connect ( $conn ); ? /body /html Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT authentication failed for user auth in /var/www/html/thomas/cis166ae/database/secretdb.php on line 8 Below is how I set up my database. [EMAIL PROTECTED] # Su – postgres -bash-3.00$ createuser –D –A –E auth -bash-3.00$ createdb auth Thanks Helping -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: PostgreSQL error with PHP
I modafide the code some more and now with the following code I get this error. CODE: htmlheadtitleLogin/title /head body ?php pg_connect(name=auth); (user=auth); ? /body /html Parse error: parse error, unexpected '=' in /var/www/html/thomas/cis166ae/database/secretdb.php on line 8 Thanks Thomas Bonham wrote: Hello All, I’m trying to get php to connect to my PostgreSQL database. The code that I’m using is below. htmlheadtitleLogin/title /head body ?php $conn = dbname=auth user=auth; $db = pg_connect ( $conn ); ? /body /html Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT authentication failed for user auth in /var/www/html/thomas/cis166ae/database/secretdb.php on line 8 Below is how I set up my database. [EMAIL PROTECTED] # Su – postgres -bash-3.00$ createuser –D –A –E auth -bash-3.00$ createdb auth Thanks Helping -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: PostgreSQL error with PHP
Thanks for the help. The code now looks like this. CODE: htmlheadtitleLogin/title /head body ?php $conn = pg_connect(user=auth dbname=auth password=redhat) or die (Could not connect) ; echo Connectd Successfully; pg_close($conn); ? /body /html And now the error I get is the following. Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT authentication failed for user auth in /var/www/html/thomas/cis166ae/database/secretdb.php on line 8 Could not connect Thomas Robbert van Andel wrote: The error is in your function pg_connect pg_connect(name=auth user=auth); I'm not a PostgreSQL user but your connection string should be enclosed into by quotes. Documentation can be found at http://us3.php.net/manual/en/function.pg-connect.php Hope this helps, Robbert -Original Message- From: Thomas Bonham [mailto:[EMAIL PROTECTED] Sent: Sunday, June 26, 2005 5:43 PM To: php-db@lists.php.net Subject: [PHP-DB] Re: PostgreSQL error with PHP I modafide the code some more and now with the following code I get this error. CODE: htmlheadtitleLogin/title /head body ?php pg_connect(name=auth); (user=auth); ? /body /html Parse error: parse error, unexpected '=' in /var/www/html/thomas/cis166ae/database/secretdb.php on line 8 Thanks Thomas Bonham wrote: Hello All, I'm trying to get php to connect to my PostgreSQL database. The code that I'm using is below. htmlheadtitleLogin/title /head body ?php $conn = dbname=auth user=auth; $db = pg_connect ( $conn ); ? /body /html Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT authentication failed for user auth in /var/www/html/thomas/cis166ae/database/secretdb.php on line 8 Below is how I set up my database. [EMAIL PROTECTED] # Su - postgres -bash-3.00$ createuser -D -A -E auth -bash-3.00$ createdb auth Thanks Helping -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: PostgreSQL error with PHP
I add the hostname and port, then I configure postgresql.conf and enable the port 5432 line in the config file. So this is the new code. htmlheadtitleLogin/title /head body ?php $conn = pg_connect( user=auth dbname=auth password=redhat host=thomas.example.com port=5432 ) or die (Could not connect) ; echo Connected Successfully; pg_close($conn); ? /body /html With the new error. Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Connection refused Is the server running on host thomas.example.com and accepting TCP/IP connections on port 5432? in /var/www/html/thomas/cis166ae/database/secretdb.php on line 10 Could not connect Thomas Robbert van Andel wrote: You might need to include the hostname and port. -Original Message- From: Thomas Bonham [mailto:[EMAIL PROTECTED] Sent: Sunday, June 26, 2005 6:48 PM To: php-db@lists.php.net Subject: Re: [PHP-DB] Re: PostgreSQL error with PHP Thanks for the help. The code now looks like this. CODE: htmlheadtitleLogin/title /head body ?php $conn = pg_connect(user=auth dbname=auth password=redhat) or die (Could not connect) ; echo Connectd Successfully; pg_close($conn); ? /body /html And now the error I get is the following. Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT authentication failed for user auth in /var/www/html/thomas/cis166ae/database/secretdb.php on line 8 Could not connect Thomas Robbert van Andel wrote: The error is in your function pg_connect pg_connect(name=auth user=auth); I'm not a PostgreSQL user but your connection string should be enclosed into by quotes. Documentation can be found at http://us3.php.net/manual/en/function.pg-connect.php Hope this helps, Robbert -Original Message- From: Thomas Bonham [mailto:[EMAIL PROTECTED] Sent: Sunday, June 26, 2005 5:43 PM To: php-db@lists.php.net Subject: [PHP-DB] Re: PostgreSQL error with PHP I modafide the code some more and now with the following code I get this error. CODE: htmlheadtitleLogin/title /head body ?php pg_connect(name=auth); (user=auth); ? /body /html Parse error: parse error, unexpected '=' in /var/www/html/thomas/cis166ae/database/secretdb.php on line 8 Thanks Thomas Bonham wrote: Hello All, I'm trying to get php to connect to my PostgreSQL database. The code that I'm using is below. htmlheadtitleLogin/title /head body ?php $conn = dbname=auth user=auth; $db = pg_connect ( $conn ); ? /body /html Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT authentication failed for user auth in /var/www/html/thomas/cis166ae/database/secretdb.php on line 8 Below is how I set up my database. [EMAIL PROTECTED] # Su - postgres -bash-3.00$ createuser -D -A -E auth -bash-3.00$ createdb auth Thanks Helping -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: PostgreSQL error with PHP
I rewrote the code. This is the code and errors. This is starting to get old, I have been working on this for over a week now. CODE: htmlheadtitleLogin/title /head body ?php $conn = user=auth password=redhat dbname=auth host=localhost port=5432; $dbconn = pg_connect($conn); echo Connected Successfully; ? /body /html Error: Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Connection refused Is the server running on host localhost and accepting TCP/IP connections on port 5432? in /var/www/html/thomas/cis166ae/database/secretdb.php on line 11 Connected Successfully Thomas Thomas Bonham wrote: I add the hostname and port, then I configure postgresql.conf and enable the port 5432 line in the config file. So this is the new code. htmlheadtitleLogin/title /head body ?php $conn = pg_connect( user=auth dbname=auth password=redhat host=thomas.example.com port=5432 ) or die (Could not connect) ; echo Connected Successfully; pg_close($conn); ? /body /html With the new error. Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Connection refused Is the server running on host thomas.example.com and accepting TCP/IP connections on port 5432? in /var/www/html/thomas/cis166ae/database/secretdb.php on line 10 Could not connect Thomas Robbert van Andel wrote: You might need to include the hostname and port. -Original Message- From: Thomas Bonham [mailto:[EMAIL PROTECTED] Sent: Sunday, June 26, 2005 6:48 PM To: php-db@lists.php.net Subject: Re: [PHP-DB] Re: PostgreSQL error with PHP Thanks for the help. The code now looks like this. CODE: htmlheadtitleLogin/title /head body ?php $conn = pg_connect(user=auth dbname=auth password=redhat) or die (Could not connect) ; echo Connectd Successfully; pg_close($conn); ? /body /html And now the error I get is the following. Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT authentication failed for user auth in /var/www/html/thomas/cis166ae/database/secretdb.php on line 8 Could not connect Thomas Robbert van Andel wrote: The error is in your function pg_connect pg_connect(name=auth user=auth); I'm not a PostgreSQL user but your connection string should be enclosed into by quotes. Documentation can be found at http://us3.php.net/manual/en/function.pg-connect.php Hope this helps, Robbert -Original Message- From: Thomas Bonham [mailto:[EMAIL PROTECTED] Sent: Sunday, June 26, 2005 5:43 PM To: php-db@lists.php.net Subject: [PHP-DB] Re: PostgreSQL error with PHP I modafide the code some more and now with the following code I get this error. CODE: htmlheadtitleLogin/title /head body ?php pg_connect(name=auth); (user=auth); ? /body /html Parse error: parse error, unexpected '=' in /var/www/html/thomas/cis166ae/database/secretdb.php on line 8 Thanks Thomas Bonham wrote: Hello All, I'm trying to get php to connect to my PostgreSQL database. The code that I'm using is below. htmlheadtitleLogin/title /head body ?php $conn = dbname=auth user=auth; $db = pg_connect ( $conn ); ? /body /html Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT authentication failed for user auth in /var/www/html/thomas/cis166ae/database/secretdb.php on line 8 Below is how I set up my database. [EMAIL PROTECTED] # Su - postgres -bash-3.00$ createuser -D -A -E auth -bash-3.00$ createdb auth Thanks Helping -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: PostgreSQL error with PHP
I think so. I'm going to go there my book (agin) and I'm also going to ask the head IT guy. Thanks for all of your help! Thomas Robbert van Andel wrote: Can you log into the PostgreSQL server from the console or command line? Are you sure you are using the right username, password or host? -Original Message- From: Thomas Bonham [mailto:[EMAIL PROTECTED] Sent: Sunday, June 26, 2005 8:03 PM To: php-db@lists.php.net Subject: Re: [PHP-DB] Re: PostgreSQL error with PHP I rewrote the code. This is the code and errors. This is starting to get old, I have been working on this for over a week now. CODE: htmlheadtitleLogin/title /head body ?php $conn = user=auth password=redhat dbname=auth host=localhost port=5432; $dbconn = pg_connect($conn); echo Connected Successfully; ? /body /html Error: Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Connection refused Is the server running on host localhost and accepting TCP/IP connections on port 5432? in /var/www/html/thomas/cis166ae/database/secretdb.php on line 11 Connected Successfully Thomas Thomas Bonham wrote: I add the hostname and port, then I configure postgresql.conf and enable the port 5432 line in the config file. So this is the new code. htmlheadtitleLogin/title /head body ?php $conn = pg_connect( user=auth dbname=auth password=redhat host=thomas.example.com port=5432 ) or die (Could not connect) ; echo Connected Successfully; pg_close($conn); ? /body /html With the new error. Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Connection refused Is the server running on host thomas.example.com and accepting TCP/IP connections on port 5432? in /var/www/html/thomas/cis166ae/database/secretdb.php on line 10 Could not connect Thomas Robbert van Andel wrote: You might need to include the hostname and port. -Original Message- From: Thomas Bonham [mailto:[EMAIL PROTECTED] Sent: Sunday, June 26, 2005 6:48 PM To: php-db@lists.php.net Subject: Re: [PHP-DB] Re: PostgreSQL error with PHP Thanks for the help. The code now looks like this. CODE: htmlheadtitleLogin/title /head body ?php $conn = pg_connect(user=auth dbname=auth password=redhat) or die (Could not connect) ; echo Connectd Successfully; pg_close($conn); ? /body /html And now the error I get is the following. Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT authentication failed for user auth in /var/www/html/thomas/cis166ae/database/secretdb.php on line 8 Could not connect Thomas Robbert van Andel wrote: The error is in your function pg_connect pg_connect(name=auth user=auth); I'm not a PostgreSQL user but your connection string should be enclosed into by quotes. Documentation can be found at http://us3.php.net/manual/en/function.pg-connect.php Hope this helps, Robbert -Original Message- From: Thomas Bonham [mailto:[EMAIL PROTECTED] Sent: Sunday, June 26, 2005 5:43 PM To: php-db@lists.php.net Subject: [PHP-DB] Re: PostgreSQL error with PHP I modafide the code some more and now with the following code I get this error. CODE: htmlheadtitleLogin/title /head body ?php pg_connect(name=auth); (user=auth); ? /body /html Parse error: parse error, unexpected '=' in /var/www/html/thomas/cis166ae/database/secretdb.php on line 8 Thanks Thomas Bonham wrote: Hello All, I'm trying to get php to connect to my PostgreSQL database. The code that I'm using is below. htmlheadtitleLogin/title /head body ?php $conn = dbname=auth user=auth; $db = pg_connect ( $conn ); ? /body /html Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT authentication failed for user auth in /var/www/html/thomas/cis166ae/database/secretdb.php on line 8 Below is how I set up my database. [EMAIL PROTECTED] # Su - postgres -bash-3.00$ createuser -D -A -E auth -bash-3.00$ createdb auth Thanks Helping -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php