This lesson wont work if your php version is 5.3 due to PHP dropped support in 5.3 for the mssql.dll.
Other solutions if your using a 5.3 version:
- Modify your php files to reference the sqlsrv_ function set instead of mssql_. http://www.microsoft.com/downloads/en/details.aspx?familyid=CCDF728B-1EA0-48A8-A84A-5052214CAAD9&displaylang=en
- SQLSRV, an alternative driver for MS SQL is available from Microsoft: http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx. The documentation is available at http://msdn.microsoft.com/en-us/library/cc296221.aspx
- Download and install Microsoft SQL Server 2005 Express Edition here. Or you can download the 2008 version of you want.
- Download and install SQL Server Management Studio here.
- If you installed successfully both products on your computer, go to start -> all programs -> microsoft sql server -> configuration tools -> sql server surface area configuration. Then, go to Service Area Configuration for Services and Connections -> Remote Connections. Finally, choose Local and Remote Connections -> use both tcp/ip and named pipes.
- Set up the authentication mode. Open sql server management studio express -> on the root folder, right click -> choose properties. Finally, select the security page -> choose sql server and windows authentication mode. Click OK.
- Create an SQL user. Open sql server management studio express -> click the root folder -> security folder, right click -> choose new -> login. Finally, create a username and choose sql server authentication, create password. Press OK.
- Close sql server management studio express. Restart your MS SQL server by opening sql server configuration manager -> right click on sql server(SQLEXPRESS) -> Restart.
- After restart success. Close sql server configuration manager.
- Open sql server management studio express by accessing using SQL Server authentication. use the account details you created in step 5.
- After logging in. create now the database. ( I think you already know how to set this up. )
- Then, configure your php.ini and enable extension=php_mssql.dll and extension=php_pdo.dll by removing the ";" before it. Restart Apache.
- Finally, create the connection on your php file. I have my example below.
if ($connection = mssql_pconnect('hostname\SQLEXPRESS', 'username',
'password')) {
echo 'Connected.';
} else {
echo 'Connection failed.';
}
hostname\SQLEXPRESS - this is the Server Name
username - the username you use to create the database.
password - the password you create using the database.
To use php mssql, you can do further reading here.
At last, if you face any problem just leave a message.
Cheers
No comments:
Post a Comment