FileMaker Pro PHP ODBC Connection - php

How do I connect to a FMP database using an ODBC connection?
The name of the server is fmserver, and there is no Username or Password.
This is what I try:
$name = 'fmserver';
$conn = odbc_connect($name, '', '');
But for some reason, when I try it out, it brings me to a page that says (on chrome):
Server error
The website encountered an error while retrieving [URL]. It may be
down for maintenance or configured incorrectly.
Is there some method that I'm implementing wrong? I have the IP address too, and have tried that, but I can't seem to get that to work either.

Do you have the FileMaker ODBC driver installed and configured with "fmserver" as the DSN?
I would highly recommend you take a look at the FileMaker PHP API vs. ODBC.
http://www.filemaker.com/support/technologies/php.html

Related

PHP ODBC_connect with existing ODBC drivers

I have an ODBC Connection that works:
$cqmconn = odbc_connect("Driver={SQL Server Native Client 10.0};
Server=JOHN-HP;
Database=cqmla;", "sa", "sa") or die ("Unable to connect to CQM site.");
However, I have an existing ODBC Driver called "cqm2" that connects to cqmla, but the line beow does NOT make a connection:
$cqmconn = odbc_connect("cqm2","sa","sa") or die ("Unable to connect to CQM site.");
I can, however, use that ODBC connection (and credentials) with other software and it works fine. What am I missing?
I ask this because while I certainly can use the first method here, I have ANOTHER proprietary system that I cannot get to work, although it does have an ODBC connection I can access via other software using the: $cqmconn = odbc_connect("cqm2","sa","sa") format. If I can get my existing connection to work here, I figure I should then be able to call the other one.
What am I missing?
PS: I've tried adding SQL_CUR_USE_ODBC to the end of the call, but it changed nothing.
Answering my own question:
It seems that odbc_connect() for PHP does NOT recognize User DSNs, only System DSNs. As a result, when I changed the DSN I was trying to use for a connection to a System DSN, I was able to use the: $cqmconn = odbc_connect("cqm2","sa","sa") paradigm.

Unable to perform any query to Mysql server on Azure from local php server

I am able to establish connection to mysql on Azure from local server. Then I am trying to get data from users table but it is failing. I tried using mysqli and also pdo connections. In any case it is failing. Below is the screenshot of failure. Please give me a solution.
I am using Laravel 5.5.
In laravel controller :
if (DB::connection()->getDatabaseName())
{
return 'Connected to the DB: ' . DB::connection()->getDatabaseName();
}
this connection is established successfully and returning db name
But when tried to query like this, it is throwing error:
if (DB::connection()->getDatabaseName())
{
return DB::select('select * from `users`');
}
ERROR MESSAGE :
Illuminate\Database\QueryException: SQLSTATE[HY000] [2002] (SQL: select * from `users`) in file C:\SIRI-22\vendor\laravel\framework\src\Illuminate\Database\Connection.php on line 664
The same code is working fine when connected to local mysql server.
AS I AM NOT ALLOWED TO POST ANSWER TO MY QUESTION, I AM POSTING SOLUTION TO THIS ISSUE HERE:
I resolved the issue. It is explained in the comments section of azure website (https://learn.microsoft.com/en-us/azure/mysql/howto-configure-ssl).
Explanation :
You might experience problems if you're trying to connect to Azure Database for MySQL over SSL from PHP through MySQLi or PDO. The problem in both cases is that the SSL certificates used by Azure Database for MySQL do not match the hostnames of the servers you're connecting to, and hence server certificate verification fails. (Many other clients will happily connect over SSL without verifying the server certificate, which only makes it harder to figure out what is wrong.)
Fortunately, this can be solved if you're running at least PHP 5.6.16 for MySQLi or PHP v7.1.4 for PDO and you're using the MySQL Native Driver--and Azure App Service meets these requirements. For MySQLi, you will need to add the MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT flag when you connect. For PDO, you will need to set the PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT option to false when you connect.
See https://bugs.php.net/bug.php?id=68344 and https://bugs.php.net/bug.php?id=71003 for details.
This is explained by Warlock. Thanks to him !
Had you check your Azure Firewall connection of your MySQL server, since Microsoft Azure doesn't allow any external connection by default.
You have error in your query builder. You can try
DB::table("users")->get();

Trouble connecting to SQL Server with PHP

I'm trying to connect to my local SQL Server 2008 R2 (have also tried it with 2005, same result exactly) with PHP. I'm using PHP 5.1 which still supports php_mssql and mssql_connect().
for some reason PHP just won't find my server, I can connect via ODBC flawlessly an that's fine, but I would like to connect to SQL Server directly.
I have connected PHP to SQL Server a million times on different servers, this one seems to be the only one giving me issue.
This is my little test code to try and get the connection working.
//define connection garbage
$db['hostname'] = "USER90C6\SQLEXPRESS";
$db['username'] = "user";
$db['password'] = "password";
$db['database'] = "kal_auth";
//connection string
$conn = mssql_connect($db['hostname'], $db['username'], $db['password']);
//does it work? :o
if($conn)
{
echo "works";
}
else
{
echo "fails";
}
The error this code produces:
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: USER90C6\SQLEXPRESS in C:\xampp\htdocs\test.php on line 9
fails
Is there something seriously wrong with my setup? or am I missing something.
Did you enable TCP/IP on the server's configuration tool?
Is the firewall blocking any ports you might be using?
Are your MDAC (microsoft data access components) updated?
turn on mssql.secure_connection in php.ini
I think you don't miss anything.. Your connection string seems to be right (you receive a "Unable to connect" error..).
In my opinion, you problem can be a version incompatibility or a user privileges mistake. First of all: look at DLL driver you are using in PHP and check it's compatibility with you MSSQL version.
Maybe can be a good idea a fresh PHP install, with the latest stable release, if it is possible. Give a look at: http://www.php.net/manual/en/mssql.requirements.php
Good luck.

Connect to SQL Server 2008 with PDO

I am trying to connect to SQL Server 2008 (not express) with PHP 5.2.9-2 on Windows XP sp2. I can connect to the remote SQL Server fine from SQL Server Management Studio from the same machine.
My first attempt was this:
$conn = new PDO("mssql:host={$host};dbname={$db}", $user, $pass);
Which gives this error:
PHP Fatal error:
Uncaught exception 'PDOException' with message
'SQLSTATE[0100] Unable to connect: SQL Server is unavailable or does not exist.
Access denied. (severity 9)'
Second attempt (found on experts-exchange)
$conn = new PDO("odbc:Driver={SQL Server Native Client 10.0};Server={$host};Database={$db};Uid={$user};Pwd={$pass}",
$user, $pass);
This works, but I can't use PDO::lastInsertId(), which I would like to be able to:
Driver does not support this function: driver does not support lastInsertId()
Do you have any suggestions? Any help would be greatly appreciated.
i'm pretty sure that pdo with the mssql data server type requires dblib to connect. do you have dblib installed on the machine? make sure you can find ntwdblib.dll somewhere in the path on your system. i know this doesn't jive with the error message you're getting, but i'm not sure i trust the error message.
I updated ntwdblib.dll as suggested here and it now works.
Unfortunately I still can't use PDO::lastInsertId() because apparently this driver does not support it either, so it wasn't really worth the hassle. I can however use the equivalent SELECT ##IDENTITY as Id.
That you cannot use SQL Server authentication because only Windows authentication is permitted.
Check if the server is running Mixed mode authentication.
Also check if this SO question helps you.

php mssql_connect: failed

I am moving data from a MSSQL database to a MySQL database. I need to connect with PHP to MSSQL and then insert into MySQL. Could someone tell me how to:
See if the mssql server is running remotely,
How to connect to it?
Code:
mssql_connect($host,$user,$pass) or die('Failed Server Connect! ' . mssql_get_last_message());
mssql_select_db($dbnm) or die('Failed DB Select!');
Note: The webserver and db are on separate machines but mysql and mssql are are the same db machine.
I change to:
$dsnn = "Driver={SQL Server};Server={$host};Database={$dbnm}";
// Connect to the data source and get a handle for that connection.
$conn=odbc_connect($dsnn,$user,$pass);
I successfully figured out the Source issue and could not find db issue but now getting:
I now have a message saying: Login failed for user "xxx".
Figured it out. Was told the wrong password. Reset and now works.
try **Telnet <IP Address> <Port Number>** ? Is any error shown?
Since you are running PHP on Windows, have you considered trying out the SqlServer driver for PHP? Where I work, we are using it on one of our projects, and have had wonderful results with it.

Categories