having a real problem with a bit of code.
I've passed 10 variables to a PHP script:
$Answer1
$Answer2
....
$Answer10
Each variable contains a code, which relates to a field called "code", ina record in a MySQL database. The other field in each record is called "body".
I'm trying to query out the data in the "body" field, for each record that matches the data in one of the $Answer variables. So I've got the following code so far:
for ($n = 0; $n < 10; $n++) {
$answervar = "$answer$n";
$sqlquery = "SELECT body FROM $table WHERE code = {$$answervar}";
$result = mysql_query($sqlquery);
while($row = mysql_fetch_object($result)) {
print $row->body; }
}
So I'm trying to move through each variable, query the table, print the value, and move onto the next one....only for the code above I'm getting the following error:
Warning: Supplied argument is not a valid MySQL result resource in /home/sites/site102/web/arraytest.php on line 30
I've tried fiddling with everything but I just cant get it to work...can anyone help?
Thanks...