Skip to content
Advertisement

Connect sqlsrv in Xampp

I have installed Xampp with a CodeIgniter installation. I want to connect from CodeIgniter to a SQL database.

I changed the database config file and set the dbdriver to sqlsrv.

In my controller I have the following code to try the connection:

I have the following error:

Fatal error: Call to undefined function sqlsrv_connect() in C:xampphtdocssystemdatabasedriverssqlsrvsqlsrv_driver.php on line 76

I have read on a forum that I have to change line 89 from sqlsrv_driver.php:

What do I wrong?

Advertisement

Answer

EDIT- First you need to download the driver http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx

Now go to your XAMPP installation and search for php.dll It will display correct PHP dll you have.

1) move following files to xampp/php/ext directory.

2) If you have php5ts.dll then move following files to xampp/php/ext directory.

above files should be used if your PHP version is compiled with Visual C++ 9.0 . Else following files should be used.

1) If you have php.dll then move following files to xampp/php/ext directory.

2) If you have php5ts.dll then move following files to xampp/php/ext directory.

Now we have to load files that we added recently. Open the php ini file and add entry in the area of dynamic extensions as follow.

Save the ini files and restart XAMPP



I don’t know for sure what you are trying to do but in codeigniter you don’t need to initialise database, CI automatically does it for you

so-

this is not needed.

You just need to load the model and in model start performing queries. $this->load->database(); In controller you need to load the model like-

then call the model function in which you have written the queries.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement