Page 1 of 1

INSERT INTO ACESS DB

Posted: Fri Dec 11, 2009 5:16 pm
by bishmedia
I'm trying to INSERT a new record into an ACCESS DB using PHP from a form, this is the code l have so far........

Code: Select all

 
    $heading = $_POST['heading']; 
    $story = $_POST['story'];
 
        $odbc = odbc_connect ('logisticsdb', 'root', '') or die('Could Not Connect to ODBC Database!');
    
    $sql = "INSERT INTO Search (sHeading, sDescription) VALUES ('$heading', '$story')";
 
    odbc_exec($odbc_connection, $sql) or die();
 
    odbc_close($odbc);
 
But i'm getting the following error.......
Warning: odbc_exec() expects parameter 1 to be resource, null given in C:\xampp\htdocs\lbm\searchupdate.php on line 8

What a l missing?

Re: INSERT INTO ACESS DB

Posted: Sat Dec 12, 2009 2:31 am
by bishmedia
I got it to work by changing $odbc_connection to $odbc :-)

It works fine on localhost but now that i have downloaded it to my server i get this error.......

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query., SQL state S1000 in SQLExecDirect in d:\inetpub\....com\web\content\searchupdate.php on line 9

Any thoughts :-(