|
How to Query a SQL Server Database from PHP.
This article shows how to connect to a SQL Server database and run query from a PHP program. To be able to run our PHP program you need to perform the
following steps: 2. Change the Windows Server computer name to a more familiar name that the default WIN-XXXXXXXXXXX. I changed the computer name MORILLOPHP. 3. Install the Web Server (IIS) role on Windows Server 2012 with all default features it requires. You can test the Web server by running the following command (Windows Logo + R): http://localhost. The IIS 8 logo should appear on Internet Explorer. 4. Download and install Microsoft Web Platform Installer 4.6 from here. Install "Microsoft Drivers 3.0 for PHP v5.4 for SQL Server in IIS" and "PHP 5.4.24" using Microsoft Web Platform Installer 4.6. 5. To test the PHP installation, save the following PHP code on the C:\inetpub\wwwroot directory and name the text file as phpinfo.php. Then run the program using Internet Explorer like this: http://localhost/phpinfo.php. <?PHP phpinfo(); ?> 6. Install SQL Server Express 2012 with Tools using this article.
Creating a simple table using SQL Server Management Studio. I created a simple table using SQL Server Management Studio (SSMS) and populated the table with one record. These are the steps I followed: Open SSMS. Make a right click on Databases folder, select "New database", and provide a database name and click OK. I named the database "MorilloDB". Now, let's create a new table by expanding the MorilloDB database folder, make a right click on the tables folder, and select "New table..." and type the column names shown below.
I created just one record, but you can go ahead and add some more.
|
.Send mail to
webmaster@sqlcoffee.com with
questions or comments about this web site.
|