943,712 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 58809
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Apr 26th, 2005
0

Using PHP to connect to remote MSSQL database

Expand Post »
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.
Reputation Points: 23
Solved Threads: 23
Posting Pro in Training
Puckdropper is offline Offline
494 posts
since Jul 2004
Apr 26th, 2005
0

Re: Using PHP to connect to remote MSSQL database

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
PHP Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 2
Newbie Poster
demo is offline Offline
18 posts
since Jan 2005
Apr 26th, 2005
0

Re: Using PHP to connect to remote MSSQL database

From everything I have read you have to have a copy of the MS-SQL server to get that file...
Reputation Points: 17
Solved Threads: 14
Posting Whiz
DanceInstructor is offline Offline
355 posts
since Feb 2005
Apr 27th, 2005
0

Re: Using PHP to connect to remote MSSQL database

Thanks for the information!
Reputation Points: 23
Solved Threads: 23
Posting Pro in Training
Puckdropper is offline Offline
494 posts
since Jul 2004
Jun 1st, 2006
0

Re: Using PHP to connect to remote MSSQL database

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
Reputation Points: 10
Solved Threads: 1
Newbie Poster
papa_fal is offline Offline
4 posts
since Jun 2006
Jun 1st, 2006
0

Re: Using PHP to connect to remote MSSQL database

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
Reputation Points: 21
Solved Threads: 1
Newbie Poster
manish812 is offline Offline
12 posts
since Jun 2006
Jun 6th, 2006
0

Re: Using PHP to connect to remote MSSQL database

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
Reputation Points: 10
Solved Threads: 1
Newbie Poster
papa_fal is offline Offline
4 posts
since Jun 2006
Jun 6th, 2006
0

Re: Using PHP to connect to remote MSSQL database

hi

sorry i don't know

i cann't help u

sorry
Reputation Points: 21
Solved Threads: 1
Newbie Poster
manish812 is offline Offline
12 posts
since Jun 2006
Jun 8th, 2006
0

Re: Using PHP to connect to remote MSSQL database

hi
ok thanks,never mind.
is person that can help me??
Reputation Points: 10
Solved Threads: 1
Newbie Poster
papa_fal is offline Offline
4 posts
since Jun 2006
Jun 17th, 2006
0

Re: Using PHP to connect to remote MSSQL database

Quote originally posted by papa_fal ...
hi
ok thanks,never mind.
is person that can help me??
An english teacher, for a start.:-|
Reputation Points: 10
Solved Threads: 1
Newbie Poster
JNathanson is offline Offline
9 posts
since May 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Php Spacing
Next Thread in PHP Forum Timeline: Urgent (Issue in AS400. Software used Vision +)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC