I am programatically generating a SQL statement that I then need to execute, however it is failing, I think due to not being escaped properly.
The SQL appears to be generated correctly in that I can cut and paste it from a browser and it executes correctly from the CMD line and PHPMyAdmin. Example:
CREATE TABLE IF NOT EXISTS `1_e6766037c49ccf8cc3f8437c123d6e88`
(`intId` int(11) NOT NULL auto_increment,
`twitter_retweet_count` TEXT NULL ,......
I then try to execute it using CI with:
$query = $this->db->query($sql);
However it fails with:
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 '
`twitter_retweet_count` TEXT NULL ,.......
Any thoughts on where I might be going wrong?
Many thanks, Ben.
@adidasadida- thanks for your efforts. Your testing made me look further at the generate code and I realised I had an HTML character in there for display purposes (new line). This was the cause of the failure. Many thanks, Ben.