Answer the question
In order to leave comments, you need to log in
How to connect from php to PostgreSQL?
Created a file
<?php
$host = 'localhost';
$db = 'Base';
$user = 'postgres';
$pass = '';
$connection = pg_connect("host=" . $host . " dbname=" . $db ." user=" .$user . " password=" . $pass);
$GLOBALS['link'] = $connection;
?>
include 'dbConnect.php';
function auth($login){
//$dbconn = pg_connect("host=localhost dbname=Base user=postgres password=");
$result = pg_query($GLOBALS['link'], "Select id from \"Users_auth\" where nick= '" . $login . "'");
pg_close($GLOBALS['link']);
return $result;
}
Warning: pg_query(): supplied resource is not a valid PostgreSQL link resource in \localhost\connect.php on line 65
Warning: pg_close(): supplied resource is not a valid PostgreSQL link resource in \localhost\connect.php on line 66
Warning: pg_fetch_result() expects parameter 1 to be resource, boolean given in \localhost\connect.php on line 101
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question