Friday, July 31, 2009

How do i connect to SQL server with PHP?

My pages run 100% ok on linux, but i need to use an SQL database and retain my PHP. This will probably run on a windows server. Someone give me the connection script for this.

How do i connect to SQL server with PHP?
If you have to connect to database in server you can use this script:


$connection=mssql_connect ($host, $username, $password);


But if you have to connect to the local host:


you should download Zip Package From this site(depends on php version):


http://www.php.net/downloads.php


and copy php_mssql.dll file to winnt\system32


and you should configure php.ini file by adding extension=php_mssql.dll
Reply:here's the code:





mysql_connect("hostname",


"username","password");





the username and password are optional, i think.





use this to connect to the database, i assume you already know this:





mysql_select_db("dbname");
Reply:what kind of SQL? if you meant MSSQL, here's how...





$conn=mssql_connect ($servername, $username, $password);
Reply:%26lt;?php


$conn = mysql_connect("localhost","USERNAME","PA...


mysql_select_db('DATABASE NAME') or die(mysql_error());


?%26gt;


sry are you talking about this ?
Reply:you might see the answer here:


www.w3schools.com


No comments:

Post a Comment