|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-01-02 05:54 UTC] parentjp at pjp dot dhs dot org
[2001-01-02 18:32 UTC] fmk@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 18:00:01 2025 UTC |
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); ?>