Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

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
?
560 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 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

721 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