PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
the code below passes the first two parameters correctly to open_db.php, but the third one, an array shows up with a content of the letters 'a r r a y' in the first 5 positions of the array and the rest is empty!!
You can't just echo an array. As qads pointed out you need to reference the element(s) you want to display. To see what those elements are you could do:
Guys - I'm fully aware of how to diplay the elements of the array. The problem is that if I do this in open_db.php (assuming 10 elemnts were initialized in the script calling open_db.php):
the resulting output is: a r r a y and I get an error message of uninitilized element for indices 6,7,8,9,10!!! So instead of the original 10 values passed through colmns=$columns in the URL the characters a r r a y are passed! having said that I can pass an array without problem with POST forinstance. It just doesn't make sense!
which returns 'Array', then when you try and access $columns on the next page $columns is not an array, it is a string which contains the 5 characters a r r a y. So you can no longer access the array elements because there aren't any. You could serialize() or implode() the data, or if there's lots of it, pass it via sessions instead.
Mac
Last edited by twigletmac on Tue Oct 01, 2002 9:04 am, edited 1 time in total.
You can't pass an array directly as a get/post parameter. You can pass an array as ?value[1]=stuff&value[2]=moresturee.... but you can't pass the whole array because the resulting url is as you wrote ?variable=array.
Sessions can handle arrays natively so you might want to see if it makes sense to pass the values you need as a session variable. Otherwise you're going to have to pass each field individually.
Another option would be to use some packing/unpacking scheme, such as changing the array to a textual, fixed deliminator string that can be passed as a single value (implode/explode).
POST doesn't really send array, it just appears to, it does the whole
variablename[]=foo&variablename[]=bar.... and php knows how to assemble this back into an array.