Inserting data into a MS Access DB
Posted: Sun Feb 08, 2004 3:47 am
Hi all,
i'm having some problems running a SQL insert for an Access DB. I echoed the SQL string to the screen:
INSERT INTO member values ('bianster@aserver.com','72bKD5BpMVi4k','Doug',12345678,12345678,false,false)
and it checks out alrite but I keep getting:
Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression., SQL state 22005 in SQLExecDirect
halp!! i can't figure out why this is happening...from the error message, something's wrong with the datatypes but I have already cast 2 variables into double integers....
i'm having some problems running a SQL insert for an Access DB. I echoed the SQL string to the screen:
INSERT INTO member values ('bianster@aserver.com','72bKD5BpMVi4k','Doug',12345678,12345678,false,false)
and it checks out alrite but I keep getting:
Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression., SQL state 22005 in SQLExecDirect
Code: Select all
<?php
$emailAddr = $HTTP_POST_VARSїemailAddr];
$password = $HTTP_POST_VARSїpassword];
$name = $HTTP_POST_VARSїname];
$contact = $HTTP_POST_VARSїcontact];
$altContact = $HTTP_POST_VARSїaltContact];
$vehno = $HTTP_POST_VARSїvehno];
$vehmodel = $HTTP_POST_VARSїvehmodel];
settype($contact, "double");
settype($altContact, "double");
$status = add_member($emailAddr, $password, $name, $contact, $altContact, $vehno, $vehmodel);
function add_member($emailAddr, $password, $name, $contact, $altContact, $vehno, $vehmodel){
require 'dbconfig.dat';
$status_code = 2;
$approved = false;
$admin = false;
$salt = substr($password, 0, 2);
$encrypted_password = crypt($password, $salt);
$db_conn = odbc_connect($db, $db_server, $db_user, $db_password) or die ("Could not connect to server...");
$member_insert = "INSERT INTO member values (";
$member_insert .= "'".$emailAddr."',";
$member_insert .= "'".$encrypted_password."',";
$member_insert .= "'".$name."',";
$member_insert .= $contact . ",";
$member_insert .= $altContact . ",";
$member_insert .= "false,";
$member_insert .= "false)";
print $member_insert;
$member_add_result = odbc_exec($db_conn, $member_insert) or die ("Unable to execute query for the MEMBER table...");
odbc_close($db_conn);
return $status_code;
}
?>