Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 820A69F9FDA for ; Sun, 3 Dec 2006 20:23:44 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 23704-04 for ; Sun, 3 Dec 2006 20:23:17 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [216.148.227.151]) by postgresql.org (Postfix) with ESMTP id 056109F9F47 for ; Sun, 3 Dec 2006 20:23:32 -0400 (AST) Received: from ramlap (c-24-2-109-170.hsd1.mn.comcast.net[24.2.109.170]) by comcast.net (rwcrmhc11) with SMTP id <20061204002330m1100sn05be>; Mon, 4 Dec 2006 00:23:30 +0000 From: "Randy Moller" To: "'Mag Gam'" Cc: Subject: Re: HTML FORMS selected question Date: Sun, 3 Dec 2006 17:23:25 -0700 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_001E_01C716FF.BDB696C0" X-Mailer: Microsoft Office Outlook, Build 11.0.5510 In-Reply-To: <1cbd6f830612031600xb902e5fgf3eb485a8af59a@mail.gmail.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 Thread-Index: AccXN00/cr3BnpKdRve83P4oTtT4wgAAfpQg Message-Id: <20061204002333.056109F9F47@postgresql.org> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.522 tagged_above=0 required=5 tests=AWL, BAYES_50, DNS_FROM_RFC_POST, HTML_MESSAGE, HTML_TEXT_AFTER_BODY, MSGID_FROM_MTA_ID, NORMAL_HTTP_TO_IP X-Spam-Level: ** X-Archive-Number: 200612/8 X-Sequence-Number: 3676 This is a multi-part message in MIME format. ------=_NextPart_000_001E_01C716FF.BDB696C0 Content-Type: text/plain; charset="windows-1250" Content-Transfer-Encoding: quoted-printable Ok, I think you are misunderstanding the process: =20 1. first, you are querying a database (I assume a postgres db) like this: =20 $result =3D pg_query($dbconn, =93select=85=94) , so, =20 $result now is a =93resource reference=94 which contains the = =93result=94 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 =93array=94, you now use $result like this: =20 $myArray =3D pg_fetch_array($result); =20 Now $myArray is the actual =93row/s=94 you returned in $result. =20 Does that make sense? =20 So, when you first query, $result (or $result_ip) =3D pg_query(conn, = sql), you need to be consistent with your variables. Either use $result_ip, or $result, but not both=85.My guess is that=92s your problem. =20 Hope that helps! Randy _____ =20 From: pgsql-php-owner@postgresql.org = [mailto:pgsql-php-owner@postgresql.org] On Behalf Of Mag Gam Sent: Sunday, December 03, 2006 5:01 PM To: Chris Cc: Randy Moller; pgsql-php@postgresql.org Subject: Re: [PHP] HTML FORMS selected question =20 Chris + Randy: Sorry, I may of forgetten to give you this: $result =3D pg_query($dbconn, "select id,address from ip"); This is right before the: $options=3Dpg_fetch_array($result_ip); so, my $results is really all the ip addresses ($rows after I perform = the pg_fetch_array).=20 I will add the var_dump to see it (never done it before, I will do some googling :) ) On 12/3/06, Chris wrote: Mag Gam wrote: > Randy + Chris: > > Thx for the quick replies!=20 > > Chris: > > $rows contain ip addresses (postgresql inet) type (example: HYPERLINK "http://192.168.0.1"192.168.0.1 > ) > $options contain ip addresses (postgresql inet0 type (example: = HYPERLINK "http://127.0.0.1"127.0.0.1 > ) > (keep in mind) they are both arrays. $rows contact all ips, and = $options > contact the ip addresses that were selected=20 > > 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=20 $result_ip=3Dpg_query($dbconn,$test_query); ^^^^^^^^^ but you are doing this: while ($row =3D 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:=20 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/ =20 -- 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 --=20 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 =20 ------=_NextPart_000_001E_01C716FF.BDB696C0 Content-Type: text/html; charset="windows-1250" Content-Transfer-Encoding: quoted-printable

Ok, I think you are = misunderstanding the process:

 

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

 

$result =3D 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 =3D = 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) =3D 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@postgresql.org [mailto:pgsql-php-owner@postgresql.org] = On Behalf Of Mag Gam
Sent: Sunday, December = 03, 2006 5:01 PM
To: Chris
Cc: Randy Moller; pgsql-php@postgresql.org
Subject: Re: [PHP] HTML = FORMS selected question

 

Chris + = Randy:

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

This is right before the:
$options=3Dpg_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 < dmagick@gmail.com> = wrote:

Mag Gam wrote:
> Randy + Chris:
>
> Thx for the quick replies!
>
> Chris:
>
> $rows contain ip addresses (postgresql inet) type (example: 192.168.0.1
> <http://192.168.0.1>)
> $options contain ip addresses (postgresql inet0 type (example: 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=3Dpg_query($dbconn,$test_query);
^^^^^^^^^
but you are doing this:

while ($row =3D 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
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

------=_NextPart_000_001E_01C716FF.BDB696C0--