How to connect php to SQL Server2008 under Windows platform?
This article mainly introduces the method of connecting PHP to SQL Server 2008 on the Windows platform. It analyzes the relevant dll dynamic link library files and corresponding configuration and usage methods required for PHP to connect to SQL Server 2008 on the Windows platform in the form of examples. Friends in need You can refer to the following example
This article describes how to implement PHP connection to SQL Server2008 on the Windows platform. Share it with everyone for your reference, the details are as follows:
If you need to communicate with sql server, you need to download The SQL Server Driver for Microsoft provided by msdn.microsoft.com/en-us/sqlserver/ff657782.aspx PHP. This is a self-extracting file. After decompression, you will get the following files:
php_sqlsrv_52_nts_vc6.dll php_sqlsrv_52_ts_vc6.dll php_sqlsrv_53_nts_vc6.dll php_sqlsrv_53_nts_vc9.dll php_sqlsrv_53_ts_vc6.dll php_sqlsrv_53_ts_vc9.dll php_sqlsrv_license.rtf SQLServerDriverForPHP.chm SQLServerDriverForPHP_Readme.htm
##PS:You can also click here to download the above compressed file.
Among them, 52 and 53 represent the versions of PHP 5.2. Server. According to your configuration, copy the corresponding DLL file to the ext folder of the PHP installation directory, then open php.ini and add the following statements to open the php_sqlsrv and php_pdo_sqlsrv extensions:——————————————————– [PHP_PDO_SQLSRV] extension=php_pdo_sqlsrv_53_ts_vc6.dll [PHP_SQLSRV] extension=php_sqlsrv_53_ts_vc6.dll —————————————————
—————————————————————- [PHP_PDO_SQLSRV] extension=php_pdo_sqlsrv_53_nts_vc6.dll [PHP_SQLSRV] extension=php_sqlsrv_53_nts_vc6.dll —————————————————-
<?php //本地测试的服务名 $serverName = "(127.0.0.1)"; //使用sql server身份验证,参数使用数组的形式,一次是用户名,密码,数据库名 //如果你使用的是windows身份验证,那么可以去掉用户名和密码 $connectionInfo = array( "UID"=>"root", "PWD"=>"root2010″, "Database"=>"master"); $conn = sqlsrv_connect( $serverName, $connectionInfo); if( $conn ) { echo "Connection established.\n"; } else { echo "Connection could not be established.\n"; die( print_r( sqlsrv_errors(), true)); } ?>
The above is the detailed content of How to connect php to SQL Server2008 under Windows platform?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

Unable to access MySQL from the terminal may be due to: MySQL service not running; connection command error; insufficient permissions; firewall blocks connection; MySQL configuration file error.

The future of PHP will be achieved by adapting to new technology trends and introducing innovative features: 1) Adapting to cloud computing, containerization and microservice architectures, supporting Docker and Kubernetes; 2) introducing JIT compilers and enumeration types to improve performance and data processing efficiency; 3) Continuously optimize performance and promote best practices.

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP remains important in modern web development, especially in content management and e-commerce platforms. 1) PHP has a rich ecosystem and strong framework support, such as Laravel and Symfony. 2) Performance optimization can be achieved through OPcache and Nginx. 3) PHP8.0 introduces JIT compiler to improve performance. 4) Cloud-native applications are deployed through Docker and Kubernetes to improve flexibility and scalability.

The reasons why PHP is the preferred technology stack for many websites include its ease of use, strong community support, and widespread use. 1) Easy to learn and use, suitable for beginners. 2) Have a huge developer community and rich resources. 3) Widely used in WordPress, Drupal and other platforms. 4) Integrate tightly with web servers to simplify development deployment.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7
