[PHP-DEV] PHP 4.0 Bug #8513 Updated: Call to undefined function: mssql_field_name() From: fmk <email protected>
Date: 01/02/01

ID: 8513
Updated by: fmk
Reported By: parentjp <email protected>
Old-Status: Open
Status: Closed
Bug Type: MSSQL related
Assigned To:
Comments:

This is not a MSSQL related error. You are using the sybase extension where aliases named mssql_* can be used. You should use sybase_fetch_field or mssql_fetch_field. Look at the Sybase documentation to find supported functions.

mssql_field_name is only available when using the mssql extension (so far only available on Win32)

Previous Comments:
---------------------------------------------------------------------------

[2001-01-02 05:54:52] parentjp <email protected>
Meanwhile, those who have this problem can use mssql_fetch_field() function to obtain field info and then using the name method (See annotated manual for a small example)...

Hope it helps.

---------------------------------------------------------------------------

[2001-01-02 05:49:44] parentjp <email protected>
I'm getting this error with my installation of PHP 4.0.4. I heard it doesnt work in 4.0.2 too. mssql_fetch_field($query, $field_number)->name works though...

I use freeTDS 0.51 for the client stuff needed for connection on a remote MS SQL 7 server and used --with-tdsver=7.0 at freeTDS compilation for protocol 7.0.

Here's the script (got to modify login, pass, db and hostname vars at beginning):

<PRE>
<h1>TestSql.php</h1><hr>
This is a direct connection to the MS SQL7.0 database. Using PHPver4.01P2 on Win NT/IIS 4.0

<?
// YOUR MSSQL 7.0 SERVER PARAMETERS
$hostname = "wruslan";
$username = "wruslanpubs";
$password = "wruslanpubs";

// YOUR MSSQL 7.0 DATABASE
$dbname = "pubs";
$tablename = "employee" ;

// CONNECT TO THE MSSQL 7.0 DATABASE
$connection = mssql_connect($hostname,$username,$password);
mssql_select_db($dbname);
$sql_query = "select * from $tablename" ;
$query_result =mssql_query($sql_query) ;
$number_rows = mssql_num_rows($query_result) ;
$number_fields = mssql_num_fields($query_result) ;

// TEST YOUR QUERY
if($number_rows == 0) :
print "
The query does not produce any data row !

" ;
elseif ($number_rows > 0) :
print "
Yes there are " . $number_rows . " rows resulting from the query.

" ;
endif ;

// DISPLAY TABLE FIELD HEADERS
print "<table border><tr><th>row</th>" ;
for ($field_number = 0 ; $field_number <= $number_fields - 1 ; $field_number++ )
{
//**************************************
//THE FOLLOWING LINE CAUSES THE PROBLEM!
//**************************************
$field_name = mssql_field_name($query_result, $field_number) ;
print "<th>" . $field_name . "</th>" ;
}
print "</tr>" ;

// DISPLAY INDIVIDUAL ROWS - POPULATING THE TABLE
for ($row_number = 0 ; $row_number <= $number_rows - 1 ; $row_number++)
{
print "<tr><td>" . $row.number . "</td>" ;
for ($field_number = 0 ; $field_number <= $number_fields - 1 ; $field_number++)
{
print "<td>" . mssql_result($query_result, $row_number, $field_number) . "</td>" ;
}
print "</tr>" ;
}
print "</table>" ;

mssql_close($connection);

?>

---------------------------------------------------------------------------

Full Bug description available at: http://bugs.php.net/?id=8513

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>