Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 10th, 2004, 12:31 AM
Registered User
 
Join Date: Dec 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default stupid question

Hi,

This might be a very simple question but I've spent far too much time trying to figure out why it isn't working:

I keep getting this parse error:

Parse error: parse error, unexpected ']', expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\sokkit\site\question_list.php on line 41

referencing this line: echo "<input type =\"checkbox\" name = \"'$chkQ[]'\" value =\"$Q_ID\"> $Question <BR>";

I am trying to put every possible selected value from a set of checkboxes into an array (chkQ[]) and sent that via POST to another page. If I take the brackets off, i.e. just have ' name=\"$chkQ\", then it will either a) not send anything in an array to the next page or b) will only send the last thing selected and when I search through the array it is, of course, undefined. Anyone with answers to my stupid question?

Thank you for your time.

- JP


  #2 (permalink)  
Old December 10th, 2004, 01:29 AM
Registered User
 
Join Date: Dec 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Also, I know that I have an added single quotation mark in my line, the error is the same whether it reads \"'chkQ[]'\" or \"chkQ[]\". I've read the other posts on check boxes and tried to modify my code but so far nothing has worked that will allow me to still keep the values of the multiple checkboxes sent to another page (in an array). Any help is very much appreciated.

Thanks.

- JP

  #3 (permalink)  
Old December 10th, 2004, 04:59 AM
Authorized User
 
Join Date: Oct 2004
Location: Edinburgh, Scotland, United Kingdom.
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to SiliconFuRy
Default

Hi dude,

try seperating out the String, and use single quotes in the html part,so it now reads...

echo "<input type ='checkbox' name = '" . $chkQ[] . '" value ='" . $Q_ID . "'> ". $Question . " <BR>";

I find this not only easier to read, but easier to Troubleshoot


Many shoes,

Jamez/SiliconFuRy
  #4 (permalink)  
Old December 10th, 2004, 10:01 AM
Registered User
 
Join Date: Dec 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the change, now it says:

Fatal error: Cannot use [] for reading in C:\sokkit\site\question_list.php on line 41

when I changed it to:
echo "<input type ='checkbox' name = '" . $chkQ[] . '" value ='" . $Q_ID . "'> ". $Question . " <BR>";

Any ideas? I'm not sure how that code is so much different than other I've written and seen on this website.

Thanks for your time.


  #5 (permalink)  
Old December 13th, 2004, 05:06 AM
Authorized User
 
Join Date: Oct 2004
Location: Edinburgh, Scotland, United Kingdom.
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to SiliconFuRy
Default

its that variable, $chkQ[]

try removing the []

Many shoes,

Jamez/SiliconFuRy


Similar Threads
Thread Thread Starter Forum Replies Last Post
stupid question... seymour_glass C# 3 May 2nd, 2007 06:40 AM
Probably stupid question skiloff BOOK: ASP.NET Website Programming Problem-Design-Solution 0 July 6th, 2005 02:44 PM
stupid question Warbird General .NET 6 December 7th, 2004 09:33 AM
A really stupid question Phaedrus VB.NET 2002/2003 Basics 3 October 29th, 2003 02:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.