disappearing array?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am not sure what the heck is going with this but here is my problem.

I am trying to validate the contents of an array, then determine if the
errors are with the array or another form submitted variable.

The problem is after the code validates the array and other form
variables using an if statement, I then try to determine if the error is
in the array but for some reason the contents of the array disappear.

Weird. Any help is appreciated.

Here is the code:

function ValArray( $array )
 {
  echo "<pre>"; print_r( $array ); echo "</pre>";
  $val = new ValidateStrings();
  $data = 0;
  if( count( $array ) !== 0 ) {
   for( $x = 0; $x < count( $array ); $x++ ) { echo "DATA: " .
$array[$x][0] . "<br>";
    if( $val->ValidateInteger( $array[$x][0] ) === -1 ) {// || (
$val->ValidateParagraph( $array[$x][1] ) === -1 ) || (
$val->ValidateMoney( $array[$x][2] ) === -1 ) || (
$val->ValidateAlphaChar( $array[$x][3] ) === -1 ) || (
$val->ValidateAlphaChar( $array[$x][4] ) === -1 ) ) {
     $data = -1;
    }
   }
  } echo "RESULTS: " . $data .  "<BR>";
  return $data;
 }

if( ValArray( $_POST['add_order_items'] ) === -1 ) {
 $message = "error";
 echo "<pre>"; print_r( $_POST['add_order_items'] ); echo "</pre>";

 // here is where it is empty or something else
 if( $fix->ValArray( $_POST['add_order_items'] === -1 ) ) {
  $errors['add_order_array'] = $erlink;
 }

 echo "<pre>"; print_r( $_POST['add_order_items'] ); echo "</pre>";

And the output:
Array
(
    [1] => Array
        (
            [0] => ^&%*&(
            [1] => ^*&()
            [2] => ^*&()
            [3] => ^*&()_
            [4] => ^%&*()
        )

    [0] => Array
        (
            [0] => afadsf
            [1] => adsfasfasdf
            [2] => asdfasdfasdf
            [3] => asdfasdfasdf
            [4] => asdfasdfasdf
        )

)

DATA: afadsf
DATA: ^&%*&(
RESULTS: -1

DATA:
RESULTS: -1

Array
(
    [1] => Array
        (
            [0] => ^&%*&(
            [1] => ^*&()
            [2] => ^*&()
            [3] => ^*&()_
            [4] => ^%&*()
        )

    [0] => Array
        (
            [0] => afadsf
            [1] => adsfasfasdf
            [2] => asdfasdfasdf
            [3] => asdfasdfasdf
            [4] => asdfasdfasdf
        )

)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux