Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Error: mysql_num_rows() expects parameter 1 to be resource, object given

  • $check_program = DB::select('program_description')->from('programs')- >where('program_description','=', $program->program_description)->as_object()->execute();

    if(mysql_num_rows($check_program) > 0){
    Session::set_flash('error', e('Program description already exists .'));
    }else{
        var_dump($check_program);die();
    }

    I want to check if $check_program is not empty 

  • Ok I found the answer 
    I just change:
     
    If(mysql_num_rows($check_program) > 0)
    to
          if (count($check_program) > 0)
    :)
  • HarroHarro
    Accepted Answer
    You can't and shouldn't use mysql functions, DB returns a database result object. It has a method count(), so you can do

    if ($check_program->count() > 0)
    {
        ....
    }

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion