RE: [PHP-DB] Puzzled by MSSQL
| From: | Troy Settle | Date: | Mon, 16 Oct 2000 18:09:41 +0000 |
| Subject: | RE: [PHP-DB] Puzzled by MSSQL | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-3651@lists.php.net to get a copy of this message | ||
Try this code:
$resultado = mssql_query($sql);
$i = 0;
if (mssql_num_rows($resultado) > 0) {
while ($this_row = mssql_fetch_array($resultado)) {
print $i++ . ": $this_row[PageID] = $this_row[Name] <BR>\n";
}
}
else {
print "No results!";
}
Normally, I'd help pick apart to see where the code was broken, but I'm
pressed for time right now.
Hope this helps,
--
Troy Settle
Pulaski Networks
540.994.4254
It's always a long day, 86400 doesn't fit into a short
> -----Original Message-----
> From: Alexandre Siufy [mailto:alex@tiaxa.net]
> Sent: Monday, October 16, 2000 4:58 PM
> To: Troy Settle
> Subject: RE: [PHP-DB] Puzzled by MSSQL
>
>
> The query looks like this:
>
> SELECT PageID, Name
> FROM tpPages
> WHERE Target = 'Chile'
>
> And the result is this:
>
> PageID Name
> ----------- --------------------------------------------------
> 198 Test Page
> 199 Test Page 2
>
> (2 row(s) affected)
>
> Again, the script grabs the first row, displays it, then as
> it tries to get
> the 2nd row, I get the error message...
>
> -----Original Message-----
> From: Troy Settle [mailto:troy@psknet.com]
> Sent: Monday, October 16, 2000 10:19 AM
> To: alex@tiaxa.net; php-db@lists.php.net
> Subject: RE: [PHP-DB] Puzzled by MSSQL
>
>
>
> What does your query look like, and which line is line 27 ?
>
>
> --
> Troy Settle
> Pulaski Networks
> 540.994.4254
>
> It's always a long day, 86400 doesn't fit into a short
>
>
>
> > -----Original Message-----
> > From: Alexandre Siufy [mailto:alex@tiaxa.net]
> > Sent: Monday, October 16, 2000 2:55 PM
> > To: php-db@lists.php.net
> > Subject: [PHP-DB] Puzzled by MSSQL
> >
> >
> > Hi folks,
> >
> > I'm having this weird problem connecting to a MS SQL Server
> > 7.0 database,
> > from 4.02 on Linux...
> > Here's a snippet of code:
> >
> > $resultado = mssql_query($sql);
> > $numero_pages = mssql_num_rows($resultado);
> >
> > $this_row=array();
> >
> > if ($numero_pages > 0) {
> > for ($i; $i <= $numero_pages; $i++) {
> > $this_row = mssql_fetch_array($resultado);
> > $pagina_id = $this_row["PageID"];
> > $pagina[$pagina_id] = $this_row["Name"];
> > print $i . " " . $pagina_id . " " . $pagina[$pagina_id];
> > }
> > }
> > else {
> > print "No results!";
> > }
> >
> > The table I'm pulling this stuff from has only 2 rows (I
> > verified the
> > SELECT statement on Microsoft's SQL Console thing), but I'm only able to
> > pull the 1st row. When the script tries to fetch the 2nd row, I get this
> > error:
> >
> > Warning: 2 is not a valid Sybase result resource in db1.php on line 27
> >
> > I'm sure I'm doing something wrong, but I simply can't see it...
> > Appreciate your help...
> >
> > --
> > alexandre siufy
> > lead developer
> > tiaxa.com / www.tiaxa.com
> > (305) 665 1055
> >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-db-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
> >
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>