Where are you using quotes? Your query:
SELECT code, long_name FROM features WHERE code in (A04, B03, B05, C04, C06, C07, D01, E10, F01, G01, G04, H01, I01, J04, R02, O01, L02, M02, K02, S02, N01, N05, N11, N14, P02, P03, P04, P06, P07, P16, Q06, Q10, Q11, U05, U09, V01, V02, V03, V04, W09, )
Doesn't show any quotes around the codes in the code list. Your query should look like this (formatted for easy reading):
SELECT code, long_name
FROM features
WHERE code in ("A04", "B03", "B05", "C04", "C06", "C07", "D01",
"E10", "F01", "G01", "G04", "H01", "I01", "J04",
"R02", "O01", "L02", "M02", "K02", "S02", "N01",
"N05", "N11", "N14", "P02", "P03", "P04", "P06",
"P07", "P16", "Q06", "Q10", "Q11", "U05", "U09",
"V01", "V02", "V03", "V04", "W09")
Also your query has a trailing , after W09. You need to change your for loop to fix this.
$sep = "";
for ($i = 0; $i < strlen($split_features); $i += 3) {
$currCode = substr($split_features,$i ,3);
$codeList = $sep . '"' . $currCode . '"';
$sep = ", ";
}
You only want to check up to the length of the string, not including the entire length. This is because we are starting at 0 and not at 1. This has to do with the fact that the numbers we are working with are offsets not character positions and offsets always start at 0.