To connect to sql-server database on defferent server using php
-
Friday, March 09, 2012 6:06 AM
Hi,
I am developing an application using programming language PHP and using data base MySQL.
Now i want to connect my application with SQL-server database which is on different server.
Because i want to insert some data in SQL-server database. I am using internet to establish connection b/w application
and SQL-server.
Please any body suggest me any idea how to do it !
Is it possible to connect to sql-server data base using ip address of remote server !!
Thanks !
- Moved by Samuel Lester - MSFTMicrosoft Employee Friday, March 09, 2012 6:42 AM Moving to PHP drivers forum (From:Getting started with SQL Server)
All Replies
-
Friday, March 09, 2012 10:29 AM
You can connect to any server, the first parameter of sqlsrv_connect() selects it, e.g.:
// Connect to IP address 1.2.3.4 on port 2000: $conn=sqlsrv_connect('1.2.3.4,2000', $params); // Connect to IP address 10.20.30.40 on port 1433: // (you don't need port if it's for default instance) $conn=sqlsrv_connect('10.20.30.40', $params); // Connect to a default instance on server // with computer name MYSERVER: $conn=sqlsrv_connect('MYSERVER', $params); // Connect to a named instance MYINST on a // server with computer name MYSERVER: $conn=sqlsrv_connect('MYSERVER\\MYINST', $params);
Rob
- Proposed As Answer by Jonathan GuerinMicrosoft Employee Monday, March 12, 2012 10:15 PM
- Marked As Answer by Jonathan GuerinMicrosoft Employee Friday, March 23, 2012 4:58 PM
-
Friday, March 09, 2012 11:55 AM
You can connect to any server, the first parameter of sqlsrv_connect() selects it, e.g.:
// Connect to IP address 1.2.3.4 on port 2000: $conn=sqlsrv_connect('1.2.3.4,2000', $params); // Connect to IP address 10.20.30.40 on port 1433: // (you don't need port if it's for default instance) $conn=sqlsrv_connect('10.20.30.40', $params); // Connect to a default instance on server // with computer name MYSERVER: $conn=sqlsrv_connect('MYSERVER', $params); // Connect to a named instance MYINST on a // server with computer name MYSERVER: $conn=sqlsrv_connect('MYSERVER\\MYINST', $params);Thanks a lot !
Actually i am first time using sql-server ,so confused something.
In fact what i want here is that , to save data in a .net application from a php application.
That .net application is not providing any web service neither giving any option to write web service .
So i am using this way for communication.
so i have to insert some data in sql server .
am i on write track ? or it can be done in some other way ???
thanks !
Rob
-
Monday, March 12, 2012 2:22 AM
I don't know... but I can confirm that there's nothing wrong with your idea at all, and there are always many different ways to solve problems - that's why it's fun to program computers.
Good luck!
Rob

