Link to home
Start Free TrialLog in
Avatar of APD Toronto
APD TorontoFlag for Canada

asked on

Connecting to MS SQL with PHP

Hello Experts,

I’m a novice when it comes to PHP, but do have lots of Classic ASP experience.

I’m wondering does anyone  know if it is possible to connect to a MS SQL (not mySQL) DB from GoDaddy’s 2GH Shared Linux Plan?  I know that I do not have the option to setup am MS SQL DB on this hosting plan, but what if I have an external SQL Server elsewhere, could I connect to it from this hosting in PHP by just specifying the IP Address, User Name, Password and Database Name?

Assuming that I am able to connect, can anyone help me to write a test script, along the lines of:
<%
strConn = "Driver={SQL Server}; " & _
	  "Server=123.456.78.987; " & _
	  "Database=someDB; " & _
	  "Uid=SOMEone; " & _
	  "Pwd=whoknows;"	

strSQL = "SELECT * FROM Table"

rs.Open strSQL, strConn
%>

Table contents: <br><br>

<%
Do While Not rs.EOF

	Response.Write(rs.Fields("fld1") & "<br>")
	rs.MoveNext

Loop
%>

Open in new window

…but, of  course, in PHP?

Many Thanks.
SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of APD Toronto

ASKER

i have actually connected from GoDddy's Shared Win to external SQL.  However, i worry if their Linux have the req'd drivers.

Can anyone help me convert the above code?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial