RE: [PHP] $answers[answer$n]

From: Date: Fri, 17 May 2002 20:36:38 +0000
Subject: RE: [PHP] $answers[answer$n]
Groups: php.general 
Request: Send a blank email to php-general+get-98186@lists.php.net to get a copy of this message
Try $answers["answer".$n] --- Scott Hurring Systems Programmer EAC Corporation ScottH@eac.com Voice: 201-462-2149 Fax: 201-288-1515 > -----Original Message----- > From: Jule [mailto:jslootbeek@clarku.edu] > Sent: Friday, May 17, 2002 4:41 PM > To: php-general@lists.php.net > Subject: [PHP] $answers[answer$n] > > > 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 | > | __________________________ | > |/\/ \/\| > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#98186) next »