I have some code that doesn't seem to work. I'm using a form to post a value (green, blue, red, etc) and make it look up something in the database using that post value as part of a variable name.
$mine = 'green';
$querymine = $dbcon->prepare('SELECT * FROM mine WHERE playerid = :playerid');
$querymine->execute(array(
'playerid' => $playerid
));
$rowmine = $querymine->fetch(PDO::FETCH_ASSOC);
if (${'rowmine[\'has'.$mine.'\']'} == 0) {
header("location:mine.php");
die();
}
It is looking up the column "hasgreen", which is INT 4 in this case. The problem is, it tells me that $rowmine['hasgreen'] is NULL, thus I'm getting kicked back to "mine.php". I'm not sure what the problem is, maybe the use of \' in the variablename?