Received: from visi.net (arsenal.visi.net [206.246.194.60]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g0TK1Ol20771 for ; Tue, 29 Jan 2002 15:01:24 -0500 (EST) (envelope-from jself@nngov.com) X-Virus-Scanner: McAfee Virus Engine Received: from [216.54.6.254] (HELO localhost.localdomain) by visi.net (CommuniGate Pro SMTP 3.5) with ESMTP id 13413772; Tue, 29 Jan 2002 15:00:14 -0500 Subject: Re: Trouble with SQL statement using variable From: Jeff Self To: Frank Bax Cc: pgsql-php@postgresql.org In-Reply-To: <3.0.6.32.20020129140932.020a06c0@pop6.sympatico.ca> References: <3.0.6.32.20020129140932.020a06c0@pop6.sympatico.ca> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Evolution/1.0.1 Date: 29 Jan 2002 15:01:21 -0500 Message-Id: <1012334482.14649.4.camel@personnel_test> Mime-Version: 1.0 X-Archive-Number: 200201/89 X-Sequence-Number: 892 I solved it. I had to pass the $conn when calling the function. 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()? > > 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 > > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster -- Jeff Self Information Technology Analyst Department of Personnel City of Newport News 2400 Washington Ave. Newport News, VA 23607 757-926-6930