I'm really stumped by this. Here is the php:
Update: I have escaped the inputs (before I did this a different way, but didn't know about mysql_real_escape_string). Also, I replace the double quotes with single quotes, yet the same problem is happening. Below is the updated code:
$request = mysql_real_escape_string($_POST['id']);
$colName = mysql_real_escape_string($_POST['col_name']);
function executeAssoc1($q)
{
$r = mysql_query($q) or die(mysql_error() . ' ' . $q);
$rass = mysql_fetch_assoc($r);
return $rass;
}
foreach(array_keys($_POST) as $pitem)
{
if($pitem == (...what I want it to...))
{
$pitem_name = mysql_real_escape_string(rawurldecode($pitem));
$qf = "SELECT * FROM possible_values WHERE table_id=$request AND col_name='$colName' AND value = '$pitem_name'";
$qfr = executeAssoc1($qf);
var_dump($pitem_name);
echo '<br>';
var_dump($qf);
echo '<br>';
var_dump($qfr);
}
}
Here is part of what that code outputs during one loop:
string(37) "1 .New England (Northeast region)"
string(122) "SELECT * FROM possible_values WHERE table_id=3 AND col_name='DIVISION' AND value = '1 .New England (Northeast region)'"
bool(false)
Now when I copy that query into the phpmyadmin SQL editor it does actually return a result. I even tried using LIKE "%...%" as suggested in here but the same thing happens (phpmyadmin returns a row, php returns 0 rows).