Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

trouble connecting to ms_sql via php

Posted on 2011-09-19
17
Medium Priority
?
184 Views
Last Modified: 2012-09-07
I'm trying to connect to a new ms_sql server using:

$connect = mssql_connect("sqldata2.ussery.local", "php", "holistic") or die ("couldn't
connect");

mssql_select_db('[PSI_DB_1]', $connect);

Open in new window


I've been successfully connecting to the previous database for YEARS but I can't figure out how to get it to recognize the new one ... I've tried various names for the database (the first variable) but can't get it to work.  On the previous server, the database server was simply referred to as "psi" but in looking at the old box, I can't even figure out where that name comes from - it's not the name of the computer itself, or anything else I can discover.  And I've already created new user in the new database, using the same username and password.

Can anyone help?
0
Comment
Question by:kennmurrah
  • 7
  • 7
  • 3
17 Comments
 
LVL 13

Accepted Solution

by:
haloexpertsexchange earned 2000 total points
ID: 36562613
psi might have been a dsn connection name.
You should check on the server to see if it is still set up there, and you may just have to change some information to get it working again.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36562624
What versions of PHP are you using and what webserver?   I ask because the 'mssql' drivers are discontinued as of PHP 5.3 and you have to get the Microsoft PHP SQL drivers.  And to use those, you have to be on Windows.
0
 
LVL 13

Expert Comment

by:haloexpertsexchange
ID: 36562644
I usually use odbc_connect for connecting to mssql databases.
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 

Author Comment

by:kennmurrah
ID: 36563015
I checked,a nd there was no dsn connection name on the old server ... as to PHP versions, I'll have to check tomorrow, but definitely 4.x

0
 
LVL 13

Expert Comment

by:haloexpertsexchange
ID: 36563222
Do you have any errors that happen when trying to connect with mssql_connect?
If there are no errors on the page itself you may have the errors being logged elsewhere.
check in your ini file and see where error_log is pointing to
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36563295
What are the old and the new versions of SQL Server?
0
 

Author Comment

by:kennmurrah
ID: 36563329
both are sql server 2000.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36563859
And you're running PHP on Windows?
0
 

Author Comment

by:kennmurrah
ID: 36564045
No, running php on Linux
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36564060
Then you have some work to do.  http://us.php.net/manual/en/mssql.requirements.php  

"To use the MSSQL extension on Unix/Linux, you first need to build and install the FreeTDS library. Source code and installation instructions are available at the FreeTDS home page: » http://www.freetds.org/ "

And so you'll know, FreeTDS and UnixODBC don't seem to work with SQL Server 2005 or 2008.  There are some commercial ODBC connectors that do but nothing we've been able to find for free.
0
 

Author Comment

by:kennmurrah
ID: 36564169
Yeah, I'm aware of those requirements - in fact, I've successfully connected to "identical" servers already, using the approach outlined in the link you recommend.  But I'm doing something wrong this time, and I just can't find it.  Thanks for the suggestions.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36564200
Is there another database on the same server that you have been able to connect to?  I ask because it could be something on the SQL server.
0
 

Author Comment

by:kennmurrah
ID: 36564289
No, the database that I've been able to connect to is on another server, but it uses the same version of Windows Server, the same version of SQL Server, etc.  In fact, we recreated the server on a different box because of the imminent death of hardware on the old box, and we tried to make everything identical.  Yet I can't connect for the life of me.  
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36565221
You said you created a new user.  How do you connect to it on it's server?
0
 

Author Comment

by:kennmurrah
ID: 36566810
Dave,  I meant that I created a new sqlserver user for that database on the new install of sqlserver.  I called it the same name "php" as I'd called it in the previous, working server.  I also tried using "sa" user, but without success there, either.

thanks
0
 

Author Comment

by:kennmurrah
ID: 36567078
This may be instructive:  in a desperate attempt to figure out how it was finding the old server using the name "psi", I searched for that on the old server and did find files called psi.dbc.dsn .... though I can't find dsn named that in any of the odbc datasource names.  

I also have the SAME psi.dbc.dsn files on the new server as well.  Does that help any of you, or am I looking in the wrong place?

thanks.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36568905
Open it in Notepad.  Maybe there's some useful info there.  http://support.microsoft.com/kb/165866  look at Method 2.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question