Hey guys, im trying to open a sql file from my php file so users can install their software from a php script (setup.php).

Anyways, I am trying to open the sql file and insert the queries into a database.

I could just have 100 different queries for each insert create statement etc but that would be sloppy.

Anyways here is my attempt at this so far.

 $fp = file($root_dir."/data.sql"); 
  if(!$fp) 
  { 

   $error = "Could not open $root_dir/data.sql.<br> 
             Please ensure file is uploaded with correct permissions"; 
  } 
  else
 { 
  for($i=0; $i<999; $i++);
  {
  mysql_query($fp[$i]);
  echo mysql_error();
  }
}
  

The error i am getting is "Query was empty".

I am quite new to php. Does anyone know what is wrong with what i have done?

    Try using the fopen and fread instead of file....

      Write a Reply...