php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8513 Call to undefined function: mssql_field_name()
Submitted: 2001-01-02 05:49 UTC Modified: 2001-01-02 18:32 UTC
From: parentjp at pjp dot dhs dot org Assigned:
Status: Closed Package: MSSQL related
PHP Version: 4.0.4 OS: Debian GNU/Linux kernel 2.2.17
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: parentjp at pjp dot dhs dot org
New email:
PHP Version: OS:

 

 [2001-01-02 05:49 UTC] parentjp at pjp dot dhs dot org
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); 

?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-02 05:54 UTC] parentjp at pjp dot dhs dot org
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 18:32 UTC] fmk@php.net
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)
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Jan 29 02:03:33 2022 UTC