cómo escapar de la cadena antes de usarla en la consulta

how to escape this string

$sql = 'LOAD DATA LOCAL INFILE "C:\\xampp\\htdocs\\test\\import-excel\\book1.csv\\" INTO TABLE exam FIELDS TERMINATED BY  "," ';

because path to file will be a variable i don't know how to escape the path before use it in query , i used phpmyadmin ( create php code ) and it's gave me escaped string so i can use that , i hope someone can tell me about what function phpmyadmin use to generate this string from orginal string

$sql = "\'LOAD DATA LOCAL INFILE \"C:\\\\xampp\\\\htdocs\\\\test\\\\import-excel\\\\book1.csv\\\\\" INTO TABLE exam FIELDS TERMINATED BY \",\" \';";

tanques

preguntado el 08 de enero de 11 a las 17:01

What string? The one that starts with $sql? The one that starts with LOAD DATA? Or the one that starts with C:\\xampp? -

1 Respuestas

Respondido el 08 de enero de 11 a las 20:01

i have use it already but it's gave me this error : LOAD DATA LOCAL INFILE \"C:\\xampp\\htdocs\\test\\import-excel\\book1.csv\\\" INTO TABLE exam FIELDS TERMINATED BY \",\" Errormessage: 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 '\"C:\\xampp\\htdocs\\test\\import-excel\\book1.csv\\\" INTO TABLE exam FIELDS TE' at line 1 - Mehdi

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.