Page 1 of 1

Insert Record into an MS-Access Database

Posted: Sun Feb 21, 2010 2:08 pm
by devarishi
Hi,

The following PHP Script does the job, i.e., adding a new record to the MS-Access Database.


Code: Select all

<?php
$db = 'myDB.mdb';
$conn = new COM('ADODB.Connection');
$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db");
$sql = "insert into contactsTbl(fName,mName,lName,phoneNo) 
values('Mr. Z','Kumar','Verma','Mobile# 99999999')";
$rs = $conn->Execute($sql);
$rs.Update;
$rs->Close();
$conn->Close();
$rs = null;
$conn = null;
?>
However, the following error page is displayed when the PHP Script has finished running.
The website cannot display the page
HTTP 500
Most likely causes:
•The website is under maintenance.
•The website has a programming error.
I checked the Database and the New Record is there! So, what could be the problem in the PHP Script that is causing the Error: HTTP 500, as given above?

Note: All the fields are of Text Data Type and their sizes are set to 30 (characters) in the database.

Re: Insert Record into an MS-Access Database

Posted: Sun Feb 21, 2010 5:55 pm
by mikosiko
comment the line 8 $rs.Update; and test.

Miko

Re: Insert Record into an MS-Access Database

Posted: Mon Feb 22, 2010 1:14 pm
by devarishi
mikosiko wrote:comment the line 8 $rs.Update; and test.

Miko

Well, I had to comment these lines also:

Code: Select all

$rs = null;
$conn = null;
I am not sure why the same lines work well when I display / fetch records, of course in a separate web page (PHP).

Re: Insert Record into an MS-Access Database

Posted: Mon Feb 22, 2010 9:23 pm
by Benjamin
Check the server error log for more details.