Method for connecting to sqlserver2000 in versions later than php5.3 _ php instance

Source: Internet
Author: User
This article describes how to connect to sqlserver2000 in php5.3 and later versions, including common solutions for php5.4 and php5.5, for more information about how to use php to connect to the sqlserver2000 database, visit a system that recently created a system to capture the data of several tables in the Butler database and display the data on the web page, many textbooks on the Internet require php configuration. ini configuration file, remove; extension = php_mssql.dll; ", copy and paste php_mssql.dll in the ext file to the system32 directory of the system disk, and then restart the apache server, then write the code to connect to the database: <? Php $ conn = mssql_connect ("server", "database username", "database password"); mssql_selected ('"", $ conn);?> Generally, the server is written in the format of "ip, port number", which can be written as localhost, port or 127.0.0.1. as for how to write data according to your own situation, we hereby declare that the above connection to the SQL Server database is only available in php version 5.3. If you are connected to a version later than 5.3, it is not supported by php5.3 or later. The following describes how to connect to a database of sqlserver2000 or a later version of php5.3.

How can I connect to the sqlserver database in php5.3 or later versions? I have also found a lot of information about the download driver. The driver is only for the sqlserver2005 or 2008 database version, and Microsoft does not provide the relevant support driver for the sqlserver2000 version, at least I did not find it. if you want to talk about it later, let's take a look at my php5.3 and later methods for connecting to sqlserver2000. In fact, it is easy to connect to the 2000 database using odbc. Next, you need to configure the data source, open the Control Panel, find the management tool, open the management tool, and double-click open data source (ODBC ),

Select system DSN and click add

Select SQL server and next. of course, if you are using another database, such as access, you choose the acess driver.

The name must be written, which is a required parameter for you to write code to connect to the database. The server must also be selected. if it is the local machine, select the visible name if it is another machine.

The login ID must be written, that is, the name used to access your database. the password is also the password used to access the database. if there is a login ID, write it. if there is no login ID, leave it blank. then, the next step will be completed, test the connection. if you click "test connection", congratulations. your connection to sqlserver2000 with php5.3 or later is successful. The next step is to write the database connection code.

The code I wrote is directly attached below for your reference:

<? Php $ conn = odbc_connect ("name of the data source just configured", "name of the database accessed", "password of the database accessed"); $ SQL = "select * from table name "; $ exec = odbc_exec ($ conn, $ SQL); // execute the statement while (odbc_fetch_array ($ exec) {$ abc = odbc_result ($ exec, '"data table field name"); echo $ abc ...}

I hope this article will be helpful to anyone who needs it. I have summarized this article and found a lot of information. it should be said that it is the most detailed article connecting php5.3 and later versions to sqlserver2000.

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.