php - Bug in Jet/Sql? -


i'm using jet in php. querying text field easy, primary key integer, , can't correct string. i've tried fallowing:

select * table1 'fullname' = 'abner avery' failed!

select * table1 fullname = 'abner avery' success, correct display:

(Àorows returned: -1 key = indi_id value = 64 key = given value = abner key = surname value = avery key = birth value = 28 may 1712 key = birthplace value = groton, new london, connecticut, usa key = death value = 13 aug 1771 key = deathplace value = montville, new london, connecticut, usa key = mother value = elizabeth bill key = father value = jonathan avery key = spouse1 value = amy fox key = marriage1 value = 22 may 1740 

select * table1 indi_id =64 / "select * table1 \"indi_id\"=64" no error, no display

select * table1 indi_id = 64 / select * table1 indi_id=64 error "(Ào" no display

select * table1 indi_id='64' warning: odbc_exec(): sql error: [microsoft][odbc microsoft access driver] data type mismatch in criteria expression., sql state 22005 in sqlexecdirect in c:\xampp\htdocs\averykin\testdb.php on line 10 22005

select * table1 indi_id=\"64\" warning: odbc_exec(): sql error: [microsoft][odbc microsoft access driver] few parameters. expected 1., sql state 07001 in sqlexecdirect in c:\xampp\htdocs\averykin\testdb.php on line 10 07001

column indi_id type integer column fullname type varchar column surname type varchar column given type varchar column sex type varchar column birth type varchar here's php:

     <?php $conn=odbc_connect('genealogy','','');//dsn $id=2; $n=(int)$id; ini_set ( 'odbc.defaultlrl' , '65536' ); $sql="select * table1 indi_id='64'";echo $sql."</br>"; // //fullname = 'abner avery' //=#27-sep-50# finds dates equal 27 september 1950 $result=odbc_exec($conn,$sql);echo odbc_error($conn); if (odbc_fetch_row($result)) {     $assoc=array();    while($user_detail = odbc_fetch_array($result) ) {         $assoc = array_push_assoc($assoc, 'indi_id', $user_detail["indi_id"]);         $assoc = array_push_assoc($assoc, 'given', $user_detail["given"]);    

it appears code you're trying "escape" table name, or wrap query engine recognize field.

in access/jet typically done using square brackets. i'm not familiar odbc driver you're using don't know how closely relates pure jet.

$sql="select * table1 [indi_id] = 64";echo $sql."</br>"; 

don't wrap number 64 in quotes of kind unless field data type you're using text.

here's recommendations try narrow down real problem:

  • try retrieving single field.
  • try changing primary key field name simpler, no symbols in it.

    $sql="select id table1 id = 64";echo $sql."";


Comments