Microsoft Access Database connect to php - php

My system OS is 64-bit. Ms Access 2007 is 32 bit. I have connect with PHP.
PHP file give following error:
"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 C:\wamp\www\PI\Connection.php on line 3"
Connection.php
<?php
$con = odbc_connect("Driver={Microsoft Access Driver (*.mdb,*.accdb)};Dbq=PIInstitute","","");
if($con){
echo "Connected";
}else{
echo "Failed";
}
?>

Related

MS Access ODBC connection issue with php

Warning: odbc_connect(): SQL error: [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied., SQL state 08001 in SQLConnect in C:\xampp\htdocs\Admin\index.php on line 9

How to connect php to ms sql 2017

I am using php 5.6.28 and Ms sql express server 2017.
I add the following code.
$cid = odbc_connect("DESKTOP-9LIFSBQ\SQLEXPRESS","testdb","");
if (!$cid){
exit("<strong>Error.</strong>");
}
I got the following errors .
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

how to find ODBC driver name?

I am using PHP 5.5 and ODBC installed and active but still I have that error I couldn't connect the server. I Guess I need odbc driver name.
$conn = "DRIVER={SQL Server};SERVER=$server;DATABASE=$db";
Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in
You can be using PDO to connect. If you are on windows:
$this->stmt = new PDO ("sqlsrv:server=$server;Database=$database;",$user,$pass);
On Linux:
$this->stmt = new PDO ("dblib:host=$server;dbname=$database;charset=UTF-8;",$user,$pass);

Connect PHP to UniVerse ODBC DSN

I have what seems a simple question, but I just cant get php to connect to my ODBC DSN.
I have a webserver with an ODBC DSN configured properly, I can test the connection and it works just fine.
I am now trying to connect PHP to this DSN.
MYDSNNAME is using the driver: UniVerse 64-Bit ODBC Driver.
Here is my php code:
$conn=odbc_connect('MYDSNNAME','username','password',SQL_CUR_USE_ODBC);
if (!$conn)
{
exit("Connection Failed: " . $conn);
}
$sql="SELECT * FROM customers";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{
exit("Error in SQL");
}
dbc_close($conn);
I am getting the following error:
Message: odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect
I have tried using the 64bit ODBC administrator and that did not work. Any suggestions would be great.
Thanks
I was able to circumvent the error I was getting by using the 32bit version of the driver within my ODBC Administrator and I am now connecting just fine.
It gets a little tricky with 32/64bit versions of the odbc administrator.

ODBC connectivity in PHP

I have created an ODBC DSN (icamexamdata) for a MS Access DB. Mine is Win 7 OS. I used the following code to connect to the DSN
$conn=odbc_connect('icamexamdata','','');
I couldn't connect and I get the following error.
Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect
Can anybody help?

Categories