Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-06-2003, 04:10 PM   PM User | #1
mathewvp
New Coder

 
Join Date: Jul 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
mathewvp is an unknown quantity at this point
variable variables

Hi,
I am migrating from an older php version which is causing me a lot of problems.
I have a question answer form where the admin can enter five questions and 4 answers each and a radio group for each question for selecting the correct answer
For eg
Question1-textbox for question
Choice1 -text box with name choice1
Choice2 -text box with name choice2
Choice3 -text box with name choice3
Choice4 -text box with name choice4
Choice5 -text box with name choice5


Select the correct answer-radio box with name answer1 and these values
1)choice1 2)choice2 3)choice3 4)choice4 5)choice5

And once the form is submitted,I could find the answer that the admin selected using

$ans1=${$answer1};
and similarly for the answers for remaining questions

Now this doesn't work with newer version of php.So can anybody tell me how to solve this.

Thanks
mathewvp is offline   Reply With Quote
Old 10-06-2003, 09:03 PM   PM User | #2
Acecool
New Coder

 
Join Date: Sep 2003
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Acecool is an unknown quantity at this point
$$answer1
__________________
http://www.acecoolco.com/avs/Acecool..._Signature.php
If you plan on contacting me, please read this: Legal Terms & Conditions
Acecool is offline   Reply With Quote
Old 10-07-2003, 10:05 AM   PM User | #3
mathewvp
New Coder

 
Join Date: Jul 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
mathewvp is an unknown quantity at this point
Acecool is that supposed to be an answer.Thanks anyway
mathewvp is offline   Reply With Quote
Old 10-07-2003, 11:47 AM   PM User | #4
mordred
Senior Coder


 
Join Date: Jun 2002
Location: frankfurt, german banana republic
Posts: 1,848
Thanks: 0
Thanked 0 Times in 0 Posts
mordred is an unknown quantity at this point
Looks like you're not using the newer superglobal arrays $_POST, $_GET etc. which replaced the old way of having the variables automagically put into the script by enabling register_globals since PHP 4.2. You have to rewrite your script or enable register_globals. I'll recommend the first option.

BTW, "doesn't work" is very little information to begin with. Any error messages? What does var_dump($answer1); say?
__________________
De gustibus non est disputandum.
mordred is offline   Reply With Quote
Old 10-07-2003, 12:00 PM   PM User | #5
mathewvp
New Coder

 
Join Date: Jul 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
mathewvp is an unknown quantity at this point
modred, I know it doesn't work coz in newer versions of php register globals are off.I cant turn it on coz its not my server so I cant edit the php.ini file.Anyway I found a solution

Use extract() function.That will help me not to rewrite the code.Thanks for trying to help modred
mathewvp is offline   Reply With Quote
Old 10-07-2003, 01:32 PM   PM User | #6
mordred
Senior Coder


 
Join Date: Jun 2002
Location: frankfurt, german banana republic
Posts: 1,848
Thanks: 0
Thanked 0 Times in 0 Posts
mordred is an unknown quantity at this point
FYI: Another possibility would have been to use import_request_variables() for a quick and hacky fix of your problem.
__________________
De gustibus non est disputandum.
mordred is offline   Reply With Quote
Old 10-07-2003, 02:17 PM   PM User | #7
mathewvp
New Coder

 
Join Date: Jul 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
mathewvp is an unknown quantity at this point
with import_request_variables() I will have to rename all my variables and the "variable variables" code will not work.And renaming all my code is a very tedeous work and error prone too. extract() does what I want for me.
Thanks modred
mathewvp is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:25 PM.


Advertisement
Log in to turn off these ads.