0

I am new at Linux OS but successfully installed apache, PHPMyAdmin, and MariaDB.

All works fine, but I have an issue and am not able to resolve it. My issue is establishing a connection to the SQL Express server which runs on WIndows machine on the same network. My script to sql ex

I was working with Windows environment with XAMPP installed I had no issues drivers for SQL express server were working.

When I do php -v in Centos, I get PHP 7.4.21 (cli) version installed. I was trying to install sqlsrv pdo drivers but have no luck. It tells me it is installed but i get issue when trying to establish a connection

Not sure how I can solve the issue. Attaching issue img error in establishing connection

Connection string I use

$serverName = "Machine\SQLEXPRESS"; //serverName\instanceName
$connectionInfo = array( "Database"=>"TestDB", "UID"=>"sa", "PWD"=>"password" , "CharacterSet" => "UTF-8");
$con = sqlsrv_connect( $serverName, $connectionInfo);

if( $con ) {
  echo "It works";
}else{
  echo "Connection could not be established.";
  die( print_r( sqlsrv_errors(), true));
}
9
  • This is not a driver issue. It is most likely a wrong connection information. Jul 15, 2021 at 13:27
  • @MichaelHampton I am using the same connection as I used on xampp environment to connect to Windows Server Machine with SQL. Updated answer with the connection string. Is there anything you suggest I can do
    – dcron
    Jul 15, 2021 at 14:17
  • Is the machine actually up and running? Jul 15, 2021 at 14:18
  • Yes it is always up and running
    – dcron
    Jul 15, 2021 at 14:20
  • OK, then go and do what the error message said to do. Jul 15, 2021 at 14:22

1 Answer 1

0

sqlsrv pdo isn't for MariaDB. for MariaDB you need to install php-mysql package. in Debian it's may be called php-mysql, or php7.4-mysql. in Centos it should be something like that also. try to find it by

yum list php*mysql*

command. if you would get success with that - try to install it with

yum install <packagename>

command, where is name of package you have found. P. S.: if you have some kind of error messages, you should post it by text, not by image like you did.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .