stockton Posted March 8, 2009 Share Posted March 8, 2009 The following code consistently works on all PCs tried on except my laptop. Please give me some hints on why this may happen. global $dbservertype, $servername, $dbusername, $dbpassword, $dbname, $link; $link = mssql_connect($servername, $dbusername, $dbpassword) or die("Unable to connect to T4T database"); Quote Link to comment https://forums.phpfreaks.com/topic/148476-hints-on-why-mssql_connect-fails-on-one-pc/ Share on other sites More sharing options...
corbin Posted March 8, 2009 Share Posted March 8, 2009 Perhaps you don't have the MSSQL client libraries on your laptop? Perhaps the MSSQL extension isn't enabled in PHP? It could be a lot of things. What error message do you get? Quote Link to comment https://forums.phpfreaks.com/topic/148476-hints-on-why-mssql_connect-fails-on-one-pc/#findComment-779692 Share on other sites More sharing options...
stockton Posted March 9, 2009 Author Share Posted March 9, 2009 I do have the client libraries on my laptop. I do have mssql extensions enabled in PHP.ini and MSSQL gives no error message that I am aware of. All I get is the "Unable to connect to T4T database" from my own code(see below) & I am aware of the die on the connect line and I have coded that many different ways but mssql refuses to share any error messages with me. $link = mssql_connect($servername, $dbusername, $dbpassword) or die("Unable to connect to T4T database"); if (!(mssql_select_db($dbname, $link))) { echo "Error in DBConnect() = " . mssql_get_last_message(); sprintf($Message, "At %d in %s Could not select %s at %s as %s",__LINE__, __FILE__, $dbname, $servername, $dbusername); trigger_error(E_USER_ERROR, $Message); exit; } Quote Link to comment https://forums.phpfreaks.com/topic/148476-hints-on-why-mssql_connect-fails-on-one-pc/#findComment-780153 Share on other sites More sharing options...
corbin Posted March 9, 2009 Share Posted March 9, 2009 Change the or die("") to or die(mssql_get_last_message()) Quote Link to comment https://forums.phpfreaks.com/topic/148476-hints-on-why-mssql_connect-fails-on-one-pc/#findComment-780682 Share on other sites More sharing options...
stockton Posted March 10, 2009 Author Share Posted March 10, 2009 Unfortunately all that, that gives me is a blank screen. Quote Link to comment https://forums.phpfreaks.com/topic/148476-hints-on-why-mssql_connect-fails-on-one-pc/#findComment-780961 Share on other sites More sharing options...
corbin Posted March 11, 2009 Share Posted March 11, 2009 Really? It shouldn't x.x. Try: or die("Error: " . mssql_get_last_message()); Maybe it's blank for some weird reason. (If it's really blank, that will show just "Error: ".) Hrmmmm, this might be an insulting question, but are you positive the host/username/password are correct? Like, you aren't trying to use localhost or something on the laptop are you? Quote Link to comment https://forums.phpfreaks.com/topic/148476-hints-on-why-mssql_connect-fails-on-one-pc/#findComment-782391 Share on other sites More sharing options...
stockton Posted March 12, 2009 Author Share Posted March 12, 2009 As you suspected adding your code and now all I get is "Error. " host/username/password are all correct but I do not understand your "Like, you aren't trying to use localhost or something on the laptop are you?". If you mean am I browsing to localhost I am and the relationship between localhost and 127.0.0.1 is setup in my hosts file; did I mention that this system is on Windows. If you mean am I using localhost in my configuration file to point to the database, yes I am. and I am attempting to access the system(on my laptop) from my laptop. Quote Link to comment https://forums.phpfreaks.com/topic/148476-hints-on-why-mssql_connect-fails-on-one-pc/#findComment-782971 Share on other sites More sharing options...
corbin Posted March 12, 2009 Share Posted March 12, 2009 Ahhhh ok. I thought maybe you were trying to access the MSSQL server on your PC from your laptop using localhost as the host. Do the MSSQL client tools connect? Quote Link to comment https://forums.phpfreaks.com/topic/148476-hints-on-why-mssql_connect-fails-on-one-pc/#findComment-783267 Share on other sites More sharing options...
stockton Posted March 13, 2009 Author Share Posted March 13, 2009 Yes Enterprise Manager works perfectly. Quote Link to comment https://forums.phpfreaks.com/topic/148476-hints-on-why-mssql_connect-fails-on-one-pc/#findComment-783586 Share on other sites More sharing options...
corbin Posted March 14, 2009 Share Posted March 14, 2009 Hrmmm I wonder if this is another infamous mssql_connect bug (which are usually caused by out dated client libraries). If you use odbc_connect when mssql_connect isn't working, does it magically work? If so, it's probably a client library issue. Quote Link to comment https://forums.phpfreaks.com/topic/148476-hints-on-why-mssql_connect-fails-on-one-pc/#findComment-784363 Share on other sites More sharing options...
stockton Posted March 14, 2009 Author Share Posted March 14, 2009 I'll try your suggestion even though I have the same version of mssql on my desktop as I have on my laptop and the desktop works fine. Quote Link to comment https://forums.phpfreaks.com/topic/148476-hints-on-why-mssql_connect-fails-on-one-pc/#findComment-784385 Share on other sites More sharing options...
phewett Posted March 14, 2009 Share Posted March 14, 2009 Try enabling the "display_errors = on" in your php.ini This should provide additional logging data in the returned page. Make sure consider the warnings in the php.ini comments, and perhaps don't do this if your php server is internet visible. Quote Link to comment https://forums.phpfreaks.com/topic/148476-hints-on-why-mssql_connect-fails-on-one-pc/#findComment-784877 Share on other sites More sharing options...
stockton Posted March 15, 2009 Author Share Posted March 15, 2009 I did not believe that enabling the "display_errors = on" in your php.ini will help show mssql messages and in fact when I tested your suggestion nothing changed. I still only get corbins suggested Error: Quote Link to comment https://forums.phpfreaks.com/topic/148476-hints-on-why-mssql_connect-fails-on-one-pc/#findComment-785109 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.