|
|||||||
New to SitePoint Forums? Register here for free!
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
SitePoint Enthusiast
![]() Join Date: Dec 2004
Location: India
Posts: 96
|
Problem with checkbox array
hi,
I have got a weird bug . I have a form in which I have lot of checkboxes. Hence I used the grouping convention and named the elements like <input type="checkbox" name="chk_ticket[]" value="S0001"> <input type="checkbox" name="chk_ticket[]" value="S0002"> and after I post to a script , I expect the $_POST['chk_ticket'] to be an array with two values S0001 and S0002 if both have been checked. It does work correctly for me locally (in my machine). And when i execute the print_R($chk_ticket); also I get the two elements printed .. (only locally). But in my remote server , the same form and the same code is not working .. I don't know why? The remote server has : PHP Version 4.3.10 Windows NT PARROT 5.0 build 2195 running on Microsoft-IIS/5.0 Does this have anything to do with my script ? Thanks & Regards, Celia |
|
|
|
|
|
#2 |
|
SitePoint Evangelist
![]() ![]() ![]() ![]() Join Date: Jun 2004
Location: Mumbai
Posts: 443
|
Whats the error Msg ?
|
|
|
|
|
|
#3 |
|
SitePoint Enthusiast
![]() Join Date: Dec 2004
Location: India
Posts: 96
|
Thanks for replying ..
in server, print_R($chk_ticket) gives me "Array" as output. SO does print_R($_POST['chk_ticket']); I am not able to access this variable in my php and if i print count of chk_ticket , i get 1 where as locally this works perfectly . Regards, Celia |
|
|
|
|
|
#4 |
|
SitePoint Enthusiast
![]() Join Date: Dec 2004
Location: India
Posts: 96
|
Bug Fixed.New doubt crops up..
Sorry.Problem was not with the checkbox array as such ..While retrieving all the POST data , I look for magic quotes and if that is not enabled i add slashes and rebuild the array.
if (!get_magic_quotes_gpc()) { while(list($key,$value)=@each($_POST)) { $_POST[$key]=addslashes($value); // Problem here } } The above code has caused me the problem when $value happened to be my check box array data.I am still not sure why it caused the problem but I however added a fix to it saying that this if block should execute only if $value is not an array. if (!get_magic_quotes_gpc()) { while(list($key,$value)=@each($_POST)) { if(!is_array($value) $_POST[$key]=addslashes($value); } } This may not be a good fix.People over here might know it better.But I somehow needed to add a quick fix to it.Please do tell me what is the problem with my former(first) code. Last edited by celia; Feb 7, 2005 at 00:42. Reason: I thought that this reply of mine was not understood my anyone |
|
|
|
|
|
#5 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Jan 2005
Location: India:Chennai
Posts: 826
|
Hai celia,
Have you corrected your problem,As my view it will work just try ny giving post_r($_POST) once again at the top of you page and right the next line exit the page. ArunKumar |
|
|
|
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 13:31.









Linear Mode
