Link to home
Start Free TrialLog in
Avatar of DrDamnit
DrDamnitFlag for United States of America

asked on

ODBC Connection to Access database with PHP

I followed the steps here:
http://www.devasp.com/samples/dsn_access.asp

and created a DSN, which went OK.

Then I tried to use this code to access it, but it keeps failing. $conn is empty.
 
<?php
	$conn=odbc_connect('MCDB','phpadmin','********!');
	if (!$conn)
	{
		exit("Connection Failed: " . $conn);
	}
	else
	{
		echo "Connection Established";
	}
	odbc_close($conn);
?>

Open in new window


What am I doing wrong?
Avatar of Lukasz Chmielewski
Lukasz Chmielewski
Flag of Poland image

If so... Seems ok but double check:
DSN name ? Is it the same ?
Are you providing good password ?
Avatar of DrDamnit

ASKER

Since this is a Windows 2k8 box, there is no user and password because I have used a system DSN.

In that same vein, I have manually added some user / passwords to the DSN, and I have also tried authenticating with the system administrator credentials (with and without the DOMAIN\User format). All to no avail.

ODBC is already installed on a Windows SBS 2008 box, so I don't think I need to install anything else. I did, however have to install the access drives, but that went ok.
Does this work without providing ANYTHING ?
$conn=odbc_connect('MCDB','','');
No joy.

I have set the file permissions to this as Everyone = Full Access (for the folder that contains this file). Still didn't work.

Thoughts?
This is how I set it up... User generated image User generated image User generated image
ASKER CERTIFIED SOLUTION
Avatar of Shinesh Premrajan
Shinesh Premrajan
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Still fails. Just to beclear, dbq should be the DSN or the path to the file?
The key was to do a DSN-less connection using the full path. Thanks!
Isn't that the thing suggested by the first post ?