Re: Trouble with SQL statement using variable - Mailing list pgsql-php

From Frank Bax
Subject Re: Trouble with SQL statement using variable
Date
Msg-id 3.0.6.32.20020129140932.020a06c0@pop6.sympatico.ca
Whole thread Raw
In response to Trouble with SQL statement using variable  (Jeff Self <jself@nngov.com>)
Responses Re: Trouble with SQL statement using variable  (Jeff Self <jself@nngov.com>)
Re: Trouble with SQL statement using variable  (Jeff Self <jself@nngov.com>)
List pgsql-php
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()?

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
>

pgsql-php by date:

Previous
From: Jeff Self
Date:
Subject: Trouble with SQL statement using variable
Next
From: Jeff Self
Date:
Subject: Re: Trouble with SQL statement using variable