PHP pg_fetch_assoc() complaining about parameters
Lonni J Friedman
netllama
Wed Jul 25 08:34:15 PDT 2007
Thanks Steve, the double quotes around the variables in the function
call were, in fact, the problem.
On 7/24/07, Steve Jardine <sjardine at acm.org> wrote:
> Lonni,
>
> Did you try getting rid of the quotes around the grabdata call?
>
> I.e. : grabData ($r_fdtd);
>
> I do not believe that the resource value that is returned from a pg_exec is a string. I believe it is a value. That is why it is used as a "resource" for pg_fetch_row, pg_fetch_assoc, etc. Try passing it as a "resource", which I think is a typed integer value. Might be wrong on that though.
>
> Steve
>
>
> On Tue, 24 Jul 2007 16:53:40 -0700
> "Lonni J Friedman" <netllama at gmail.com> wrote:
>
> > Hopefully one of you PHP wizards will find this easy. I've got this
> > PHP script that I'm writing. Its 100% functional, but since I'm
> > basically duplicating the same code across 3 variants of the script, I
> > figured I'd put the duplicated code into a single file, call it as an
> > include, and come out ahead. Sadly, i've had nothing but problems
> > with it since trying to move stuff into an include.
> >
> > In the included file, I've (currently) got a single function (called
> > grabData), with a while loop that looks like this:
> >
> > grabData ($r_fdtd) {
> > while($row=pg_fetch_assoc($r_fdtd)){
> > $data_fdtd[]=$row['norm'];
> > $xdata_fdtd[]=$row['date_created'];
> > }}
> >
> >
> > In the main PHP script, I've got the following:
> > $q_fdtd=("select * from fdtd where gpu='80' AND os='2.6.9-55.ELsmp'
> > ORDER BY date_created");
> > $r_fdtd=pg_exec($db, $q_fdtd);
> > grabData ("$r_fdtd");
> >
> > The big issue right now is the following error appears in the apache
> > error log every time the php script runs:
> > pg_fetch_assoc() expects parameter 1 to be resource, string given
> >
> > I can't figure out why the variable that I'm passing to the included
> > function is getting treated as a string when it should be a resource.
> > Anyone see what i'm doing wrong?
> >
> > thanks in advance.
> >
> > --
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
L. Friedman netllama at gmail.com
LlamaLand http://netllama.linux-sxs.org
More information about the Linux-users
mailing list