Jump to content

problem connecting to Access Database

- - - - -

  • Please log in to reply
No replies to this topic

#1
system32

system32

    Newbie

  • Members
  • PipPip
  • 24 posts
When a user types in information on my form it will send and save it in a access database. This is my code:

<?php

    $vendorNo = $_POST["vendorNo"];
    $vendorName = $_POST["vendorName"];
    $address = $_POST["address"];
    $alternateAddress = $_POST["alternateAddress"];
    $city = $_POST["city"];
    $province = $_POST["province"];
    $postalCode = $_POST["postalCode"];
    $country = $_POST["country"];
    $phoneNumber = $_POST["phone"];
    $email = $_POST["email"];


    $db = 'C:\\xampp\\htdocs\\As4.mdb';
    $conn = new COM('ADODB.Connection') or exit ('Cannot start ADO');

    $conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$db");

    $sql = "INSERT INTO Vendors (VendorNo, VendorName, Address1, Address2, City, Prov, PCode, Country, Phone, email) VALUES ('$vendorNo','$vendorName','$address','$alternateAddress','$city','$province','$postalCode','$country','$phoneNumber','$email')";
    $rs = $conn->Execute($sql);

?>

<?php
    $rs->Close();
    $conn->Close();
    $rs = null;
    $conn = null;
?>
Now this worked fine at school but when I test it at home I get this error:

Quote

Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft OLE DB Provider for ODBC Drivers<br/><b>Description:</b> [Microsoft][ODBC Microsoft Access Driver] '(unknown)' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.' in C:\xampp\htdocs\parts.php:15 Stack trace: #0 C:\xampp\htdocs\parts.php(15): com->Open('DRIVER={Microso...') #1 {main} thrown in C:\xampp\htdocs\parts.php on line 15


Is there a way to resolve this? I have both access 2007 and 2003 installed on my computer and am connecting to the 2003 version of access. Do I need to download a driver for access? If so where can I find it?

Thanks




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users