• PHP Help PHP Newbies
  • [RESOLVED] Warning: array_shift() [function.array-shift]: The argument should be an array

Hi can any body help with this error 🙂
here is the tutorial code im using 🙂

$result_array = self::find_by_sql($sql);
return !empty($result_array) ? array_shift($result_array) : false;

I can print out the sql query so i know its returning the correct row, The sql has LIMIT 1 to return the single row.

Heres the error

Warning: array_shift() [function.array-shift]: The argument should be an array

Thanks in advance

    as the error msg says $result_array is not an array.

    try var_dump($result_array); and see what it returns

      Hi thanks for your help
      it gives back
      resource(8, mysql result)
      i thought this was correct and array_shift would actually return the first row as usable.

        need to modify the method find_by_sql to return the actully result or use another method\function to do it.

          Write a Reply...