Hello, I am trying to add some data to an ODBC database. (in this case Access). I have written a script that connects to Access. It seems to connect to the DB ok so there are no problems there, however it seems to have a problem with actually executing the query. What am I doing wrong here.
Before anyone says, why am I using access and not MySQL, this is just as a test, to see it connect to other databases. I know that this works well in MySql.
Here is the script. :
<html>
<head>
<title>Address Book</title>
</head>
<body>
<center><form action"<?php echo("$PHP_SELF")?>" method="post">
First Name <INPUT TYPE="text" NAME="firstname" size ="40"><br>
Last Name <input type="text" name="lastname" size ="40"><br>
email address <input type="text" name="email" size="40"><br>
Tel number <input type="text" name="tel" size="40"><br>
<br>
<INPUT TYPE="submit" name="submit" value="Submit!">
</FORM></center>
<?php
if(isset($_POST['submit'])) {
// decalre variables
$firstname= trim ( $_POST['firstname'] );
$lastname = trim ($_POST['lastname'] );
$email = trim ($_POST['email'] );
$tel = trim ($_POST['tel'] );
if($firstname!="" && $lastname!="" && $email!="" && $tel!="") {
$conn = odbc_connect ('address', '', '') or die( "Could Not Connect to ODBC Database!" );
//$conn= mysql_connect("localhost", "root", "") or die("connection error");
// mysql_select_db("address", $conn) or die("Could not find database you specified ");
//$query ="INSERT into details VALUES('$firstname', '$lastname', '$email', '$tel')";
$query ="Insert into Details (firstname, lastname, email, tel) VALUES ('$firstname', '$lastname', $email','$tel')";
$result=mysql_query ($query) or die ("There has been a problem with executing the query.");
if($result)
echo 'Thankyou. The information you submitted, has been added to the database.';
}
}
?>
</body>
</html>