Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
lwavery769
Starting Member
3 Posts |
Posted - 2013-07-11 : 13:21:48
|
Hi, I'm trying to select a record in Access through PHP.I've tried:SELECT * FROM Table1 WHERE 'FullName' = 'ABNER AVERY'Failed!SELECT * FROM Table1 WHERE FullName = 'ABNER AVERY'Success, correct displaySELECT * FROM Table1 WHERE INDI_ID =64 / "SELECT * FROM Table1 WHERE \"INDI_ID\"=64"No Error, no displaySELECT * FROM Table1 WHERE INDI_ID = 64 / SELECT * FROM Table1 WHERE INDI_ID=64Error "(Ào" no displaySELECT * FROM Table1 WHERE 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 1022005 SELECT * FROM Table1 WHERE INDI_ID=\"64\"Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1., SQL state 07001 in SQLExecDirect in C:\xampp\htdocs\averykin\testdb.php on line 1007001MY code:$conn=odbc_connect('genealogy','','');//dsn$sql="SELECT * FROM Table1 WHERE INDI_ID = 108";////FullName ='ABNER AVERY'//=#27-Sep-50# finds dates equal to 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"]); |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-07-11 : 13:24:15
|
quote: Originally posted by lwavery769 Hi, I'm trying to select a record in Access through PHP.I've tried:SELECT * FROM Table1 WHERE 'FullName' = 'ABNER AVERY'Failed!SELECT * FROM Table1 WHERE FullName = 'ABNER AVERY'Success, correct displaySELECT * FROM Table1 WHERE INDI_ID =64 / "SELECT * FROM Table1 WHERE \"INDI_ID\"=64"No Error, no displaySELECT * FROM Table1 WHERE INDI_ID = 64 / SELECT * FROM Table1 WHERE INDI_ID=64Error "(Ào" no displaySELECT * FROM Table1 WHERE 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 1022005 SELECT * FROM Table1 WHERE INDI_ID=\"64\"Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1., SQL state 07001 in SQLExecDirect in C:\xampp\htdocs\averykin\testdb.php on line 1007001MY code:$conn=odbc_connect('genealogy','','');//dsn$sql="SELECT * FROM Table1 WHERE INDI_ID = 108";////FullName ='ABNER AVERY'//=#27-Sep-50# finds dates equal to 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"]);
If your second case works correctly and displays the record correctly, what is the issue you are facing? The second query seems sytnactically correct to me as well. |
|
|
lwavery769
Starting Member
3 Posts |
Posted - 2013-07-11 : 13:35:22
|
I need to select records by the integer in the INDI_ID field. |
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-07-11 : 13:55:49
|
Remove the single quote and it should work.SELECT * FROM Table1 WHERE INDI_ID=64 But in your case if it is not returning any records, can it be because there are no records in the table that match that filter? You could also try this:SELECT * FROM Table1 WHERE CStr(INDI_ID)='64' |
|
|
lwavery769
Starting Member
3 Posts |
Posted - 2013-07-11 : 17:37:50
|
Thanks, but no luck. This works:SELECT * FROM Table1 WHERE FullName = 'ABNER AVERY' Success, correct display:(ÀoRows returned: -1Key = INDI_ID Value = 64Key = Given Value = ABNERKey = Surname Value = AVERYKey = Birth Value = 28 MAY 1712Key = BirthPlace Value = Groton, New London, Connecticut, USAKey = Death Value = 13 AUG 1771Key = DeathPlace Value = Montville, New London, Connecticut, USAKey = Mother Value = ELIZABETH BILLKey = Father Value = JONATHAN AVERYKey = Spouse1 Value = AMY FOXKey = Marriage1 Value = 22 MAY 1740but,SELECT * FROM Table1 WHERE INDI_ID = 64 produces an Error "(Ào" and no display |
|
|
|
|
|
|
|