SQL Query returns no results (but it's there!) |
[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(); 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
[eluser]jbuk[/eluser]
Hi, it's the same as below (which works in Phpmyadmin) Code: SELECT * FROM listings WHERE from_email = '[email protected]' Thanks for the reply
[eluser]siptik[/eluser]
it's works fine for me: RESULT: 2SELECT * FROM my_files WHERE from_email = '[email protected]'
[eluser]siptik[/eluser]
Send me dump of database ("listings"). and your controller. I'll try to test it.
[eluser]jbuk[/eluser]
Hi Thanks, Code: CREATE TABLE `listings` ( Code: 1,[email protected],'testing' controller code Code: $query = $this->db->query("SELECT * FROM listings WHERE from_email = '[email protected]'
[eluser]siptik[/eluser]
it's strangely! Your code works fine for me! Code: echo $this->db->query("SELECT * FROM listings WHERE from_email = '[email protected]'")->num_rows(); 2 SELECT * FROM listings WHERE from_email = '[email protected]' I have two rows in database where from_email = '[email protected]' |
Welcome Guest, Not a member yet? Register Sign In |