Fatal error Call to undefined function sqlsrv connect

0 votes

Even though I have read a lot of posts on the same topic, I am still unable to find an answer, so I ask. In my php script, I'm trying to connect to SQL. What is my connection string?

/* Specify the server and connection string attributes. */
$serverName = "xxx-PC\SQLExpress";
$connectionOptions = array("Database"=>"Salesforce");
$conn = sqlsrv_connect($serverName, $connectionOptions);
if($conn === false)
{
      die(print_r(sqlsrv_errors(), true));
}

I have installed and included the following in my php.ini file located under the wamp folder: C:\wamp\bin\php\php5.4.16:

extension=c:/wamp/bin/php/php5.4.16/ext/php_sqlsrv_53_ts.dll

My wampserver is running fine and so are the wampapache and wampsqld services. I am able to execute php.exe successfully. However I am unable to make the connection to SQL Server 2008 R2 where my database is located. Please help!

EDIT 1: The wamp server is running the wampmysql service while I am trying to connect to SQL Server 2008 R2. Could this be the reason? Should I be using MySQL instead of SQL? Any pointers?

EDIT 2: I do not see sqlsrv section at all when I run phpinfo() though I have added extension=php_sqlsrv_54_ts.dll in the php.ini file located in the bin folder of the wamp server.

enter image description hereCan someone please help me with this?

Sep 12, 2022 in Database by Kithuzzz
• 38,000 points
3,415 views

1 answer to this question.

0 votes

This helped me get to my answer. There are two php.ini files located, in my case, for wamp. One is under the php folder and the other one is in the C:\wamp\bin\apache\Apachex.x.x\bin folder. When connecting to SQL through sqlsrv_connect function, we are referring to the php.ini file in the apache folder. Add the following (as per your version) to this file:

extension=c:/wamp/bin/php/php5.4.16/ext/php_sqlsrv_53_ts.dll

I hope this helps you.

answered Sep 13, 2022 by narikkadan
• 63,600 points

Related Questions In Database

0 votes
3 answers

MySQL "Could not create connection to database serve" error

Pls check that you have MySQL server ...READ MORE

answered Jul 3, 2020 in Database by anonymous
29,961 views
0 votes
1 answer
0 votes
1 answer

Error: Cannot connect to the server using SA account - MSSQL Linux

The option is to reset the system ...READ MORE

answered Mar 17, 2019 in Database by Fatima
890 views
0 votes
1 answer

Error Code: 2020. Lost connection to MySQL server during query

Hello @kartik, I got the same issue when ...READ MORE

answered May 4, 2020 in Database by Niroj
• 82,840 points
2,712 views
0 votes
0 answers

Laravel/ MSSQL (AWS RDS) General error: 20018 Unicode data

I'm using SQL Server with a Laravel ...READ MORE

Apr 25, 2022 in AWS by Aditya
• 7,680 points
1,135 views
0 votes
0 answers

Localhost giving an error "ERR_NAME_NOT_RESOLVED "

I created a folder in the "www" ...READ MORE

Jun 27, 2022 in PHP by narikkadan
• 63,600 points
565 views
0 votes
1 answer
+1 vote
2 answers

Scp Php files into server using gradle

Tru something like this: plugins { id ...READ MORE

answered Oct 11, 2018 in DevOps & Agile by lina
• 8,220 points
1,592 views
0 votes
1 answer

How to solve : SQL Error: ORA-00604: error occurred at recursive SQL level 1

I saw the problem in the line ...READ MORE

answered Sep 10, 2022 in Database by narikkadan
• 63,600 points
5,004 views
0 votes
1 answer

How to execute function in SQL Server 2008

The function appears not to be being ...READ MORE

answered Sep 11, 2022 in Database by narikkadan
• 63,600 points
972 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP