开发者

Data type mismatch in criteria expression using Access via ODBC

$conn=odbc_connect('mobshopDB','','');
    if(!$conn){
        exit("Connection Failed: " . $conn);
    }
    $query="INSERT INTO users(uid,pass,fname,lname,pmm) VALUES('$username','$password','$fname','$lname',$pmm)";
    $rs=odbc_exec($conn,$query);

this query gives me this error

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in c开发者_如何学Criteria expression., SQL state 22005 in SQLExecDirect in C:\Program Files\EasyPHP-5.3.6.0\www\mobshop\registered.php on line 39

..please suggest a solution

NOTE: pmm is a numeric field, thats why i haven't put it in quotes.


"Data Type Mismatch" indicates that you are trying to pass in an incorrect data type in one of your variables for one of the fields listed in your first set of parenthesis.

Try writing $query to the screen using echo and then take that result and run it in your MS Access database query designer (assuming you have the MS Access software).


Instead of This

$query="INSERT INTO users(uid,pass,fname,lname,pmm) VALUES('$username','$password','$fname','$lname',$pmm)";

Try This

$query="INSERT INTO users(uid,pass,fname,lname,pmm) VALUES('$username','$password','$fname','$lname','$pmm')";

You just forget single quote in $pmm field. Remember if you are using ODBC then be careful with datatype.

If the value will be an integer then do Type casting of value like this
$id = (int) $id;

If Datatype is not Integer then you must put single quotes

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜