Jump to content

[SOLVED] php with access


Recommended Posts

i want to insert data from php to microsoft access ,but i got warning..

 

 

its the error that i got

 

PHP 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 C:\Inetpub\wwwroot\php\test.php on line 8 .

 

and its the code:

 

<?php

$conn=odbc_connect('test','root','');

if($conn)

{

echo "connect";

}

$sql="insert into t1 values(1,'emmy')";

odbc_exec($conn,$sql);

?>

 

 

 

Link to comment
Share on other sites

The string 'test' is not a dsn. Been a long while since Ive programmed in asp but from memory it would look something like...

 

DRIVER={Microsoft Access Driver (*.mdb)};

 

You'll need to research what a dsn (the expected firest perameter) is.

Link to comment
Share on other sites

its about odbc in (php.ini) file:

 

 

 

[ODBC]

;odbc.default_db    =  Not yet implemented

;odbc.default_user  =  Not yet implemented

;odbc.default_pw    =  Not yet implemented

 

; Allow or prevent persistent links.

odbc.allow_persistent = On

 

; Check that a connection is still valid before reuse.

odbc.check_persistent = On

 

; Maximum number of persistent links.  -1 means no limit.

odbc.max_persistent = -1

 

; Maximum number of links (persistent + non-persistent).  -1 means no limit.

odbc.max_links = -1

 

; Handling of LONG fields.  Returns number of bytes to variables.  0 means

; passthru.

odbc.defaultlrl = 4096

 

; Handling of binary data.  0 means passthru, 1 return as is, 2 convert to char.

; See the documentation on odbc_binmode and odbc_longreadlen for an explanation

; of uodbc.defaultlrl and uodbc.defaultbinmode

odbc.defaultbinmode = 1

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.