|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have two identical servers. By identical I mean one was built from the RAID of the other. Everything is identical including files, permissions, etc.
One of these servers has functional PHP connectivity to a SQL Server 2000 SP2 box. The other does not. I have tried the code on this website with the server listed "ONE" as an alias to a named instance of SQL Server (IPADRESS\ONE): <?php $myServer = "ONE"; $myUser = "seh"; $myPass = "*****"; $myDB = "seh"; $s = @mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer"); $d = @mssql_select_db($myDB, $s) or die("Couldn't open database $myDB"); ?> Even with this simple code this doesn't work on the second server. Some information on the second server: it has the same alias in Client Network Utility as the first server. The PHP.ini files are identical (I actually copied the working file over the disfunctional one). Permissions are identical. IIS setup is identical. Using ODBC I can see the SQL server from this server so the problem is ONLY connecting with PHP. Please help I am at wits' end. |
|
#2
|
|||
|
|||
|
hmm, try running php_info() on both servers and see if theirs any differences between them, maybe theirs something left out of the second server that you havent thought about yet.??
if their both the same, then your got problems |
|
#3
|
|||
|
|||
|
phpinfo
Ok, I'm pretty PHP ignorant. What code would I use to run this? I tried:
<?php php_info() ?> and it failed " Fatal error: Call to undefined function: php_info()" Sorry for the lack of knowledge. |
|
#4
|
|||
|
|||
|
phpinfo();
![]()
__________________
Best Regards, Håvard Lindset |
|
#5
|
|||
|
|||
|
Gblenn -- what kind of error do you get from your second server. You've already checked the obvious: you can ping from one server to another, it knows hot to resolve the hosts names from one to the other, and you have your SQL Server DSN that PHP will use from the one server set up correctlY?
You can always load Enterprise Manager for SQL Server on the machine that does work and make sure you can connect that way or just run Query Analyzer if you're savvy. Another option would be to create a SQL Server DSN and select the "TEST" button. There is also a ODBCPing for SQL Server that would allow your client to ping SQL Server using ODBC calls. |
|
#6
|
|||
|
|||
|
php/sql continued
Thanks for the info. Yes, I already have done the SQL ODBC connection (i.e. setup a DSN and run the Test). Connectivity is perfect. I don't understand why I'm erroring out with PHP. It's ONLY in PHP that this occurs.
I have checked phpinfo() per the recommendation above and everything looks identical. The only difference I noted was that under mmsql->mssql support the Active Links on one displayed 0 and the other displayed 1. That is, one is enabled and one is diabled. But they are using the same php.ini file so is this a dynamic setting?! I'm at the end of troubleshooting here and am still clueless why it connects from one and not the other. When I run the simple code above I get a could not connect to sql server "ONE" error. |
|
#7
|
|||
|
|||
|
You sure you have the same version of PHP? I believe the later versions of PHP have MySQL support compiled into the binary. With older versions, you may need to uncomment the line with the .dll filename and stop/restart server for it to work.
You sure you have the permissions setup within your MySQL database for your remote machine name to connect? In MySQL, you have to not only set permissions for the username, but also the hostname that they connect from. Usually "localhost" is set up by default. There are a couple good articles explaining how this works on this site. Check your mysql database and look at the "hosts" or "users" table for correct permissions. |
|
#8
|
|||
|
|||
|
I'm not using MySQL I'm using MSSQL. Yes, both are v.4.21, same build date.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > PHP/SQL won't connect |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|