Welcome Guest, Not a member yet? Register   Sign In
New line in database query causes problems on Yahoo
#1

[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.)


Messages In This Thread
New line in database query causes problems on Yahoo - by El Forum - 01-10-2009, 05:48 PM
New line in database query causes problems on Yahoo - by El Forum - 01-10-2009, 10:50 PM
New line in database query causes problems on Yahoo - by El Forum - 01-11-2009, 10:25 AM
New line in database query causes problems on Yahoo - by El Forum - 01-11-2009, 11:52 AM
New line in database query causes problems on Yahoo - by El Forum - 01-11-2009, 03:11 PM
New line in database query causes problems on Yahoo - by El Forum - 01-11-2009, 03:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB