Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MySQL (http://www.go4expert.com/forums/mysql-forum/)
-   -   php can't connecting to access database to be able to insert a new record (http://www.go4expert.com/forums/php-connecting-access-database-able-t17971/)

itsys 13Jun2009 15:38

php can't connecting to access database to be able to insert a new record
 
Code: PHP

<?php
    $vendorName = $_POST["vendorName"];
    $address = $_POST["address"];
    $countryGroup = $_POST["countryGroup"];
    $city = $_POST["city"];
    $cost = $_POST["cost"];
    $provinceList = $_POST["provinceList"];
    $stateList = $_POST["stateList"];
    $postalCode = $_POST["postalCode"];
    $phone = $_POST["phone"];
    $fax = $_POST["fax"];

    print ("<br> Vendor Name: $vendorName");
    print ("<br> Address: $address");
    print ("<br> Country: $countryGroup");
    print ("<br> City: $city");
    if ($provinceList != "")
    {
        print ("<br> Province: $provinceList");
    }
    if ($stateList != "")
    {
        print ("<br> State: $stateList");
    }
    print ("<br> Postal Code: $postalCode");
    print ("<br> Phone: $phone");
    print ("<br> Fax: $fax");
   
    if ($vendorName != "" || $address != "" || $countryGroup != "" || $city != "" || $cost != "" ||
    $provinceList != "" || $stateList != "" || $postalCode != "" || $phone != "" || $fax != "")
    {
        //$conn=odbc_connect('MyAccess','','');
   
        $db="D:\Program Files\xampplite\htdocs\As4.mdb";
       
        $conn=new COM('ADODB.Connection');
       
        $conn->Open("Provider=Microsoft.ACE.OLEDB.12.0;DataSource=$db;");
           
        $conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=D:\Program Files\xampplite\htdocs\As4.mdb");
       
        print "<br>TEST TEST TEST 1";
       
        $sql="INSERT INTO
        Vendors(VendorName,Address1,Prov,City,Country,PCode,phone,FAX)
        VALUES('$vendorName','$address','$provinceList','$city','$countryGroup','$postalCode','$phone','$fax')"
;
       
        print "<br>TEST TEST TEST 2";
       
        $rs=$conn->Execute($sql);
       
        print "<br>TEST TEST TEST 3";
       
        $rs->Close();
        $conn->Close();
        $rs = null;
        $conn = null;
    }
    else
    {
        print("Values not passed correctly please hit back and re-Submit.");
    }
?>


pradeep 4Sep2009 11:51

Re: php can't connecting to access database to be able to insert a new record
 
try
PHP Code:

$db="D:\\Program Files\\xampplite\\htdocs\\As4.mdb"



All times are GMT +5.5. The time now is 12:37.