I am currently faced with a new challenge to develop a site using Microsoft Access as the primary database instead of mysql. I have not used MS Access before and I would like guidiance on how to go about it, I have looked up the w3c website on W3schools but the code gives 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 in C:\Users\NNALI\Desktop\root\test.php on line 2
and this error
Warning: odbc_exec() expects parameter 1 to be resource, boolean given in C:\Users\NNALI\Desktop\Breweries\root\test.php on line 4
I am stuck and do not know what to do, I would appreciate all help on this.
<?php
$conc = odbc_connect("northwind", "","");
$sql = "Select * From customers";
$rs = odbc_exec($conn, $sql);
?>
Above is the code I used
A successful connection will allow SQL commands to be executed from PHP to read or write the database. If, however, you get the error message “PDOException Could not find driver” then it’s likely that the PDO ODBC driver is not installed. Use the phpinfo() function to check your installation for references to PDO.
If an entry for PDO ODBC is not present, you will need to ensure your installation includes the PDO extension and ODBC drivers. To do so on Windows, uncomment the line extension=php_pdo_odbc.dll in php.ini, restart Apache, and then try to connect to the database again.
With the driver installed, the output from phpinfo() should include information like this:https://www.diigo.com/item/image/5kc39/hdse
Are you sure the odbc connector is well created ? if not check the step "Create an ODBC Connection" again
EDIT: Connection without DSN from php.net
// Microsoft Access
in your case it might be if your filename is northwind and your file extension mdb:
If you are just getting started with a new project then I would suggest that you use PDO instead of the old
odbc_exec()
approach. Here is a simple example:The problem is a simple typo. You named your variable 'conc' on line 2 but then referenced 'conn' on line 4.