Php5.3 how to connect to sqlserver2000_PHP tutorial

Source: Internet
Author: User
Php5.3 how to connect to sqlserver2000. We know that the new version of php5.3 does not support the data connection function mssql_connect provided by mysql. to connect to the sqlserver database, we can only use the com interface. 1. we know that the new version of php5.3 does not support the data connection function mssql_connect provided by mysql. to connect to the sqlserver database, we can only use the Com interface.

1. Com link, ADODB. Connection

The code is as follows:

$ Conn = new Com ("ADODB. Connection"); // instantiate a Connection object
$ Connstr = "provider = sqloledb; datasource =.; uid = sa; pwd = 123456; database = jnold ;";
$ Conn-> Open ($ connstr );
$ Rs = new Com ("ADODB. Recordset"); // instantiate a Recordcount object

$ Rs-> Open ('select * from News where bigclassid = 59 And LeadPostil is Null', $ conn, 1, 1 );
$ Count = $ rs-> RecordCount;
Echo "a total of {$ count} records
";
For ($ I = 0; $ I <$ count; $ I ++ ){

$ Arr_result [$ I] ['title'] = addslashes ($ rs-> Fields ('title')-> Value); // Title
$ Arr_result [$ I] ['color'] = addslashes ($ rs-> Fields ('titlecolor')-> Value? $ Rs-> Fields ('titlecolor')-> Value: "); // Title color
$ Arr_result [$ I] ['wenhao'] = addslashes ($ rs-> Fields ('othertext')-> Value); // Document No.

}

2. ODBC Connection mssql

The code is as follows:

$ Dbhost = ";
$ Dbuser = "; // your mssql user name
$ Dbpass = "; // your mssql password
$ Dbname = "; // your mssql database name

$ Connect = odbc_connect ("Driver = {SQL Server}; Server = $ dbhost; Database = $ dbname", "$ dbuser", "$ dbpass ");
$ SQL = "select * from content ";
$ Exec = odbc_exec ($ connect, $ SQL );
While ($ row = (odbc_fetch_array ($ exec )))
{
$ Row ['id'] //? Field value
...
}

You can use the DIG Interface. 1. Com chain...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.