SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select integer
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

lwavery769
Starting Member

3 Posts

Posted - 07/11/2013 :  13:21:48  Show Profile  Reply with Quote
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 display

SELECT * FROM Table1 WHERE INDI_ID =64 / "SELECT * FROM Table1 WHERE \"INDI_ID\"=64"
No Error, no display

SELECT * FROM Table1 WHERE INDI_ID = 64 / SELECT * FROM Table1 WHERE INDI_ID=64
Error "(Ào" no display

SELECT * 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 10
22005

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 10
07001
MY 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
Flowing Fount of Yak Knowledge

3562 Posts

Posted - 07/11/2013 :  13:24:15  Show Profile  Reply with Quote
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 display

SELECT * FROM Table1 WHERE INDI_ID =64 / "SELECT * FROM Table1 WHERE \"INDI_ID\"=64"
No Error, no display

SELECT * FROM Table1 WHERE INDI_ID = 64 / SELECT * FROM Table1 WHERE INDI_ID=64
Error "(Ào" no display

SELECT * 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 10
22005

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 10
07001
MY 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.
Go to Top of Page

lwavery769
Starting Member

3 Posts

Posted - 07/11/2013 :  13:35:22  Show Profile  Reply with Quote
I need to select records by the integer in the INDI_ID field.
Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3562 Posts

Posted - 07/11/2013 :  13:55:49  Show Profile  Reply with Quote
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'
Go to Top of Page

lwavery769
Starting Member

3 Posts

Posted - 07/11/2013 :  17:37:50  Show Profile  Reply with Quote
Thanks, but no luck. This works:
SELECT * FROM Table1 WHERE 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

but,
SELECT * FROM Table1 WHERE INDI_ID = 64 produces an Error "(Ào" and no display
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000