I am glad I found you all.  I have been teaching myself php and mysql
out of books for several months now.  I haven't found anyone in my
community to chat with about these subjects.  It is nice to have
someone to bounce ideas off of, help, and get help from.

Here's my problem.  I am constructing polls from my database.  I have
it set up with a form to input poll questions, the type of question
(radio button, check box, select box).  I have each questions stored
in a separate table with a code for the type of question, and the
possible responses.  What I am trying to do in my code is render the
form with loops.

/* put the table names into an array */
$tableid= array('pollq1', 'pollq2', 'pollq3', 'pollq3', 'pollq4',
'pollq5', 'pollq6', 'pollq7', 'pollq8', 'pollq9');
for ($i=0; $i <= $numberofqusetions]; $i++) {
        $query = '"SELECT * from '. $tableid[$i]. ' where uid = '. $pid;. '"';
        $getresps = mysql_query($query) or die (mysql_error());
        $resps = mysql_fetch_array($getresps);
        /* The following line puts the answers into a two dimensional array
to make them easier to process when printing them.
        $a[$i] = array($resps["a1"], $resps["a2"], $resps["a3"],
$resps["a4"], $resps["a5"], $resps["a6"], $resps["a7"], $resps["at8"],
$resps["a9"], $resps["a10"]);
}

My problem is that no matter what I try I get a unknown column 'uid'
in 'where clause' error.  I have tried to structure the query in
different ways using different configurations of ' and " marks to get
this to work.  The I know it is seeing the value of the variable,
because when I structure the query like this:

$getresps = mysql_query("SELECT * from ('".$tableid[$i]."') where uid
= ('".$pid."')") or die (mysql_error());

I get a syntax error near ''pollq1') where uid = ('1')' at line 1

I have used this syntax before with a standard variable (not array),
or I have used -- (".$table.") -- before and had it work.

What am I missing?  What am I doing wrong?

Reply via email to