How can fix error PDOException: could not find driver? - php

I have local site in Wamp32, apache 2.4.23, php 7.0.10 and mysql 5.7.14
I wrote program to connect to sql server 2014 in another server but when I run this program it has an error
"could not find driver"
In php.ini I have:
extension=php_sqlsrv_7_ts.dll
extension=php_pdo_sqlsrv_7_ts.dll
My command for connect to sql server is:
$connection = new PDO('sqlsrv:Server=myserverIP;Database=mydatabase', 'username', 'password');
My server OS is windows server 2012R2

Related

Why can I not connect to my PostgreSQL database with PHP?

I have recently attempted to install a postgresql database on a digital ocean droplet running Ubuntu 18.04 x64
Using PgAdmin on my local PC, I can connect fine to the database.
Using my own C# tool on my local PC, I can connect fine to the database.
Using PHP on another server however, I cannot connect and upon checking the error log I have receiving this -
[19-Jan-2019 16:32:55 UTC] PHP Warning: pg_connect(): Unable to
connect to PostgreSQL server: could not connect to server: Connection
refused Is the server running on host "178.62.42.168" and
accepting TCP/IP connections on port 5432?
My PHP code is as follows, credentials adjusted for posting here but are correct.
<?php
$db = pg_connect("host=hostip port=5432 user=sam password=sensoredpassword dbname=sam ") or die('connection failed');
?>
Port 5432 is open.
I have adjusted /etc/postgresql/10/main/postgresql.conf >>> "listen_addresses = '*' and uncommented.
I have adjusted /etc/postgresql/10/main/pg_hba.conf and added >>> host all all 0.0.0.0/0 md5
Why can I not connect with PHP but I can connect with other tools and languages? Could something on the server the PHP is running on be blocking the connection?

Cannot connect to localhost MySQL - mysql.sock error - ERROR 2002 (HY000)

I'm using a brew php mysql config for my localhost and after trying to switch from php71 to php56, I am now unable to connect to my localhost and get this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
My services running:
I am researching this for quite some time now and I can't seem to be able to fix it. Please can someone help me? I'm going crazy.

How to connect from cakePHP3 to MSSQL Server

(I develop on a Windows System with XAMPP and use cakePHP3)
I want to connect from my cakePHP3 Localhost application, to a external SQL Server (installed on a external Windows Server 2012 r2).
In my app.php I config my Server and that is how I test the connection:
try {
$connection = ConnectionManager::get('sqlServer');
$connected = $connection->connect();
}catch (Exception $connectionError) {
echo "not";
}
echo "connected";
On testing I get this error:
A Database connection using was missing or unable to connect.
The database server returned this error: SQLSTATE[IMSSP]: This extension requires the Microsoft ODBC Driver 11 for SQL Server to communicate with SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712
So I go to my Server and Installed the needed extensions (ODBC Driver 11 for SQL Server). But I get still the same Error.
Is it possible to connect to the external Server from Localhost? Or did I make a mistake?

Unable to connect SQL SERVER 2008 R2

i have one page for register ... all my config is right but my register.php can't connect to my sql server..
Error
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: x.x.x.x in C:\xampp\htdocs\rfweb\regis.php on line 81
code in line 81 is
$connectsql=mssql_connect($db_host, $db_user, $db_pass) or die('<center><b>'.$lang_error_cant_connect1.'</b><br>'.$lang_error_cant_connect2.'<br><br>Back</center>');
spesification :
SQL SERVER 2008 R2 and xampp 1.6
i've try to setting ODBC, Restart SQL, ect
anyone help me to fix it?
Try sqlsrv queries instead of mssql, and make sure you properly configured the ports of your xampp. Another thing, try to check whether you have IIS, maybe it's blocking your xampp.

SQL Server data to php

I have this php script:
<?php
$server = 'PCCSAF\SQLEXPRESS';
$link = mssql_connect($server, 'username', 'password');
if (!$link) {
die('wrong');
}
?>
I need to connect to local SQL Server express server, but I always get
Fatal error: Call to undefined function mssql_connect() in C:\wamp\www\dbgrab\index.php on line 4
I've tried to install ntwdblib.dll, uncomment extension=php_ming.dll and extension=php_mssql.dll in php.ini, but it still not works.
I'm using PHP 5.4.3 and WAMP server 2.2 on 64bit windows7
Thank you.
WAMP Server x64 is not compatible with PHP SQL Server Driver. Try using 32 bit WAMP.

Categories