note 82117 added to function.pg-connect
| From: | bgalloway at citycarshare dot org | Date: | Fri, 28 Mar 2008 02:33:14 +0000 |
| Subject: | note 82117 added to function.pg-connect | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137651@lists.php.net to get a copy of this message | ||
Beware about writing something like
<?php
function getdb_FAILS() {
return pg_connect("...") or die('connection failed');
}
?>
It will return a boolean. This will appear to be fine if you don't use the return value as a
db connection handle, but will fail if you do.
Instead, use:
<?php
function getdb() {
$db = pg_connect("...") or die('connection failed');
return $db;
}
?>
which actually returns a handle.
----
Server IP: 208.69.120.35
Probable Submitter: 67.152.84.66
----
Manual Page -- http://www.php.net/manual/en/function.pg-connect.php
Edit -- https://master.php.net/note/edit/82117
Del: integrated -- https://master.php.net/note/delete/82117/integrated
Del: useless -- https://master.php.net/note/delete/82117/useless
Del: bad code -- https://master.php.net/note/delete/82117/bad+code
Del: spam -- https://master.php.net/note/delete/82117/spam
Del: non-english -- https://master.php.net/note/delete/82117/non-english
Del: in docs -- https://master.php.net/note/delete/82117/in+docs
Del: other reasons-- https://master.php.net/note/delete/82117
Reject -- https://master.php.net/note/reject/82117
Search -- https://master.php.net/manage/user-notes.php