★ wanayoo — archive 1999 http://www.php.net/manual/ref.mssql.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Function Reference
Quick Reference
German version of this pageJapanese version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
Function Reference
* Apache
* Arrays
* Aspell
* BC math
* Calendar
* CCVS
* COM
* Classes/Objects
* ClibPDF
* CURL
* Cybercash
* dba
* Date/time
* dBase
* DBM
* Directories
* Dyn.loading
* DOM XML
* filePro
* Filesystem
* FDF
* FTP
* gettext
* HTTP
* Hyperwave
* ICAP
* Graphics
* IMAP
* Informix
* InterBase
* LDAP
* Mail
* Math.
* MCAL
* mcrypt
* mhash
* MS SQL Server
* Misc.
* mSQL
* MySQL
* Network
* ODBC
* Oracle
* OCI8
* PDF
* Verisign Payflow Pro
* PHP options/info
* POSIX
* PostgreSQL
* Program Execution
* Pspell
* readline
* Recode
* PCRE
* Regexps
* Semaphore
* Sessions
* SWF
* SNMP
* Strings
* Sybase
* URLs
* Variables
* Vmailmgr
* WDDX
* XML
* YAZ
* YP/NIS
* Zlib
Manual: Microsoft SQL Server functions
View the source code for this pageSearch the site



Previous page
 mhash
 Updated
Sat, 12 Aug 2000
mssql_close 
Next page


XXXVII. Microsoft SQL Server functions

Table of Contents
mssql_close — Close MS SQL Server connection
mssql_connect — Open MS SQL server connection
mssql_data_seek — Move internal row pointer
mssql_fetch_array — Fetch row as array
mssql_fetch_field — Get field information
mssql_fetch_object — Fetch row as object
mssql_fetch_row — Get row as enumerated array
mssql_field_length — Get the length of a field
mssql_field_name — Get the name of a field
mssql_field_seek — Set field offset
mssql_field_type — Get the type of a field
mssql_free_result — Free result memory
mssql_get_last_message — Returns the last message from server (over min_message_severity?)
mssql_min_error_severity — Sets the lower error severity
mssql_min_message_severity — Sets the lower message severity
mssql_num_fields — Get number of fields in result
mssql_num_rows — Get number of rows in result
mssql_pconnect — Open persistent MS SQL connection
mssql_query — Send MS SQL query
mssql_result — Get result data
mssql_select_db — Select MS SQL database

User Contributed Notes: Microsoft SQL Server functions


myconid@together.net
19-Nov-1999 01:56
Hello, I am a PHP developer. I play with PHP out of a personal interest, and run it on my workstation that has MSSQL 7 installed. I really like MSSQL and have found VERY little support with it. Therefor I am offering myself to anyone who wishes to contact me with help per MSSQL. [Im not a pro, but I do know how to use MSSQL, and there is little other info on the net.]. Feel free to email me, or ICQ @ 7008466.


Bernhard.Bock@ThePentagon.com
08-Jan-2000 12:19
Hi there!

Why isn't it possible to do some transactions with mssql (commit, rollback)?
I hope this will be available soon...

Greetingz - Bernhard Bock



camber@ais.org
11-Feb-2000 03:02
To access MS SQL from Unix you may use Sybase's OpenClient which happens to work (depending on platform, 7.0 needs SP1 and big endian platforms have trouble) or FreeTDS (www.freetds.org) which is still alpha-ish but directly supports MS SQL.


klaus@silberbauer.dk
03-Mar-2000 09:56
Hi. On win32: When enabling the php3_mssql library in php3.ini, make sure you've got the ntwdblib.dll in %systemroot%\system32. Otherwise php.exe will fail when executing calls to the php3_mssql.dll.


myconid@sover.net
23-Mar-2000 04:22
MiniFAQ. I get a lot of messages asking for basic help that is provided here. To use PHP on Win32 you must EDIT php3.ini. ITS IN THE DOCS, READ THEM. TO use PHP on Linux you must download RPM's from Sybase (see mssql_connect). To use a MSSQL server on another machine, make sure you have installed a MSSQL client or it will fail without an error message. Thanks.


stefan@paybycheck.com
18-Apr-2000 10:07
The MSSQL module is included with the binary distribution of PHP 3.x



jhamann@sfresearch.com
20-Apr-2000 09:49
I have just finished setting up php4 with freetds to connect to a MSSQL 7 server. I used freetds 5.0 and configured with --with-tdsver=7.0


jsteele@writeme.com
24-Apr-2000 04:57
For PHP4, Frank M. Kromann has the modules available at:

http://download.swwwing.com/php4/modules/

For PHP3, use http://download.swwwing.com/php3/



cgi@harrison.org
30-Apr-2000 11:45
Update: PHP4, MSSQL, WIN32

The PHP_MSSQL.DLL isn't needed unless your compiling your own for various uses. The functions are already available. Don't uncomment the line in the php.ini file for php_mssql.dll or you might see errors.


As far as I can tell the MSSQL functions don't work. At least not in PHP4 RC1. I have had success using the ODBC functions to connect to the SQL database. Just make sure you can connect properly with the system DSN defined in the ODBC control panel first.


Hope this helped a little. =)



greg@stargig.com
30-Jun-2000 06:24
i have succesfully done two major projects using php and mssql. however i used the odbc calls. they work fine and although slower than a direct connect you do get the advantage of support for two phase commits.

greg walsh



tj11189@hotmail.com
03-Jul-2000 04:39
People seeling the mssql dll should be advised that php4 ships with php_mssql70.dll


bookslash.com
05-Jul-2000 03:42
Right! php_mssql70.dll works and is included with v4.01p2.


All you have to do is set the php.ini setting about the MS SQL extension as follows:


[MSSQL]

extension=php_mssql70.dll ;
mssql.allow_persistent = On ; allow or prevent persistent link

mssql.max_persistent = -1 ; maximum number of persistent links. -1 means no limit




and make sure you have the extension dir pointed to your dir where your dll files are. Then it should work...mine does.



caspian_@hotmail.com
06-Jul-2000 10:14
To compile PHP to support M$SQL on LINUX:

-Download FreeTDS: www.freetds.org
and compile as required. Make sure to compile with the correct version of the protocol (read the readme)

-Compile PHP with '--with-sybase=/usr/local/freetds' or wherever you put freetds.


PHP will now support both mssql_*** and sybase_*** from Linux.. enjoy!



wruslan@dectra.com.my
17-Jul-2000 02:07
<PRE>
<h1>TestSql.php</h1><hr>
This is a direct connection to the MS SQL7.0 database. Using PHPver4.01P2 on Win NT/IIS 4.0


&lt;?
// YOUR MSSQL 7.0 SERVER PARAMETERS
$hostname = "wruslan";
$username = "wruslanpubs";
$password = "wruslanpubs";

// YOUR MSSQL 7.0 DATABASE
$dbname = "pubs";
$tablename = "employee" ;

// CONNECT TO THE MSSQL 7.0 DATABASE
$connection = mssql_connect($hostname,$username,$password);
mssql_select_db($dbname);
$sql_query = "select * from $tablename" ;
$query_result =mssql_query($sql_query) ;
$number_rows = mssql_num_rows($query_result) ;
$number_fields = mssql_num_fields($query_result) ;

// TEST YOUR QUERY
if($number_rows == 0) :
print "
The query does not produce any data row !

" ;
elseif ($number_rows > 0) :
print "
Yes there are " . $number_rows . " rows resulting from the query.

" ;
endif ;

// DISPLAY TABLE FIELD HEADERS
print "<table border><tr><th>row</th>" ;
for ($field_number = 0 ; $field_number <= $number_fields - 1 ; $field_number++ )
{
$field_name = mssql_field_name($query_result, $field_number) ;
print "<th>" . $field_name . "</th>" ;
}
print "</tr>" ;

// DISPLAY INDIVIDUAL ROWS - POPULATING THE TABLE
for ($row_number = 0 ; $row_number <= $number_rows - 1 ; $row_number++)
{
print "<tr><td>" . $row.number . "</td>" ;
for ($field_number = 0 ; $field_number <= $number_fields - 1 ; $field_number++)
{
print "<td>" . mssql_result($query_result, $row_number, $field_number) . "</td>" ;
}
print "</tr>" ;
}
print "</table>" ;


mssql_close($connection);

?>

<hr>
All the best to you. .... Alhamdulillah ... wruslan ... 17 July 2000 ....
<hr></PRE>



high_impedance@yahoo.de
21-Jul-2000 07:23
FACT: The MS SQL functions does not work in PHP4.0pl2 definitely! I read about this failure in several forums and newsgroups. There is only one solution: use ODBC-Functions instead! To connect the MS SQL Server with ODBC you have to install your database under System-DSN. The next steps are quite easy and might not be a problem.


mqbeers@usa.net
24-Jul-2000 07:11
hmmm, I haven't had any problems connecting, executing or doing anything with MSSQL in rl2. It does work (on all the machines in my office anyway). It might be the set of dlls on the machine. For example we all have the enterprise manager installed, so our versions of the mssql dlls might be later than what you have. Just a thought.


cgi@harrison.org
25-Jul-2000 08:16
Okay !!! Hey everyone I got it working ... I mean I was having problems getting PHP to recognize the MSSQL Functions but I have them working now.

I will post a resolution as soon as I narrow down exactly what I did to fix it. One thing for sure is the reference in the php.ini must be edited.

extension=php_mssql.dll should read extension=php_mssql70.dll

Then all that might be needed is too stop the IIS Admin service and its associates, then start the Web service again.

I'm running Windows NT workstation, my php.ini is located in \WINNT, NOT \WINNT\SYSTEM32 like the .dll(s). I also have all the .dll(s) in the same directory as where I'm executing php4isapi.dll and php.exe.

Anyway, I'll post again later with more definate conclusions. Hope this helps!

- Jason



cgi@harrison.org
25-Jul-2000 11:23
MSSQL Server Functions ARE Available and actually work!


STEP 1: Follow the README.txt include with the php-4.0.1pl2-Win32.zip file.


STEP 2: Make sure you copy the .dll(s) you want to use LIKE php_mssql70.dll to the SYSTEM directory (eg: C:\WINDOWS\SYSTEM or C:\WINNT\SYSTEM32).


STEP 3: Copy and rename the php.ini-dist to the WINDOWS (C:\WINDOWS or C:\WINNT) folder. This file should be named php.ini (in other words remove the -dist).


STEP 4: Edit the php.ini and un-comment or add an extension=php_mssql70.dll (this calls the appropiate .dll from the SYSTEM path therefore this php_mssql70.dll must be in the SYSTEM folder. The php.ini must also call the correct name of the file (php_mssql70.dll) not php_mssql.dll). This entry is found in two places but must only be added to one or the other. (Windows Extensions and [MSSQL])


STEP 5: STOP ALL w3svc(s) including, especially the IIS Admin service. ('net stop iisadmin'). Then start the w3svc service which will also start the IIS Admin service.


In the event that I missed something .. or you did .. try reading the README.txt
That is all. Thank You.
- Jason



luciano@netsolution.com.ar
27-Jul-2000 03:20
There are two thing in my mind: 1) How come there is no mssql_affected_rows() function.. how can I get the number of rows that where updated/deleted?? mssql_num_rows() works with select statements only.. In mysql there is a mysql_affected_rows() but what about MS-SQL. and 2) When I make a "SELECT * FROM users" I can't get all the fields in an array, after the query/fetch_row the array is empty, but if I make the "SELECT id,name,last,tel FROM user" I get all the fields in the array.. but I have to enumerate all of them....

Thanks for the help.... Keep up the good work..Luciano Ramos. luciano@netsolution.com.ar



 About Notes


Previous page
 mhash
 Updated
Sat, 12 Aug 2000
mssql_close 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.