Solved

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

Posted on 2008-10-02
3
550 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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql calculate reminders 11 73
SQL Merige returns error code when updating 15 53
Impove long SQL Stored Procedure Performance 14 75
T-SQL to Update Table Dynamically 2 47
If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

773 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