Jump to content

Archived

This topic is now archived and is closed to further replies.

loving_php2008

[SOLVED] php with access

Recommended Posts

How can we help you if you have:

1: not provided any code

2: described what the porblem is in more detail then "it does not send data"

Regards

Mark

Share this post


Link to post
Share on other sites

i think he means MS Access. but then again he dont exactly explain himself well

 

Share this post


Link to post
Share on other sites

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);

?>

 

 

 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Since he got the error on odbc_exec and not on odbc_connect, he has the extension enabled.

 

@loving_php2008: can you execute a SELECT query for example?

Share this post


Link to post
Share on other sites

i didnt enabled that in php.ini...... what i enable in php.ini... can you tell me please..?

 

 

but with select its ok.. i get the data without any problems

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites

Since you can perform SELECT query, it means your odbc connection works. No need to change anything in php.ini

 

See this article for some ideas about the error you're getting.

 

 

Share this post


Link to post
Share on other sites

I don't work with Access so I will not be able to give you any more advice unfortunately.

Share this post


Link to post
Share on other sites

whay do you want to use access anyway got for MySQL i would rate it alot better than access and it will be easier for you to work with in php

Share this post


Link to post
Share on other sites

Whenever I see someone using Access I just assume he/she doesn't have a choice in the matter.

Share this post


Link to post
Share on other sites

<?php

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

if($conn)

{

echo "connect";

}

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

odbc_exec($conn,$sql);

?>

 

he is using php is he not?

Share this post


Link to post
Share on other sites

Does the query work when executed within access itself?

 

The best I could suggest is to clean up your syntax a little.

 

$sql="INSERT INTO t1 VALUES (1,'emmy')";

Share this post


Link to post
Share on other sites

×
×
  • 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.