i've had the same problem, and i resolved with this simple function:
function execute_sql_script($filename)
{
$fd = fopen($filename, "r");
$query = "";
while(!feof ( $fd ))
{
$line = fgets($fd, 4096);
if ( strstr($line, ";") != false )
{
$query .= substr($line, 0, strpos($line, ";"));
mysql_query($query);
if ( mysql_errno() )
echo "<font color=\"red\">Error executing query</font><br><pre>$query</pre><br>".mysql_errno().": ".mysql_error()."<br>\n";
$query = "";
} else
$query .= $line;
}
}
The problem is if there's multiple query on a single line.