Re: pg_fetch_array etc

From: Date: Fri, 15 Dec 2000 19:03:34 +0000
Subject: Re: pg_fetch_array etc
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-30564@lists.php.net to get a copy of this message
On Sat, 16 Dec 2000, Dan Harrington wrote: > Hello, > > I'm using PHP to grab some rows off a PostgreSQL server and return the > results....and for some reason this code > keeps looping and looping and looping forever when called from a webpage as > follows: > > > http://www.myservername.com/database.php?orientation=both&category=nature&keywords=water+fire > > [snip] > > and here is the code . . . why in the heck ? > > <? > $query = getenv("QUERY_STRING"); > parse_str($query); > > if ( $query != "" ) > { > $Query = "select * from generator where "; > $Query .= "orientation LIKE'%$orientation%' and category"; > $Query .= " LIKE '%$category%' and keywords LIKE '%$keywords%' > "; > > $Connection = pg_connect("", "", "", "", > "aaron"); > $Result = pg_exec($Connection, $Query); > > while ($Row = pg_fetch_row($Result, $Row)) > { > print("$Row[0], $Row[1], $Row[2], $Row[3]<br>\n"); > } > > } > pg_freeresult($Result); > pg_close($Connection); > ?> > > ------------- > I'm aware that I should strip certain characters right after I > genenv("QUERY_STRING") for security's sake...I just > want the stupid thing to work before I implement those features. > > Why does it loop forever? > > Thanks > Dan Harrington > Some questions: 1) How do you know that it loops forever? 2) Why aren't you using $HTTP_GET_VARS? 3) Why are your pg_freeresult() and pg_close() calls outside of the if? -- Ignacio Vazquez-Abrams <ignacio@openservices.net>

« previous php.general (#30564) next »