KeithMcL
Wed 22nd Jun '05, 7:49pm
I have a form I'm working on where I'm able to add an item to several categories. The form is like so:
<form action="sale.php?action=add&confirmed=no" method="post" name="addsale">
<table border="0" cellspacing="0" cellpadding="4">
<tr>
<td align="right">Name:</td>
<td><input type="text" name="name" size="34" maxlength="100" /></td>
</tr>
<tr>
<td align="right" valign="top">Description:</td>
<td><textarea rows="6" cols="22" name="description"></textarea></td>
</tr>
<tr>
<td valign="top" align="right">Category:</td>
<td>
<select name="categories[]" multiple="multiple">
<optgroup label="Clothing & Accessories">
<option label="mens-clothing" value="4">Mens Clothing</option>
<option label="womens-clothing" value="5">Womens Clothing</option>
<option label="kids-baby-clothing" value="6">Kids & Baby Clothing</option>
<option label="bags-backpacks" value="15">Bags & Backpacks</option>
<option label="hats-caps" value="16">Hats & Caps</option>
<option label="jewellery" value="17">Jewellery</option>
</optgroup>
</select>
</td>
</tr>
<tr>
<td align="right">Discount:</td>
<td><input type="text" name="discount" size="1" maxlength="3" />%</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Add Sale" /></td>
</tr>
</table>
</form>Now, the categories select should return an array inside the $_POST array.
The problem is, when the form is submitted the categories element is being recognised as a string with the value "Array".
Anyone got any ideas why this is happening?
A var_dump of $_POST comes out like this:
array(5) { ["name"]=> string(13) "June Bargains" ["description"]=> string(13) "June Bargains" ["categories"]=> string(5) "Array" ["discount"]=> string(2) "10" ["submit"]=> string(8) "Add Sale" }This only happens on my host (using php 4), it works fine locally (using php5).
<form action="sale.php?action=add&confirmed=no" method="post" name="addsale">
<table border="0" cellspacing="0" cellpadding="4">
<tr>
<td align="right">Name:</td>
<td><input type="text" name="name" size="34" maxlength="100" /></td>
</tr>
<tr>
<td align="right" valign="top">Description:</td>
<td><textarea rows="6" cols="22" name="description"></textarea></td>
</tr>
<tr>
<td valign="top" align="right">Category:</td>
<td>
<select name="categories[]" multiple="multiple">
<optgroup label="Clothing & Accessories">
<option label="mens-clothing" value="4">Mens Clothing</option>
<option label="womens-clothing" value="5">Womens Clothing</option>
<option label="kids-baby-clothing" value="6">Kids & Baby Clothing</option>
<option label="bags-backpacks" value="15">Bags & Backpacks</option>
<option label="hats-caps" value="16">Hats & Caps</option>
<option label="jewellery" value="17">Jewellery</option>
</optgroup>
</select>
</td>
</tr>
<tr>
<td align="right">Discount:</td>
<td><input type="text" name="discount" size="1" maxlength="3" />%</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Add Sale" /></td>
</tr>
</table>
</form>Now, the categories select should return an array inside the $_POST array.
The problem is, when the form is submitted the categories element is being recognised as a string with the value "Array".
Anyone got any ideas why this is happening?
A var_dump of $_POST comes out like this:
array(5) { ["name"]=> string(13) "June Bargains" ["description"]=> string(13) "June Bargains" ["categories"]=> string(5) "Array" ["discount"]=> string(2) "10" ["submit"]=> string(8) "Add Sale" }This only happens on my host (using php 4), it works fine locally (using php5).