Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
hi i have been taring to connect a MS access database using php in wamp server i used i a ready code from the internet but i still have an error that i couldn't fix

PHP
<?php
try{
    $dbh = new PDO("odbc:Driver={MS Access Database (*.mdb, *.accdb)};Dbq=C:\wamp\www\Database1.accdb");
}catch(PDOException $e){
    echo $e->getMessage();
}



and the message i get is

SQLSTATE[IM002] SQLDriverConnect: 0 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified


help please ^_^
Posted
Comments
Prasad Khandekar 25-Apr-13 11:10am    
Checkout this tutorial (http://phpmaster.com/using-an-access-database-with-php/)
marwa_e 25-Apr-13 11:20am    
i uncommented the line extension=php_pdo_odbc.dll in php.ini
but i dont get this line in the code
$dbName = $_SERVER["DOCUMENT_ROOT"] . "products\\products.mdb";
i am a beginner in php ^^
Prasad Khandekar 25-Apr-13 12:40pm    
The $dbName = $_SERVER["DOCUMENT_ROOT"] . "products\\products.mdb"; line creates the full path of the data file.
marwa_e 25-Apr-13 15:32pm    
ok then in my case i will write :-
The $dbName = $_SERVER["DOCUMENT_ROOT"] . "\\Database1.accdb";
right?
when i do this :( i get a new error :-
PDOException: SQLSTATE[IM002] SQLDriverConnect: 0 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified in C:\wamp\www\odbc_test.php on line 6

my code in the odbc_test.php file :-
Prasad Khandekar 26-Apr-13 1:56am    
Have you tried the connection string as odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\\wamp\\www\\Database1.accdb; Uid=; Pwd=;.
Assuming that your database file name is Database1.accdb and is located in C:\wamp\www\ folder.

1 solution

the problem is about a conflation about 64-bit and 32-bit :)
it looks like it only work on 32-bit wamp server (php) and i was using a 64-bit :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900