I am having a problem with syntax errors in the following variable:
$uploadQuery = "
LOAD DATA LOCAL INFILE '".$docRoot."/../../includes/dbUploads/".$fileToUpload."'
INTO TABLE `promotions`
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\r\n'
";
I know that it has something do do with the escaping of the ' characters in the LOAD DATA… line. But I am stumped when it comes to what exactly the problem is, or how to reword this query in the correct manner.
So, My question is this:
How do i reword the stated variable in the correct manner, as to have no syntax errors relating to it.
If anyone has any suggestions or input with this, it would be greatly appreciated.
Thank You!
Missing an escape character, this is the correct string:
Note the extra
\on the 5th line. It was treating the"as a string terminator. Also another problem (that doesn’t cause a syntax error) is on the 7th line, you need to escape the backslashes.P.S. the markup analyzer even picked it up 😛
Edit: you probably also need to change line 7 to
ESCAPED BY '\\\\'since this reduces toESCAPED BY '\\'after PHP parses it.