I'm trying to connect a Microsoft Access Database to a PHP file. The PHP file listed below gives the 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("PIInstitute","","");
if($con){
echo "Connected";
}else{
echo "Failed";
}
?>
You need to specify your driver when calling odbc_connect() like so:
$conn = odbc_connect ( "Driver={SQL Server};Server=$servername;Database=$dbname;", $username, $password ) or die ( "Connection failed: " . $conn );
You can find more info on odbc_connect()here: http://php.net/manual/en/function.odbc-connect.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With