tags:

views:

61

answers:

1

I have a file called script.sql

how can I run that file using q mysql query?

global $sql;
$res = $sql->query("\. /script.sql")or die(mysql_error());

gives:

#1064 - 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 '\. /script.sql' at line 1
A: 

Read the file in, parse it into individual SQL statements, then execute them.

Ignacio Vazquez-Abrams
that sounds tricky!!
vick
Not very useful.
T.J. Crowder
@vick: It is. There are routines out there for parsing SQL, but I've not yet seen one for PHP.
Ignacio Vazquez-Abrams