When I wrote the code I was using wamp for development. Everything worked fine there. I uploaded it to my server and it broke. If I copy and paste the query that is created into phpMyAdmin it works. I'm at a loss.
Here is the code that generates the query:
$query = "SELECT * FROM `" . $databaseName . "`.`changes` ORDER BY `entityID`;";
Here is the error:
A fatal MySQL error occured.
Query: SELECT * FROM `styles2_systemscans`.`changes` ORDER BY `entityID`;
Error: (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 '' at line 1