Welcome Guest, Not a member yet? Register   Sign In
SQL Query returns no results (but it's there!)
#1

[eluser]jbuk[/eluser]
Hi all,

I'm lost on this one, and I'm sure it's something obvious...

I'm querying a table via CodeIgniter, and it doesn't return any results - but I've checked the output via $this->db->last_query() and run it within my SQL client directly -it returns the record.

Code:
echo $this->db->query("SELECT * FROM listings WHERE  from_email = '$email'")->num_rows();
echo $this->db->last_query();
Returns 0

In PHPMyADMIN
Code:
SELECT * FROM listings WHERE from_email = '[email protected]'

Returns the row

Could it potentially be encoding of the $email variable when CodeIgniter runs it? If I hard code the $email string in the code it works, I've tried wrapping it in utf_encode/utf_decode

I've not had any problems with any other queries in my application at all

Any help appreciated


Messages In This Thread
SQL Query returns no results (but it's there!) - by El Forum - 11-03-2012, 10:22 AM
SQL Query returns no results (but it's there!) - by El Forum - 11-03-2012, 11:01 AM
SQL Query returns no results (but it's there!) - by El Forum - 11-03-2012, 11:09 AM
SQL Query returns no results (but it's there!) - by El Forum - 11-03-2012, 11:29 AM
SQL Query returns no results (but it's there!) - by El Forum - 11-03-2012, 11:33 AM
SQL Query returns no results (but it's there!) - by El Forum - 11-03-2012, 11:51 AM
SQL Query returns no results (but it's there!) - by El Forum - 11-03-2012, 12:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB