Title: can't assign row ID from DB to var for specific entry
Tags: php;mysql;ms-access
Question: I am trying to get the row (unique) ID for a row of data returned from the following SELECT query (using an ACCESS backend if it matters), so I can use the ID in a second UPDATE SET statement if the user chooses to update current data returned:
$sqlQuery = "SELECT id FROM addresses WHERE firstName='$firstName' AND lastName='$lastName'";
$rs=(odbc_exec($conn,$sqlQuery));
But instead of being assigned the (unique) row id, $rs gets passed, for where the row id=9 for example, $rs=Resource id #5. I guess I could just SELECT * from addresses and filter for ID, but I would prefer to know why the above doesn't work as I think it should. Can anyone explain what I am doing wrong here?
Comment: "Resource id #5:" is not an error. It means that you tried to `echo $rs` or another variable.

Comment: you should post your full code; your question is unclear.

Comment: you need to fetch/loop over the first (successful) result before you can use the second query; again, post your full code.

Comment: We can't fix a vehicle if it's not in the garage; again... and for the 3rd time now, post your full code. I've revisited this question 3 times and not seeing any update to the question.

Comment: Right. Later in the script I want to use $rs with: $sqlUpdate = "UPDATE addesses SET firstName='$firstName',lastName='$lastName',location='$location',email='$email',phoneNo='$phoneNo' WHERE ID = '$rs'"; but the UPDATE was failing. So then I echo'd $rs and see that it contains Resource id #5. What does that mean then? I expected to see 9 echoed when querying for data corresonding to key 9.

Comment: @Fred -ii-: Thanks for pointing me in the right direction. a Fetch/loop was exactly what I required to get at the key ID for the $row returned. Cheers.

Comment: Indeed, [odbc_exec](http://php.net/manual/en/function.odbc-exec.php) explicitly returns a resource which you would normally loop through to actually access the results.



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 7, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2017:00:01/26/17', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<php><mysql><ms-access>', 'Title': "can't assign row ID from DB to var for specific entry", 'ViewCount': 34, 'id': 41881277, 'user_AboutMe': None, 'user_AccountId': 4849334.0, 'user_DisplayName': 'scriptz', 'user_Reputation': 515.0, 'user_Views': 16.0, 'user_id': 3912084.0}}