I have the following string connection:
$string_connection = "host=localhost port=5432 user=postgres password=postgres";
$conn = pg_connect($string_connection );
Later in my code, I need to select a database:
pg_connect("dbname=my_database");
But, always I have the following error:
Warning: pg_connect(): Unable to connect to PostgreSQL server: fe_sendauth: no password supplied in ..\class.databases.php on line 142
But, in the example of PHP.net, they do this. Another example:
pg_query($conn,'\connect my_database');
Why this dont work?
When I do a backup with PgAdmin, I got the following strings:
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;
DROP DATABASE my_database;
CREATE DATABASE my_database WITH ENCODING = 'UTF8' LC_COLLATE = 'Portuguese_Brazil.1252' LC_CTYPE = 'Portuguese_Brazil.1252';
ALTER DATABASE my_database OWNER TO postgres;
\connect my_database
Whe I try to run this script with pg_query, I have erros:
Warning: pg_query(): Query failed: ERRO: syntax error in "\" LINE 1: \connect my_database ^
I need to select a dabatase to create a schema then create my tables... I dont know how to do this with Postgres.
pg_connect
? – andrewsi Jul 17 '13 at 17:56