简体   繁体   中英

ODBC INSERT/UPDATE statements trigger internal server error (500)

I am currently building a PHP site, which has to connect to a data source via an ODBC connection. The data source is not common and the driver was supplied by the customer (and no, they don't know how it all works :) ).

I was able to successfully connect to a test data source and SELECT statements work just fine. For example, this works:

$resource = odbc_prepare($connection,'SELECT * FROM [TABLE] WHERE EMAIL=?');
$success = odbc_execute($res,array('some@email');

I am able to read any information from the database. However, INSETR/UPDATE statements don't seem to work:

$resource = odbc_prepare($connection,'UPDATE [TABLE] SET EMAIL=? WHERE ID=?');
$success = odbc_execute($res,array('some@email',1);

The above statement returns an internal server error. It only says, that the error is linked to the odbc_execute() command. I checked the Apache error logs and there was no information about what could cause the error.

I checked the folder, where the test database is stored (since the database is just a bunch of files without extensions and .IDX files. My guess is, that the .IDX files are the index files for the actual DB files) and none of them are readonly.

Also, I gave anonymous users permission to modify the DB folder contents (I was desperate), no effect.

I don't think there is an error in the SQL statement, because I tried adding a syntax error and I got back a descriptive error about what is wrong.

I can not use odbc_error($connection); since I get an internal server error before I get to that line.

Any suggestions what could be wrong? I would be grateful for every hint in the right direction :)

You need to look at the ODBC connection. Depending on your version of Windows on that server, you want to open Data Sources (ODBC) . Select the alias you are using. Right Click and select Configure / Edit (there may be a button saying Configure). Check that Read Only is not ticked and that Execute Proc is ticked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM