Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-10-02
3
Medium Priority
?
565 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 2000 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

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 article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Loops Section Overview

972 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