Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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


Reply With Quote
  #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

Reply With Quote
  #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
Reply With Quote
  #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.


Reply With Quote
  #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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:51 AM.


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