Skip site navigation (1) Skip section navigation (2)

Re: HTML FORMS selected question

From: "Randy Moller" <zoomerz(at)comcast(dot)net>
To: "'Mag Gam'" <magawake(at)gmail(dot)com>
Cc: <pgsql-php(at)postgresql(dot)org>
Subject: Re: HTML FORMS selected question
Date: 2006-12-04 00:23:25
Message-ID: 20061204002333.056109F9F47@postgresql.org (view raw or flat)
Thread:
Lists: pgsql-php
Ok, I think you are misunderstanding the process:

 

1.	first, you are querying a database (I assume a postgres db) like
this:

 

$result = pg_query($dbconn, “select…”) , so,

 

$result now is a “resource reference” which contains the “result” of the
query. However, now you need to tell php to return the contents of that
resource to you (you can return in either an indexed, associative, or object
array). So, to get your “array”, you now use $result like this:

 

$myArray = pg_fetch_array($result);

 

Now $myArray is the actual “row/s” you returned in $result.

 

Does that make sense?

 

So, when you first query, $result (or $result_ip) = pg_query(conn, sql), you
need to be consistent with your variables. Either use $result_ip, or
$result, but not both….My guess is that’s your problem.

 

Hope that helps!

Randy

   _____  

From: pgsql-php-owner(at)postgresql(dot)org [mailto:pgsql-php-owner(at)postgresql(dot)org]
On Behalf Of Mag Gam
Sent: Sunday, December 03, 2006 5:01 PM
To: Chris
Cc: Randy Moller; pgsql-php(at)postgresql(dot)org
Subject: Re: [PHP] HTML FORMS selected question

 

Chris + Randy:

Sorry, I may of forgetten to give you this:
$result = pg_query($dbconn, "select id,address from ip");

This is right before the:
$options=pg_fetch_array($result_ip);

so, my $results is really all the ip addresses ($rows after I perform the
pg_fetch_array). 

I will add the var_dump to see it (never done it before, I will do some
googling :) )







On 12/3/06, Chris <HYPERLINK "mailto:dmagick(at)gmail(dot)com" dmagick(at)gmail(dot)com>
wrote:

Mag Gam wrote:
> Randy + Chris:
>
> Thx for the quick replies! 
>
> Chris:
>
> $rows contain ip addresses (postgresql inet) type (example: HYPERLINK
"http://192.168.0.1"192.168.0.1
> <HYPERLINK "http://192.168.0.1"http://192.168.0.1>)
> $options contain ip addresses (postgresql inet0 type (example: HYPERLINK
"http://127.0.0.1"127.0.0.1
> <HYPERLINK "http://127.0.0.1"http://127.0.0.1>)
> (keep in mind) they are both arrays. $rows contact all ips, and $options
> contact the ip addresses that were selected 
>
> Randy:
> I am not sure what you mean. The variables look right. I am getting no
> errors! Just the logic is messed up.

I think Randy's right.

At the top you have:

//The values that need to be selected 
$result_ip=pg_query($dbconn,$test_query);
^^^^^^^^^
but you are doing this:

while ($row = pg_fetch_array($result)) {


$result_ip  at the top, $result in the second bit.


If you don't see errors, turn up error reporting & display errors: 

error_reporting(E_ALL);
ini_set('display_errors', true);


Also that's not what I meant. I meant add a var_dump or print_r at each
stage to see what you are *really* getting from the code.


--
Postgresql & php tutorials
HYPERLINK "http://www.designmagick.com/"http://www.designmagick.com/

 

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.430 / Virus Database: 268.15.6/565 - Release Date: 12/2/2006
9:39 PM


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.430 / Virus Database: 268.15.6/565 - Release Date: 12/2/2006
9:39 PM
 

In response to

pgsql-php by date

Next:From: ChrisDate: 2006-12-04 00:25:59
Subject: Re: HTML FORMS selected question
Previous:From: Mag GamDate: 2006-12-04 00:00:45
Subject: Re: HTML FORMS selected question

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group