SMS GATEWAY USING OZEKING MYSQL + PHP - php

I'm trying to configure an SMS GATEWAY USING OZEKING but I'm getting an error which has something to do with MYSQL ODBC DRIVER not being found. I have the driver installed on my Windows 10 machine and I'm not sure if I'm doing the right thing. In the OZEKING configuration I'm seeing this in the picture below:
The error I'm getting is :
12/16/2015 14:51:47 - INFO 6021: Connecting to database ODBC, DRIVER={MySQL ODBC 5.3 Driver};Server=localhost;Database=dbtest;UID=root;PWD=password#87;.
12/16/2015 14:51:47 - ERROR 6001: Database connection error: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified. ODBC;DRIVER={MySQL ODBC 5.3 Driver};Server=localhost;Database=dbtest;UID=root;PWD=password#87;
12/16/2015 14:51:47 - INFO 6026: Will try to reconnect to database in 20 seconds.
My question is what exactly am I doing wrong?
These parameters I'm entering Server=localhost;Database=dbtest;UID=root;PWD=password#87 are the ones I'm using to connect to my database, i.e:
$serverName = "localhost";
$userName = "root";
$password = "password#87";
$databaseName = "dbtest";
//create connection and select database by given data
$GLOBALS["connection"] = mysql_connect($serverName, $userName, $password);
if ($GLOBALS["connection"] == null)
{
echo mysql_error() . "<br>";
return false;
}
Anyone to assist me the correct way of doing things. Thanks.

ODBC drivers installed are 32-bit OR 64-bit, make sure you installed the correct architecture for your machine.
(install both to be safe)
Click Start and type "ODBC", you'll be given an option for your 32-bit and 64-bit sources, check them both and make sure your 5.3 driver is installed under both.

Related

PDO returning error "could not find driver" with a known working DSN

I'm trying to connect to an odbc database via php's PDO class:
$dsn = 'odbc:CS_HDZipCodes32bit';
$username = 'demo';
$password = 'skdemo!';
$connection = new PDO($dsn, $username, $password);
die( var_dump( $connection ) );
but when I do, I get the error :
Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in C:\inetpub\wwwroot\pdoClass.php:7 Stack trace: #0 C:\inetpub\wwwroot\pdoClass.php(7): PDO->__construct('odbc:CS_HDZipCo...', 'demo', 'skdemo!') #1 {main} thrown in C:\inetpub\wwwroot\pdoClass.php on line 7
The $dsn value is the name of the DSN I created in my ODBC Manager.
I know this particular DSN works because I was able to build another demo file and connect successfully via odbc_connect:
$connection = odbc_connect("CS_HDZipCodes32bit", 'demo', 'skdemo!');
if(!$connection){
die('connection failed');
}
$statement = "SELECT * FROM ZipCodes";
$result = odbc_exec($connection, $statement);
// Outputs the zips as expected
var_dump(odbc_result_all($result));
I've been digging through the PDO-ODBC documentation as well as other resources online, but I can't figure out why PHP is unable to find the driver when trying from PDO.
Any ideas?
Update
I popped open my phpinfo page to make sure the odbc driver is installed per Marc B's comment:
It looks like the driver is installed unless this is a different driver.
Another Update
On further inspection of my phpini per Marc B's additional comment, it looks like I don't have the POD ODBC specific driver installed:
So here, if I had the ODBC driver for pdo installed, odbc would be at the end of the list, correct?
After getting some great help from Marc B in the initial question's comments it turns out the problem was coming from my misunderstanding of enabling odbc on my web server and having the pdo_odbc driver installed.
While I did have odbc enabled on the web server, I did not have the odbc driver installed for PDO.
This driver is necessary to be able to access odbc databases via pdo.
Per the php.net documentation on installing pdo for windows, the driver was already included in the php build (I'm using version 5.5) and just needed to be included in the php.ini file.
After adding the driver and restarting the server I now had the driver loaded:
and my test query using PDO on my demo database worked:
$dsn = 'odbc:CS_HDZipCodes32bit';
$username = 'demo';
$password = 'skdemo!';
$connection = new PDO($dsn, $username, $password);
$query = "Select * FROM ZipCodes";
$result = $connection->query($query);
foreach($result as $row){
var_dump($row);
}
Dumps out:
Thanks for your help Marc B.

How to connect php and hana?

$driver = "HANADB";
$servername = "sercername";
$schema = "schemaname";
$username = "user";
$password = "XXXX";
$conn=odbc_connect("Driver={HANADB};Server=$servername;Schema=$db_name;",
$username, $password);}
I am using an odbc connection to try and connect to my hana schema. However, when i connect I get the following message
Warning: odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] Data source
name not found and no default driver specified, SQL state IM002 in SQLConnect in
I am not really sure as to where I am going wrong.
Did you install HANA clients already? Look here for some reference
If the HANA client is installed, the ODBC drivers are automatically added to your host.
May be you want to use the optional parameter cursor_type = SQL_CUR_USE_ODBC ??
Check: http://php.net/manual/en/function.odbc-connect.php
$conn = odbc_connect("", "", "", SQL_CUR_USE_ODBC);
Make sure you are using the 32bit ODBC Administrator to create your connection.
The 32bit ODBC admin is run from C:\Windows\SysWOW64\odbcad32.exe
The 64bit ODBC admin is run from C:\Windows\System32\odbcad32.exe
The 32 bit driver will show up in the list of available drivers as HDBODBC32.
Follow HANA Academy - Installing the 32bit HANA Client for more detailed explanation
Why not using Server Side JavaScript provided by SAP?
I recommend reading chapter 8 "Writing Server-Side JavaScript Code" of the SAP HANA Developer Guide

Connecting to an MSSQL database through ODBC Error

Where to start..
I have a server with windows 2008 R2 standard 32 bits.
On that server ISS 7 is installed and a php site is added but requires databases.
Made an sql database on that server wich is called 'test'.
ODBC connection is made and tested and it succeeded.
Now when I use this php code to connect to the server it gives me:
Can not connect because the target machine actively refused it.
php code:
<?
### Database ###
$user = "*****"; //database user
$pass = "*****"; //database password
$host = "localhost"; //database location
$db = "test"; //database name
##mysql_connect ("$host","$user","$pass");
##mysql_select_db("$db");
$dbConn = odbc_connect("$db","$user","$pass","$host") or die(odbc_errormsg());
?>
The password and username are correct but the error still remains.
Any help is appreciated!
Have you set your datasource using administrative tools, data sources, System DSN?
if not i'm sure it won't find the database.
see this link: http://support.microsoft.com/kb/305599

DB2 connection failed php

I'm trying to connect to remote DB2 via PHP. But have some problems. I've already installed IBM Application developer client.
phpinfo() output:
IBM DB2, Cloudscape and Apache Derby support enabled
Module release 1.9.4
Module revision $Revision: 327944 $
Binary data mode (ibm_db2.binmode) DB2_BINARY
Then, I've got a php file which is looking like:
$database = 'MyDB';
$user = 'db2inst1';
$password = 'mypassword';
$hostname = '1.1.1.1';
$port = 50000;
$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;PORT=$port;HOSTNAME=$hostname;".
"PROTOCOL=TCPIP;UID=$user;PWD=$password;";
$conn = db2_connect($conn_string, '', '');
if ($conn) {
echo "connection to $database succeeded";
} else {
echo "connection to $database failed";
echo db2_conn_errormsg();
}
And trying to execute this file, I have "connection to MyDB failed", and NO visible response from db2_conn_errormsg(), which is actually making me baffled
Unfortunately, I haven't got a straight access to the remote server with database. But several months ago, when I was using other client, I succeeded to connect to exactly this database. But that time I didn't need to install IBM ADCL. That is why I can guess that problem is on this side. But even if so, I couldn't fix it.
Sorry if I duplicated some question on stackoverflow, but all answers, which I found, were unfortunately useless to me.
I'm using Apache 2.2 and PHP 5.4.
Hope you can help.
Thanks for any replies!
Are you sure you have connectivity to the server? Correct port, server, firewall rules, username, password, database name?
What is the SQL code you are receiving. Try to get the SQL code from PHP, "connection to xx failed" is your own code so it is useless to help you.
Did you install the application development client? which DB2 version are you using? ADCL is old, it was for DB2 8. Since DB2 9.7, clients have different names, and I think you need IBM Data server client in order to compile the php module. For more information, check this website: http://www-01.ibm.com/support/docview.wss?uid=swg27016878
I think you have to catalog the database server (node) and the database in the local machine with the db2 client. It seems that your PHP code uses ODBC driver, and it has to be configured locally.
Your connection string looks like an ODBC connection where as the db2_connect function in PHP needs :-
DATABASE=database;HOSTNAME=hostname;PORT=port;PROTOCOL=TCPIP;UID=username;PWD=password;
It's on the PHP web page.
I have never been able to get ibm_db2 or pdo_ibm working on a remote. They work if DB2 and Apache are on the same machine (like the iSeries) but not if the host is connecting to a remote DB2.
If you read the Doctrine2 PHP drivers for each you will find they redirect to ODBC if the host is not 'localhost' or '127.0.0.1'.
This code works for me
<?php
if (!$db = odbc_connect ( "AS400", $user, $password) )
echo 'error!';
$result = odbc_exec($db, "select count(*) from $table");
while (odbc_fetch_row($result)) {
var_dump($result);
print_r($result);
echo "\n";
echo odbc_result($result, 1)."\n";
}
odbc_close($db);
AS400 is DSN name defined in ODBC.

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.

Categories