Solved

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

Posted on 2008-10-02
3
541 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
Comment Utility
0
 

Author Comment

by:lilyyan
Comment Utility
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
Comment Utility
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 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

7 Experts available now in Live!

Get 1:1 Help Now