-1

I am trying to save a array of tables into separate file. Why doesn't this code work?

<?php
$query = "SELECT * INTO OUTFILE 'pessoa_Out.txt' FIELDS TERMINATED BY ',' ENCLOSED BY '\"'       LINES TERMINATED BY '#' FROM $tables[$i]";
?>

I have already tried to save a single table and I was successful. I can also list the array values, so the problem must be on this line.

4

1 に答える 1

0

If the sql is in a loop then you are overwriting the file each time. Also placing variables inside string is not advisable as arrays don't evaluate unless you use curly brackets too!

<?php
for($i=0;$i<sizeof($tables);$i++)
{
    $query = "SELECT * INTO OUTFILE '".$tables[$i]."_Out.txt' FIELDS TERMINATED BY ',' ENCLOSED BY '\"'       LINES TERMINATED BY '#' FROM ".$tables[$i];
    mysqli_query($query);
}
?>
于 2013-03-25T12:34:00.680 に答える