Page 1 of 1
Array is not an Array??! is_array()
Posted: Mon Jul 12, 2010 11:49 am
by bla5e
Code: Select all
<select name="prods[]" id="products" MULTIPLE size=5 style="width:250px; display:none;">
</select>
<select name="cats[]" id="categories" MULTIPLE>
{foreach from=$categories item=category}
<option value="{$category.id}">{$category.category}</option>
{foreachelse}
<optgroup label="[SQL ERROR]"></optgroup>
{/foreach}
</select>
<script type="text/javascript">
$('#products').load('https://corp.my.domain/associatedpubs/');
</script>
It loads the select boxes fine.
Code: Select all
if(is_array($_POST['prods'])){
echo '<script type="text/javascript">alert(\'Product Array!\');</script>';
}
if (is_array($_POST['cats'])){
echo '<script type="text/javascript">alert(\'Category Array!\');</script>';
}
I never see the alerts

I have DB delete/inserts inside the same IF;s but neither of them get hit either.
When i do
print_r($_POST['cats']);
print_r($_POST['prods']);
it just says ArrayArray.
wtf?
Re: Array is not an Array??! is_array()
Posted: Mon Jul 12, 2010 12:09 pm
by Jade
Have you viewed your source to see if it's printing the javascript on the page?
Re: Array is not an Array??! is_array()
Posted: Mon Jul 12, 2010 1:00 pm
by bla5e
Jade wrote:Have you viewed your source to see if it's printing the javascript on the page?
its not
Re: Array is not an Array??! is_array()
Posted: Mon Jul 12, 2010 1:23 pm
by bla5e
i forgot about my sql injection script to stop from injections
this fix
Code: Select all
foreach($_POST as $key=>$value) {
if($key != 'prods' && $key != 'cats'){
$_POST[$key] = pg_escape_string(stripslashes($value));
}
}
Re: Array is not an Array??! is_array()
Posted: Mon Jul 12, 2010 2:00 pm
by Jade
It sounds to me like it's not posting any of your form values.
Re: Array is not an Array??! is_array()
Posted: Mon Jul 12, 2010 2:08 pm
by AbraCadaver
You've done something else in your code that is creating a multi-dimensional array out of those. Post your code from the entire page.