Skip to Content.
Sympa Menu

freetds - [freetds] Re: Problem with using the mysql_num_rows and mysql_fetch_array

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: max <max.eaves AT bbc.co.uk>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] Re: Problem with using the mysql_num_rows and mysql_fetch_array
  • Date: Sun, 29 May 2005 21:40:28 +0100


Hi there,

I am running a local Fedora Core 3 box with FreeTDS / PHP and Apache. I
have successfully set up, configured FreeTDS, PHP (with graphic support)
and Apache (with PHP support) using the book SAM PHP, MySQL and Apache
book (sadly slightly out of date - as it references PHP4 instead of
PHP5).

The script I will paste onto the bottom of the screen broadly works, but
just doesn't present any data. I know that if I use mssql_result(),
FreeTDS uses that command and presents me back with some data (even
though it is only one line of one field).

In essence, I want to assume a couple of things - FreeTDS translates
mysql_fetch_array() and mysql_num_rows() when looking up information in
the database. I did have a look at the API's on the FreeTDS site, but
was slightly confused over what I should be using.


<html>
<body>
<?php
$con = mssql_connect ("192.168.1.1", "sa", "");
mssql_select_db ("PreSetLive", $con);
$sql = "SELECT * FROM PST_Channels";
$rs = mssql_query ($sql, $con) or die (mysql_error());;
//$numberofrows = @mysql_num_rows($rs);
//echo "The number of rows are $numberofrows";
echo "The information from bbcdbms105 is: ";
echo mssql_result ($rs, 0, 0);
echo mssql_result ($rs, 1, 0);
//while ($outputarray = @mysql_fetch_array($rs)) {
// echo $outputarray;
//}
mssql_close ($con);
?>
</body>
</html>

The current script works well by displays some output, but the stuff
that is hashed // out [the while loop] is not so good. It just returns
blank. If I remove the @ from mysql_fetch_array(), then I get an error
message -

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource

I found something on this on the internet:
http://www.osticket.com/forums/showthread.php?t=689

I am not sure how relevant this is to my problem though.

Can someone please give me a guiding hand.

Best Wishes



Max
_________________________________________________

Max Eaves | System Specialist IBS | Broadcast Centre Rapid Response
Engineer

BBC Broadcast | BC1-B1 | Broadcast Centre | Wood Lane, LONDON W12 7TP







Archive powered by MHonArc 2.6.24.

Top of Page