![]() |
How to connect to Microsoft Sql Server 2005 with PHP - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How to connect to Microsoft Sql Server 2005 with PHP (/showthread.php?tid=23499) |
How to connect to Microsoft Sql Server 2005 with PHP - El Forum - 10-13-2009 [eluser]FutureKing[/eluser] I am trying to connect to MS SQL Server 2005 with PHP using following code: Code: mssql_connect('SQL5.ZNETINDIA.NET','user','pass') or die(mssql_get_last_message()); BUT IT does not work. I also tried to connect to my local sql server 2005 developer edition database But it also did not work. Code: mssql_connect('ANKURGUPTA-PC\SQLSERVER','user','pass') or die(mssql_get_last_message()); I get following error: Code: Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: SQL5.ZNETINDIA.NET in G:\websites\project.localhost\mssql.php on line 3 In the above code only username and password has been changed. Actual user name and password is not "user" and "pass". I am 101% sure about my database server name, its username and password. Is there any problem in my PHP configuration? I am using WAMP Server with php_mssql extension enabled. mssql MSSQL Support enabled Active Persistent Links 0 Active Links 0 Library version 7.0 Directive Local Value Master Value mssql.allow_persistent On On mssql.batchsize 0 0 mssql.compatability_mode Off Off mssql.connect_timeout 5 5 mssql.datetimeconvert On On mssql.max_links Unlimited Unlimited mssql.max_persistent Unlimited Unlimited mssql.max_procs Unlimited Unlimited mssql.min_error_severity 10 10 mssql.min_message_severity 10 10 mssql.secure_connection Off Off mssql.textlimit Server default Server default mssql.textsize Server default Server default mssql.timeout 60 60 How to connect to Microsoft Sql Server 2005 with PHP - El Forum - 10-13-2009 [eluser]timpisti[/eluser] Hello. You may try to this 1: Check the connection with another software in windows (like mssql management studio) 2: In most cases, the windows autentication does'nt work thru PHP. a: Check the PHP.ini MSSQL values. You may find a point similar to: 'enable windows autentication...', or something like that. Enable it. b: Try this mssql_connect('SQL5.ZNETINDIA.NET') or die(mssql_get_last_message()); If you connect with windows autentication does'nt need the user and pass. 3: Create a normal SQL user - this is worked for me, and a lot of windows IT wizard can't find ANY solution to demonstrate a working MSSQL setup in this environment: ISA server auth - Windows 2008 server - MSSQL 2008 - IIS 7.0 - PHP 5.2 Its only worked with SQL user. Not the windows authenticated. How to connect to Microsoft Sql Server 2005 with PHP - El Forum - 10-13-2009 [eluser]FutureKing[/eluser] [quote author="timpisti" date="1255451681"]Hello. You may try to this 1: Check the connection with another software in windows (like mssql management studio) 2: In most cases, the windows autentication does'nt work thru PHP. a: Check the PHP.ini MSSQL values. You may find a point similar to: 'enable windows autentication...', or something like that. Enable it. b: Try this mssql_connect('SQL5.ZNETINDIA.NET') or die(mssql_get_last_message()); If you connect with windows autentication does'nt need the user and pass. 3: Create a normal SQL user - this is worked for me, and a lot of windows IT wizard can't find ANY solution to demonstrate a working MSSQL setup in this environment: ISA server auth - Windows 2008 server - MSSQL 2008 - IIS 7.0 - PHP 5.2 Its only worked with SQL user. Not the windows authenticated.[/quote] I tried all of the above but failed. When I tried to connect via ODBC it worked! MS SQL 2005 -----> ODBC -------> PHP --------> Code Igniter --------> Worked! --------------------------------------------------------------------------------------- I am creating a program which will connect to two different dbs one is new Mysql db and another is old MS Sql Server DB (via ODBC) and it will process & transfer data from MS Sql Server to MySql db. In CI I noticed that there is option to select one db at a time in database.php file. How to connect to two different dbs in one time with CI? How to connect to Microsoft Sql Server 2005 with PHP - El Forum - 10-13-2009 [eluser]timpisti[/eluser] (And you have windows authenticated user to run both PHP and MSSQL connection?) How to connect to Microsoft Sql Server 2005 with PHP - El Forum - 10-13-2009 [eluser]FutureKing[/eluser] My problem solved. How to connect to Microsoft Sql Server 2005 with PHP - El Forum - 10-19-2009 [eluser]Unknown[/eluser] How did you resolve your problem FutureKing? I'm trying to connect to a MSSQL 2005 server through ODBC connector but I can't ![]() How to connect to Microsoft Sql Server 2005 with PHP - El Forum - 10-22-2009 [eluser]FutureKing[/eluser] [quote author="Moisés" date="1255988095"]How did you resolve your problem FutureKing? I'm trying to connect to a MSSQL 2005 server through ODBC connector but I can't ![]() I used ODBC connector. Create ODBC connection from Administrative tools on your computer. Fill your db config something like this: $db['sqlserver']['hostname'] = "mydatabase"; $db['sqlserver']['username'] = ""; $db['sqlserver']['password'] = ""; $db['sqlserver']['database'] = ""; $db['sqlserver']['dbdriver'] = "odbc"; $db['sqlserver']['dbprefix'] = ""; $db['sqlserver']['pconnect'] = TRUE; $db['sqlserver']['db_debug'] = TRUE; $db['sqlserver']['cache_on'] = FALSE; $db['sqlserver']['cachedir'] = ""; $db['sqlserver']['char_set'] = "utf8"; $db['sqlserver']['dbcollat'] = "utf8_general_ci"; How to connect to Microsoft Sql Server 2005 with PHP - El Forum - 01-05-2010 [eluser]jadfreak[/eluser] [quote author="FutureKing" date="1256218829"][quote author="Moisés" date="1255988095"]How did you resolve your problem FutureKing? I'm trying to connect to a MSSQL 2005 server through ODBC connector but I can't ![]() I used ODBC connector. Create ODBC connection from Administrative tools on your computer. Fill your db config something like this: $db['sqlserver']['hostname'] = "mydatabase"; $db['sqlserver']['username'] = ""; $db['sqlserver']['password'] = ""; $db['sqlserver']['database'] = ""; $db['sqlserver']['dbdriver'] = "odbc"; $db['sqlserver']['dbprefix'] = ""; $db['sqlserver']['pconnect'] = TRUE; $db['sqlserver']['db_debug'] = TRUE; $db['sqlserver']['cache_on'] = FALSE; $db['sqlserver']['cachedir'] = ""; $db['sqlserver']['char_set'] = "utf8"; $db['sqlserver']['dbcollat'] = "utf8_general_ci";[/quote] hello futureking.. can you provide us with a more complete code for your solution above. i can't seem to make it work. please.. |