I'm trying to create a application using Php that enables me to insert a new record into an MS Access
database.
I've created a DSN for my access databse giving it the name 'CD'.
I've tried to methods of database connection, one using ADODB and the other using ODBC_connect. I've
received errors for each methods i've used.
Here are my codes, pls help and see what my problem is.
// Using ADODB
function Data_connect($Release,$Retest,$theDate,$Type,$UNum) {
include('adodb/adodb.inc.php'); //load code common to ADODB
$con = &ADONewConnection('access'); //create a connection
$con->PConnect('CD'); //connect to MS-Acess through DSN
$sql = "INSERT INTO Num (Release, Retest, Date, Type, UniqueNum) VALUES ('$Release', '$Retest', '$theDate',
'$Type', '$UNum')";
print $sql;
echo "<br>";
//$exec = $con->Execute($sql);
//print $exec;
if ($con->execute($sql) === False) {
print 'error inserting: '.$con->ErrorMsg().'<br>';
} else {
print "Successful";
}
}*/
it gives out this error ->
INSERT INTO Num (Release, Retest, Date, Type, UniqueNum) VALUES ('1', '2', '13062001', 'S', '0004')
error inserting: !! ODBC ACCESS:
/*Using ODBC Connect
function Data_connect($Release,$Retest,$theDate,$Type,$UNum) {
$cnx=odbc_connect('CD', 'root', '');
if(!$cnx) {
Error_handler("Error in odbc_connect", $cnx);
}
$SQL="INSERT INTO Num (Release, Retest, Date, Type, UniqueNum) ";
$SQL .= "VALUES ('$Release', '$Retest', '$theDate', '$Type', '$UNum')";
print $SQL;
$cur = @odbc_exec($SQL);
if (!$cur) {
Error_handler("Error in odbc_exec(no cursor returned)", $cnx);
}
odbc_close($cnx);
}
it gives out this error ->
INSERT INTO Num (Release, Retest, Date, Type, UniqueNum) VALUES ('2', '3', '13062001', 'S', '0004')
Fatal error: Call to undefined function: error_handler() in E:\webdev\chip\DataAccess.php on line 47
Thank you