From: | Jeff Self <jself(at)nngov(dot)com> |
---|---|
To: | Frank Bax <fbax(at)sympatico(dot)ca> |
Cc: | pgsql-php(at)postgresql(dot)org |
Subject: | Re: Trouble with SQL statement using variable |
Date: | 2002-01-29 19:19:21 |
Message-ID: | 1012331962.14649.2.camel@personnel_test |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-php |
On Tue, 2002-01-29 at 14:09, Frank Bax wrote:
> I believe this is a problem with $conn, not your sql syntax. How is $conn
> defined? Is it passed as an argument to the function containing this code,
> or defined as a global? Are you using pg_pconnect or pg_connect()?
$conn is defined as a global in a file called database.inc which is
here:
<?php
//
// database.inc
//
// Database Information
$dbname = "personnel";
$dbuser = "webuser";
$conn = pg_pconnect("dbname=$dbname user=$dbuser");
if (!$conn) {
echo "Could not connect to database.";
exit;
}
?>
As you can see, I'm using pg_pconnect.
>
> At 01:34 PM 1/29/02 -0500, Jeff Self wrote:
> >I'm having trouble getting an SQL statement to use a variable. Here's
> >the statement:
> >
> > $sql = "SELECT emp_fname FROM employee WHERE username = '$username'";
> > $result = pg_exec($conn,$sql);
> > if (!$result) {
> > exit;
> > }
> >I get the following warning from this:
> >
> >Warning: Supplied argument is not a valid PostgreSQL link resource in
> >/var/www/personnel/include/functions.inc on line 25
> >
> >Is there another way to use a variable in an SQL statement. This format
> >works with MySQL.
> >
> >--
> >Jeff Self
> >Information Technology Analyst
> >Department of Personnel
> >City of Newport News
> >2400 Washington Ave.
> >Newport News, VA 23607
> >757-926-6930
> >
> >
> >---------------------------(end of broadcast)---------------------------
> >TIP 5: Have you checked our extensive FAQ?
> >
> >http://www.postgresql.org/users-lounge/docs/faq.html
> >
--
Jeff Self
Information Technology Analyst
Department of Personnel
City of Newport News
2400 Washington Ave.
Newport News, VA 23607
757-926-6930
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Self | 2002-01-29 20:01:21 | Re: Trouble with SQL statement using variable |
Previous Message | Frank Bax | 2002-01-29 19:09:32 | Re: Trouble with SQL statement using variable |