1

Just managed to connect with MS Access database but now another problem appears. I cannot select data from the database with the follwing code, because it says there is an error with the odbc_execute() function. How can this be fixed?

include( '../../lib/adodb5/adodb.inc.php');


$dbName = "database.mdb";
$db = ADONewConnection('access'); 

$dsn = "Driver={Micrsoft Access Driver(*.mdb)};Dbq=$dbName";
$db->Connect($dsn);

if(!db){
    die("Connection error!");
} else{
    echo "Connection established";
}

$sql = "Select * from Ladegut";
$result = $db->getAll($sql);

print_r($result);


EDIT: Sorry I forgot to add the Error-Message:

 Uncaught Error: Call to undefined function odbc_exec()
\lib\adodb5\drivers\adodb-odbc.inc.php on line 537
  • which database you are using `msaccess` with `PHP`? – KUMAR Jul 06 '20 at 07:26
  • If you are getting an error it would make sense to tell us exactly what it says... – ADyson Jul 06 '20 at 07:27
  • P.s. MS Access is designed as a desktop database system. It's a very poor choice for the backend of a web application. There are plenty of better, free database engines you can use – ADyson Jul 06 '20 at 07:28
  • 1
    where you are using `odbc_execute()`? – KUMAR Jul 06 '20 at 07:30
  • @ADyson: I know that it is a poor idea, but I have no choice. The database exists since the early 2000 and now it should be used in a webapplication –  Jul 06 '20 at 07:52
  • @fhprogrammer have you get `Connection established` message? – KUMAR Jul 06 '20 at 07:53
  • @KUMAR: Yes the connection can be established but I can't select data from it –  Jul 06 '20 at 07:55
  • 1
    @fhprogrammer please tell me why you have `no choice`.? – KUMAR Jul 06 '20 at 08:00
  • @fhprogrammer I suggest migrating the data to a new platform. – ADyson Jul 06 '20 at 08:08
  • @fhprogrammer regarding the error though, please see https://stackoverflow.com/questions/7535327/call-to-undefined-function-odbc-exec-error-connecting-to-access-database-on , https://stackoverflow.com/questions/34321203/call-to-undefined-function-odbc-connect-php-7 , https://stackoverflow.com/questions/50929680/undefined-function-odbc-connect-in-php-7-2 and many others where answers to your problem already exist. You should always google your error messages - you are very rarely the first person to experience the same problem – ADyson Jul 06 '20 at 08:10
  • @ADyson: I did check my ODBC-Data sources and the driver seems to be installed because it looks same as the picture: [there](https://docs.actian.com/ingres/11.0/index.html#page/QuickStart_Win/Configure_a_Data_Source_(Windows).htm) –  Jul 06 '20 at 08:51
  • ok but that's not all, you have to have the PHP library loaded too. Did you check that? Those links I showed you are mentioning that aspect too. – ADyson Jul 06 '20 at 08:56
  • Yes the ``php_pdo_odbc`` module can be loaded as well –  Jul 06 '20 at 09:00
  • Ok but that doesn't correlate with the error message you're seeing. We can't really help much without having access to your environment, but you need to double-check your understanding and assumptions. P.S. I still would strongly recommend migrating away from MS Access for this application anyway though. – ADyson Jul 06 '20 at 09:04

0 Answers0