PDA

View Full Version : php connecting to Access


rambo6376
02-22-2004, 01:34 PM
Hello guys!

I'm hoping someone can help me out in figuring out where my code is wrong. I'm writing a page that connects to an access database and inserts a record using data gathered from a form.

for the connection I have the following code:

$conn = new COM('ADODB.connection');
$connstring = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ='db2.mdb'";
$conn->open($connstring);

the above is in a file and I do the following in the form processing code:

require 'adoTransfer.php';

//create variables out of all post data
$date = $_POST['date'];
$rep = $_POST['rep'];
$dl = $_POST['dl'];
$name = $_POST['name'];
$contact = $_POST['contact'];
$issue = $_POST['issue'];
$comments = $_POST['comments'];

//testing the variable values
echo $date.' '.$rep.' '.$dl.' '.$name.' '.$contact.' '.$issue.' '.$comments;

$query = "insert into Transfer (Date,Rep,DL,Name,Contact,Issue,Comments) VALUES ('$date','$rep','$dl','$name','$contact','$issue','$comments');

/*
$result = $conn->execute($query);

if (!$result) echo $conn->ErrorMsg();
else echo "Insert Successful!";

$result->close();
$conn->close();*/
$result=null;
$conn=null;



The problem I am having is that it does not give me any errors at all! I have the E_ALL option set in the php.ini file but it doesnt give me an error telling me where I went wrong. If I comment out the entire block below the part where I'm testing the variable values I retrieved from the $_POST, I can see all the data is coming in correctly from the form page. However, when I uncomment the code, I get nothing - not even the values of the variables before I actually run the query! Strange thing is that I have a different page I wrote on this exact same machine using a different .mdb file and it still works.

Feel free to post any suggestions you may have at all because I have been stuck for an hour now! LOL

skidooer
02-24-2004, 05:10 PM
Are you sure it's not because you've commented out the important part of your code?