I have completed all the steps to make a connection between PHP and Ms SQL but still its not working and showing an error of "Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect()". I have installed MS SQL Driver also. the extension i am using in php.ini is php_pdo_sqlsrv_53_ts_vc9.dll right now but it is not included in xampp extensions. TCP/ IP is also enabled already.
Asked
Active
Viewed 107 times
-1
-
search on google "Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect()". – Genish Parvadia Jun 07 '18 at 09:27
-
Possible duplicate of [Fatal error: Call to undefined function sqlsrv\_connect()](https://stackoverflow.com/questions/22015179/fatal-error-call-to-undefined-function-sqlsrv-connect) – GuidoG Jun 07 '18 at 09:29
-
see https://stackoverflow.com/questions/47103452/fatal-error-uncaught-error-call-to-undefined-function-sqlsrv-connect – Genish Parvadia Jun 07 '18 at 09:30
-
I have already checked this link..@GenishParvadia – Sonia Jun 07 '18 at 09:35
-
I am using this extension on xampp for ms sql in php.ini php_pdo_sqlsrv_53_ts_vc9.dll – Sonia Jun 07 '18 at 09:36
-
Edit your question. Tell us what you have tried and what is different with your problem and the answers in the links from the comments. With this little information nobody can even start to guess what is wrong – GuidoG Jun 07 '18 at 09:37
-
I have also tried with pdo_sqlsrv but it shows the "Fatal error: Uncaught PDOException: could not find driver" whether drivers are already installed. – Sonia Jun 07 '18 at 10:57
1 Answers
0
You could use PDO statement to connect An example bellow:
# Connecting to PostGreSQL
$dbh = new PDO("msql:dbname=$dbname; host=$host", $username, $password);
# Setting an attribute on the database handle and error reporting
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
# Prepares a statement for execution and returns a statement object
$query = 'SELECT * FROM test';
$stmt = $dbh->prepare($query);
$stmt->execute();
# Set the resulting array to associative
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
# Returns an array containing all the results from the query
$allRows = $stmt->fetchAll();

ageans
- 549
- 5
- 20