Using PHP to connect to remote MSSQL database

Thread Solved

Join Date: Jul 2004
Posts: 494
Reputation: Puckdropper is an unknown quantity at this point 
Solved Threads: 21
Puckdropper Puckdropper is offline Offline
Posting Pro in Training

Using PHP to connect to remote MSSQL database

 
0
  #1
Apr 26th, 2005
Hello,

I installed PHP 5 on my Server 2003 machine with IIS and got that working properly. I want to connect to my school's MS-SQL student database, but PHP balks when it hits "mssql_connect" (or whatever the statement is). How can I set this up so I can actually connect to the database?

Apparently I need a file that's included with SQL Server (which I don't have) in order to get PHP to do this. Is there a way to get this file (nwtdb--something) so I can connect the database?

The whole motivation with this is being able to write and test the PHP code for the database without having to find times one of the labs on campus is open... they won't give users FTP access so you can't upload your files and test them from the web interface on their machine.
www.uncreativelabs.net

Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 18
Reputation: demo is an unknown quantity at this point 
Solved Threads: 2
demo demo is offline Offline
Newbie Poster

Re: Using PHP to connect to remote MSSQL database

 
0
  #2
Apr 26th, 2005
Hi

You first need the information that your school has given you to access the database...

This will include...

Database User Name
Database Password
Database Server Name
Database Server Port (#) it is listening on
Database Name you have permission to access
Database tables you have permissions to access

One you have this then you can connect using the following PHP functions
  1. // connect
  2. $cs = mssql_connect ( 'server_name:port', 'username', 'password' ) or die ( 'Can not connect to server' );
  3.  
  4. // select
  5. mssql_select_db ( '[database_name]', $cs ) or die ( 'Can not select database' );
  6.  
  7. //query
  8. $sql = "SELECT * FROM [TABLENAME]";
  9. $r = mssql_query ( $sql, $cs ) or die ( 'Query Error' );
  10.  
  11. // loop the result
  12.  
  13. while ( $row = mssql_fetch_array ( $r ) )
  14. {
  15. /* do stuff */
  16. }


demo
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 355
Reputation: DanceInstructor is an unknown quantity at this point 
Solved Threads: 14
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: Using PHP to connect to remote MSSQL database

 
0
  #3
Apr 26th, 2005
From everything I have read you have to have a copy of the MS-SQL server to get that file...
Clear Mind Hosting and Web Design

If I've helped you please consider adding to my reputation.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 494
Reputation: Puckdropper is an unknown quantity at this point 
Solved Threads: 21
Puckdropper Puckdropper is offline Offline
Posting Pro in Training

Re: Using PHP to connect to remote MSSQL database

 
0
  #4
Apr 27th, 2005
Thanks for the information!
www.uncreativelabs.net

Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 4
Reputation: papa_fal is an unknown quantity at this point 
Solved Threads: 1
papa_fal papa_fal is offline Offline
Newbie Poster

Re: Using PHP to connect to remote MSSQL database

 
0
  #5
Jun 1st, 2006
hello to all
i want connect to mssql insist of mysql ,i want design a web site with [php nuke],as default this CMS work with mysql,and how i can change setting that php read table of (sql server) insist of mysql.???
plz explain with details[i am in low level]
i am wait for your responses.

i hope that put this question in suitable place.

thanks
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 10
Reputation: manish812 is an unknown quantity at this point 
Solved Threads: 1
manish812 manish812 is offline Offline
Newbie Poster

Re: Using PHP to connect to remote MSSQL database

 
0
  #6
Jun 1st, 2006
hey wht u r using to connect with mysql
i also use php in window with IIS server and using mysql but i connect it very easy.
mysql_connect("host_name","user","password")
simple hai agar koi problem ho thn mail me -----manish812@gmail.com
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 4
Reputation: papa_fal is an unknown quantity at this point 
Solved Threads: 1
papa_fal papa_fal is offline Offline
Newbie Poster

Re: Using PHP to connect to remote MSSQL database

 
0
  #7
Jun 6th, 2006
hello
thanks alot of your attention.
yes,i know that mysql is better ,but my boss wants change (mysql db) to (sql server db) for (nuke[that is a CMS]).
you know that (nuke)works as default with (mysql).and i want change [connections] is special files .but i donot know where are they????and how??
do you work with nuke????and do you can help me??
i am very confused.
thanks of you .
i am wait for your response.
[plz wirte to me only to english]
with best regards.
good bye
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 10
Reputation: manish812 is an unknown quantity at this point 
Solved Threads: 1
manish812 manish812 is offline Offline
Newbie Poster

Re: Using PHP to connect to remote MSSQL database

 
0
  #8
Jun 6th, 2006
hi

sorry i don't know

i cann't help u

sorry
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 4
Reputation: papa_fal is an unknown quantity at this point 
Solved Threads: 1
papa_fal papa_fal is offline Offline
Newbie Poster

Re: Using PHP to connect to remote MSSQL database

 
0
  #9
Jun 8th, 2006
hi
ok thanks,never mind.
is person that can help me??
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 9
Reputation: JNathanson is an unknown quantity at this point 
Solved Threads: 1
JNathanson JNathanson is offline Offline
Newbie Poster

Re: Using PHP to connect to remote MSSQL database

 
0
  #10
Jun 17th, 2006
Originally Posted by papa_fal
hi
ok thanks,never mind.
is person that can help me??
An english teacher, for a start.:-|
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC