Array is not an Array??! is_array()

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!

Moderator: General Moderators

Post Reply
bla5e
Forum Contributor
Posts: 234
Joined: Tue May 25, 2004 4:28 pm

Array is not an Array??! is_array()

Post 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?
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: Array is not an Array??! is_array()

Post by Jade »

Have you viewed your source to see if it's printing the javascript on the page?
bla5e
Forum Contributor
Posts: 234
Joined: Tue May 25, 2004 4:28 pm

Re: Array is not an Array??! is_array()

Post by bla5e »

Jade wrote:Have you viewed your source to see if it's printing the javascript on the page?
its not
bla5e
Forum Contributor
Posts: 234
Joined: Tue May 25, 2004 4:28 pm

Re: Array is not an Array??! is_array()

Post 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));
      }
    }
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: Array is not an Array??! is_array()

Post by Jade »

It sounds to me like it's not posting any of your form values.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Array is not an Array??! is_array()

Post 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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply