$answers[answer$n]
| From: | Jule | Date: | Fri, 17 May 2002 20:40:47 +0000 |
| Subject: | $answers[answer$n] | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-98184@lists.php.net to get a copy of this message | ||
Hey guys,
i'm getting this error whe i try to access this variable. $answers[answer$n]
Parse error: parse error, expecting `']'' in
/home/blindtheory/web/quiz/add_quiz/add_quiz_process_2.php on line 36
the variable $answer[answers$n] comes from a form on the preceding page in
which a number of answers has been entered. the number of answers is up to
the user and can vary from 2 to 15. not the $n comes from a for loop whcih
enteres the answers into a database since i do not know how many answers each
user has used.
why am i getting this error?
and is there a way around it?
following is the for() loop in which this story takes place.
thanks
Jule
--SCRIPT--
for ($n = 1; $n <= $quiz[number_answers]; $n++) {
$table = "$quiz[code]_answers";
$value = "$answers[answer$n]";
$query_alter_table = "ALTER table $table ADD answer$n TEXT NUT NULL";
$query_add_answers = "INSERT INTO $table (answer$n) VALUES($value)";
if (mysql_db_query($database_glob, $query_alter_table, $link_glob) AND
(mysql_db_query($database_glob, $query_add_answer, $link_glob));
echo "Answer $n has successfully been added to the Quiz<br>\n";
} else {
echo mysql_error();
}
echo "Click here to continue";
}
--SCRIPT--
--
|\/\__________________________/\/|
| Jule Slootbeek |
| jslootbeek@clarku.edu |
| http://blindtheory.cjb.net |
| __________________________ |
|/\/ \/\|