I would like to Insert some values into my table from a file. I do the following
$stmt=$db->prepare(INSERT INTO Info VALUES (NOW(), LOAD DATA INFILE "insert.txt"));
$stmt->execute();
I get the following error message: Parse Error syntax error unexpected T_STRING on line 6…
Both your PHP and your MySQL syntax have problems. First, your SQL statement needs to be surrounded by quotes. Secondly, the syntax for
LOAD DATA INFILEis incorrect. Try this:See the MySQL docs for
LOAD DATA INFILEfor more options. You’ll probably need to specify your field and line delimiters, for instance. If you need to set a column to the value of thenow()function, you can issue a separateupdatequery for that.