MySQL Database Php

// open the .sql file
$fp = @fopen("mysql.sql", "r");
$file = fread($fp, 80000);
fclose($fp);
$lines = explode(';', $file); // split the .sql into sepearte queries
$cnt = count($lines); // count array elements
// database connection string
mysql_connect("localhost","root");
// loop each query and execute
for($j=0; ($j<$cnt-1); $j ) {
if(!mysql_query($lines[$j])) {
// echo any errors
echo "Error on line $j of Query:
";
echo $lines[$j]."

";
die;
}
}
// show confirmation
echo "Done";
?>