pg_fetch_array etc
| From: | Dan Harrington | Date: | Sat, 16 Dec 2000 18:57:43 +0000 |
| Subject: | pg_fetch_array etc | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-30563@lists.php.net to get a copy of this message | ||
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&ke
ywords=water+fire
I know that just 1 row results....
select * from generator where orientation like '%both%' and category like
'%nature%' and keywords like '%water%' and keywords like '%
fire%';
----------------------------------------------------------------------------
---------------------------
clip | title | image | height | width | orientation |
artist | keywords | quality | category | prints
------+----------------+--------------------+--------+-------+-------------+
--------+----------------------+---------+----------+--------
| Flaming Person | images/flaming.gif | 133 | 200 | both |
| water fire earth air | | nature |
(1 row)
----------------------------------------------------------------------------
---------------------------
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