PHP, XAMPP, Sql Server

Asked

Viewed 528 times

-1

Good night, you guys,

I’m trying to connect php with sql server already have a couple of days, someone can help me ?

It just shows this : Fatal error: Uncaught Error: Call to Undefined Function sqlsrv_connect() in C: xampp htdocs conexaoSqlServer index.php:5 Stack trace: #0 {main} thrown in C: xampp htdocs conexaoSqlServer index.php on line 5

I am using windows 10, php 7.2.1, xampp 3.2.2, Sql Server 2014 Express

I installed the drive : php to sql server : https://www.microsoft.com/en-us/download/details.aspx?id=20098

inside the xampp/php/ext folder

I pasted the lines in php.ini: Extension=php_pdo_sqlsrv_71_ts.dll Extension=php_sqlsrv_71_ts.dll

And even then it wasn’t... I have 2 sql server 1 in Azure and another Local, I tried both and did not roll

My php code looks like this

$servername = "db-Luciano.database.windows.net";

$connectionInfo = array("Database"=>"DB_BANCO_DE_HORAS","UID"=>"user","PWD"=>"password");

$Conn = sqlsrv_connect( $servername, $connectionInfo);

if($Conn) {

    echo "Connection established.<br />";

}Else{

    echo "Connection could not be established.<br />";
    die( print_r( sqlsrv_errors(), true));

}

Connecting in place, the servername -> put localhost, and also tried with the name of the server I picked with the command select @servername

Thanks for your attention.

insert image description here

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

  • If you have php 7.2 you need to use the dll version 7.2 instead of 7.1

1 answer

0

Greetings! It was a little strange your question, but I will answer you for what I could understand. Apparently you are trying to make a PHP connection to the database through your Apache in XAMPP.

For this, you do not need to install Mysql Server on the outside, the XAMPP itself already includes the Mysql server on itself, as you can see below. Just start the module.

Print do MySQL no XAMPP

And for you to make connections via PHP in the database, I recommend that you use PDO. You can learn more about creating scripts using PDO at this link: https://www.devmedia.com.br/introducao-ao-php-pdo/24973

I hope I’ve been of use to you.

  • So Arthur , with Mysql is bemmm quiet, I need to connect on Sqlserver...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.