Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Query result returns '500 Internal Server Error'
  • Hey,

    in my Model, I have the following query:

    $access = DB::query('SELECT * FROM `users` 
                         WHERE username = "'. $_REQUEST["username"] .'" 
                         AND password = "'. $_REQUEST["password"] .'" 
                         ORDER BY id 
                         LIMIT 1', 
                         DB::SELECT)->execute();

    And when I try to get some information from this query like so:

    echo $access["ip_last"]; or echo $access->ip_last;

    I get a 500 Internal Server Error....

    Does someone know how this is possible?

    I already tried "->as_object('stdClass')->execute()->as_array()" instead of "->execute()" as well but that didn't help me out....

    Thanks!
  • Check your logs for error messages in the application logs, and make sure you develop with Fuel in "development" environment so you can see error messages instead of the generic production errors.

    p,s.: your queries are VERY insecure, and can be abused using sql injection without any problem. Either use the query  builder from the DB class, or use the ORM, to access your database:

    $access = DB::select()
        ->from('users')
        ->where('username', '=', Input::post('username'))
        ->where('password', '=', Input::post('password'))
        ->order_by('id')
        ->limit(1)
        ->execute();


    Or better still, use the Auth package for authentication and authorisation.

Howdy, Stranger!

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

In this Discussion