New line in database query causes problems on Yahoo - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: New line in database query causes problems on Yahoo (/showthread.php?tid=14667) |
New line in database query causes problems on Yahoo - El Forum - 01-10-2009 [eluser]voidstar[/eluser] My CI 1.7.0 application runs great on my PC (PHP 5.2.6 and MySQL Server 5.0.67). When I moved it to my Yahoo Web site (PHP 4.3.11. MySQL Server 4.1.14), the following error is generated. [10-Jan-2009 22:25:45] PHP Fatal error: Call to a member function on a non-object in /CCC/system/database/DB_active_rec.php on line 1030 The problem is caused by new lines (\n) in the query string. This is the content of the $sql variable immediately after count_all_results() calls _compile_select() on line 1025 of DB_active_rec.php. SELECT COUNT(*) AS `numrows`\nFROM (`doggie`)\nWHERE `status` = 'Adopted'\nAND `adopt_date` BETWEEN '2008-01-01' AND '2008-12-31'\nORDER BY `adopt_date` desc When I run this query in Yahoo's phpmyadmin I get the following error message: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\nFROM (`doggie`)\nWHERE `status` = 'Adopted'\nAND `adopt_date` If I replace the newlines with a simple space, the query runs without error. I see that the new lines are inserted by _compile_select(), e.g. here on line 1470: if (count($this->ar_from) > 0) { $sql .= "\nFROM "; $sql .= $this->_from_tables($this->ar_from); } Given the goal of "compatibility with standard hosting accounts" (CI's front page) is this a bug, or is Yahoo not a standard hosting account? (I've had enough problems with Yahoo that the latter seems likely.) New line in database query causes problems on Yahoo - El Forum - 01-10-2009 [eluser]darkhouse[/eluser] I've got code igniter running on a few servers and never had that problem. I don't know if this counts as a CI bug, but I have also had nothing but problems with yahoo's hosting. I convinced a client to switch to a "regular" host because of the issues we had with their project due to yahoo's odd system. New line in database query causes problems on Yahoo - El Forum - 01-11-2009 [eluser]Pascal Kriete[/eluser] I don't if it's related to this particular issue, but your PHP version is just a tad too low. CI requires 4.3.2. I find it odd that Yahoo of all hosts are so far behind, given that they use PHP for their own backend. New line in database query causes problems on Yahoo - El Forum - 01-11-2009 [eluser]darkhouse[/eluser] I think 4.3.11 is newer than 4.3.2 New line in database query causes problems on Yahoo - El Forum - 01-11-2009 [eluser]Pascal Kriete[/eluser] D'oh! Shouldn't post before the morning coffee, thanks darkhouse. New line in database query causes problems on Yahoo - El Forum - 01-11-2009 [eluser]darkhouse[/eluser] Hehe, I hear ya. |