Question:
How do I connect PHP to MS SQL database?
medic_man
2008-09-30 13:19:55 UTC
How do I connect PHP and IIS webserver to an MS SQL database?
Three answers:
▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀
2008-10-01 11:29:38 UTC
I have only done it from Linux, but it is probably easier with IIS.



Use phpInfo() to make sure you have MSSql Support.


$MSDBConn = mssql_connect($IP_ADDR,$Username,$Passwd);

mssql_select_db($DB_Name);

$sql = "SELECT * FROM TABLE";

$res = mssql_query($sql);

while($row = mssql_fetch_object($res))

{

echo "$r->Column_Name";

}

?>



You can also create a system ODBC connection, then you just use the odbc functions, but you are better off using the mssql functions.
wummer
2008-09-30 20:49:21 UTC
I know this answer doesn't seem very helpful, but to save yourself in the long run, please follow:

Answer: don't

Why: take the time to learn Django -> django makes is SOOO easy to create, handle and manipulate databases like mySQL. The tutorial below is only four pages long. Take a day and do it, you will not regret it. It is built in Python (also very easy and sexy language). After a single day of spending time on Django, you will never wanna go back to php again. And Google also uses python a lot, and hey, if you wanna look at database handling, then I guess we all can agree that Google know their sh...



http://docs.djangoproject.com/en/dev/intro/tutorial01/?from=olddocs
alberge
2008-09-30 20:40:12 UTC
You can use the MS SQL extension (see the PHP manual below). I've never used it myself, so your mileage may vary.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...