The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Error when looping to make group radio buttons using HTML_QuickForm

PHP 5.1.2
Apache 2.x
On a RedHat box

OK, I've been trying to nail down a solution to this problem for about 3 days now and nothing I've tried seems to work. I'm creating a survey and want to ask a question and have the user select only 1 answer. Obviously this should be done with a radio button group.

To minimize code, I created an array with the potential answers to the questions then wanted to loop through that array to generate each call for the radio button. Below is my code, then the error I receive after submitting the form.

The error I get is:Fatal error: Cannot create references to/from string offsets nor overloaded objects in /apps/home/edwards/public_html/cgi-bin/survey2007/survey2.shtml on line 35

A colleague suggested making it without the ampersand : $q2[$key] = HTML_QuickForm::createElement
Which instead throws the error: Catchable fatal error: Object of class HTML_QuickForm_radio could not be converted to string in /apps/home/edwards/public_html/cgi-bin/survey2007/survey2.shtml on line 31

Can I accomplish this without hard-coding each radio button? Thanks for any help you all can provide.

QuickForm did not like the fact that I wanted to name my radio button 'q2' and use the variable name '$q2' to input the question's answer values. If I use a different variable name to input my answers it takes no problem.

This error may have been caused by a conflict when submitting the form since our server has Magic Quotes enabled, which would make all post vars for that radio group come back in $q2 before being redefined later in the QuickForm code block.

Whatever the case, just be careful of your variable naming conventions!