Welcome Guest, Not a member yet? Register   Sign In
Spot my Query error
#1

[eluser]Kemik[/eluser]
Hello,

Here's my code:
Code:
$query = "SELECT f.email, u.user_id
     FROM forgotten_password AS f
     LEFT JOIN users AS u ON f.email = u.email
     WHERE f.act_key = '$act_key'";
            
if ($query->num_rows() < 1) {
    show_error('Reset ID passed is not in the database');
}
            
$row = $query->row();
However I get "Call to a member function on a non-object" for the $query->num_rows().

Edit: Fixed - Add $query = $this->db->query($query); above the $query->num_rows() IF. I'm sure I did try that before but must have mistyped it.
#2

[eluser]coolfactor[/eluser]
You've composed a query string, but you haven't executed it to get back a query resultset.

Code:
$query = "SELECT f.email, u.user_id
     FROM forgotten_password AS f
     LEFT JOIN users AS u ON f.email = u.email
     WHERE f.act_key = '$act_key'";

$result = $this->db->query($query);    // <-- you need this or something like it.

if (!$result OR ($result->num_rows() < 1)) {
    show_error('Reset ID passed is not in the database');
}
#3

[eluser]coolfactor[/eluser]
Just a friendly note: Try to keep your development-focused questions in the "Code & Application Development" forum. The "CodeIgniter" forum should be used for discussions about CodeIgniter and its architecture.




Theme © iAndrew 2016 - Forum software by © MyBB