General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 27th, 2004, 11:32 AM
Karstengp Karstengp is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Texas
Posts: 3 Karstengp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Karstengp Send a message via AIM to Karstengp Send a message via Yahoo to Karstengp
Question Using a Variable in a $_POST

I'm currently trying to develope a system that allows users to develop tests. These tests can range from 10 questions to 100 questions. To cope with the different size I setup each test as its own table.

Now to read the input from the forms generated by this test I am using a while loop:

$TestData = @mssql_query("SELECT Id FROM Course$CourseId$TestType");

$Counter = 1;
while ($TData = mssql_fetch_array($TestData))
{
$QuestionId = htmlspecialchars($TData["Id"]);
$Question$Counter = $_POST["$QuestionId"];
$Counter++;
}

How can I get the $QuestionId to be read as a number and not a variable. cause it spits back "..parse error, unexpected T_VARIABLE.."

Reply With Quote
  #2  
Old January 27th, 2004, 11:46 AM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
what line is the problem at

Reply With Quote
  #3  
Old January 27th, 2004, 11:56 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Your problem's in the second line within your while statement. You're jamming two variables together and trying to assign the $_POST value to the jammed-together variables. You'll need to use an array or something instead.

Incidentally, it's probably not the best idea to have a different table for each test. Better to have a test table that holds general info (title, etc.) and a questions table that has a test_id field for each row mapping the row's question to the given test.

Reply With Quote
  #4  
Old January 27th, 2004, 12:33 PM
Karstengp Karstengp is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Texas
Posts: 3 Karstengp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Karstengp Send a message via AIM to Karstengp Send a message via Yahoo to Karstengp
The problem is with
$Question$Counter = $_POST["$QuestionId"];

Reply With Quote
  #5  
Old January 27th, 2004, 12:45 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
i have a poll script i wrote, if u want ill post it so u can get the basic idea of what houston was saying.

Reply With Quote
  #6  
Old January 27th, 2004, 09:35 PM
Karstengp Karstengp is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Texas
Posts: 3 Karstengp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Karstengp Send a message via AIM to Karstengp Send a message via Yahoo to Karstengp
Thanks I got it to work, also thanks for the advice on my database setup...

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Using a Variable in a $_POST


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT