Solved

is there a same function for mssql_fetch_field and mssql_fetch_assoc in sql 2005 (odbc)

Posted on 2008-10-02
3
544 Views
Last Modified: 2008-10-14
hello:

i am using ODBC connection in sql 2005. the following code, when i used in sql 2005, it shows invalid.

could some expert tell if is there a sinmiar function for mssql_fetch_field and mssql_fetch_assoc?

code attached.

thnak you so much
while ($row = mssql_fetch_field($result)) {

		echo($row->name."\t");

	}

	echo("\n");

	

	while ($row = mssql_fetch_assoc($result)) {

		foreach($row as $key=>$val) {

			$output = ($key == 'Address') ? '"'.str_replace('|', chr(10), $val).'"'."\t" : $val."\t";

					}

Open in new window

0
Comment
Question by:lilyyan
  • 2
3 Comments
 
LVL 16

Expert Comment

by:brad2575
ID: 22627526
0
 

Author Comment

by:lilyyan
ID: 22627750
i want to get the columns' names, but the following is not working

would you please help check? thank you so much!!
$SQL="SELECT * FROM mytable";

$result = odbc_exec($dsn, $SQL);

$result =odbc_fetch_array ($result);

$countField=1;

for (int $k=0; $k<sizeof($result); $k++){

echo odbc_field_name ($result , $countField )."\t";

$countField++;

}

	echo("\n")

Open in new window

0
 
LVL 16

Accepted Solution

by:
brad2575 earned 500 total points
ID: 22632706
Here you go:

http://us2.php.net/manual/en/function.odbc-columns.php


and here is a full list of all the ODBC connection functions:
http://us2.php.net/odbc
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SSRS report parameters set after publishing to report manager 1 50
Isolation level in SQL server 3 47
Why is the output of this function is like this? 4 29
Sql query 107 29
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now