I feel like an idiot, I overlooked the *_fetch__array(). It's been a long
week...

Billy Rose 
[EMAIL PROTECTED]

> -----Original Message-----
> From: Gabriel Ricard [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, April 25, 2002 11:53 AM
> To: Rose, Billy
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP-DEV] foreach
> 
> 
> This is neither a problem with PHP nor FreeTDS. From the manual:
> 
> " sybase_fetch_array() is an extended version of 
> sybase_fetch_row(). In 
> addition to storing the data in the numeric indices of the 
> result array, 
> it also stores the data in associative indices, using the 
> field names as 
> keys. "
> 
> Therefore each row contains duplicates of each value. Use 
> sybase_fetch_row() instead.
> 
> And, btw, this question really belongs on the php-general list. ;)
> 
> - Gabriel
> 
> Rose, Billy wrote:
> > Environment:
> > 
> >   Apache 2.0.35
> >   PHP 4.2.0RC2
> >   FreeTDS used in place of Sybase libraries to connect to 
> MS SQL 2000
> >   RedHat Linux 7.1
> >   PII 233
> > 
> > Problem:
> > 
> >   Using foreach retrieves a duplicate of each database column.
> > 
> > Code tested:
> > 
> > <html>
> > <head>
> > <title>Test</title>
> > </head>
> > <body>
> > <?
> > $link = sybase_connect($dbhost,$dbuser,$dbpass)
> >   or die("Error connecting");
> > sybase_select_db($dbname)
> >   or die("Error selecting database");
> > $result = sybase_query($query)
> >   or die("Error running query");
> > print("<table border='0' width='100%' cellpadding='0' 
> cellspacing='4'>\n");
> > while ($row = sybase_fetch_array($result)) {
> >   print("<tr>\n");
> >   foreach ($row as $col) {
> >     print("<td>".$col."</td>\n");
> >   }
> >   print("</tr>\n");
> > }
> > print("</table>\n");
> > sybase_free_result($result);
> > sybase_close($link);
> > ?>
> > </body>
> > </html>
> > 
> > Is this a PHP issue, or a FreeTDS problem?
> > 
> > Billy Rose 
> > [EMAIL PROTECTED]
> > 
> 
> 
> 
> -- 
> Gabriel Ricard
> [EMAIL PROTECTED]
> 

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to