Solved

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

Posted on 2008-10-02
3
554 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
spx for moving values to new table 5 76
how many extra RAM for SQL server is needed 23 49
Set the max value for a column 7 43
ms sql + top 1 for each customer 3 70
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

739 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