(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?
Related
I am attempting to set up a website on my Windows 10 machine using IIS. I can successfully load a simple php file (using PHP 8.1).
When I attempt a new PDO call to MSAccess I get:
HTTP Error 500.0 - Internal Server Error
C:\php\php-cgi.exe - The FastCGI process exited unexpectedly
My code is
$dbName = $_SERVER["DOCUMENT_ROOT"] . "\\vhs\VHS.accdb";
try {
$db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=$dbName;Uid=admin;");
}
catch (PDOException $e) {
echo $e->getMessage();
}
Nothing gets placed into the php_errors.log.
I have both
extension=pdo_odbc.dll
extension=php_pdo_odbc.dll
in my php.ini file (and both exist in the ext folder).
I have tried the following:
1 - a different MSAccess database (both another .accdb and an old .mdb) ... same error
2 - using the incorrect driver name (for example "Microsoft Blah Driver") ... this results in a PDOException "SQLSTATE[IM002] SQLDriverConnect: 0 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified" so I believe I have the driver spelled correctly in my original code
The Microsoft Access Driver (*.mdb, .accdb) name matches the one I see in the 64-bit ODBC administrator. If I instead use Microsoft Access Driver (.mdb) which appears in the 32-bit administrator I get the 'Data source name not found' error as well.
Does anyone have any suggestions for things to check / try?
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?
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
I just installed the Zend Server on my system and I'm trying to test my database connections. I prefer using PDO to connect my databases.
MySQL connection works very well, but when I'm trying to connect MS SQL server I got an error.
Connection to MSSQL Server failed: SQLSTATE[IM002] SQLDriverConnect: 0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified
This is the code that I'm trying to run
try {
$pdo = new PDO('odbc:host=ip-addr; dbname=my-database', 'user', 'password');
echo "Successfully connected to MSSQL Server";
} catch (PDOException $e) {
echo "Connection to MSSQL Server failed: " . $e->getMessage();
}
I have successfully enabled odbc and pdo_odbc in the configuration panel. I'm running this on macOS Sierra 10.12.
Thanks in advance.
I found this tutorial, and it brought me to succeed. It's written for Linux, but I just installed Homebrew and followed the tutorial a bit adapting.
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.