how read data from file and execute to MYSQL?
        Posted  
        
            by Mahran Elneel
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Mahran Elneel
        
        
        
        Published on 2010-03-07T16:52:42Z
        Indexed on 
            2010/06/11
            14:22 UTC
        
        
        Read the original article
        Hit count: 245
        
php
i create form to load sql file and used fopen function top open file and read this but when want to execute this data to database not work? what is wrong in my code?????????????
$ofile      =   trim(basename($_FILES['sqlfile']['name']));
$path = "sqlfiles/".$ofile;
//$data = settype($data,"string");
$file = "";
$connect = mysql_connect('localhost','root','');
$selectdb = mysql_select_db('files');
if(isset($_POST['submit']))
{
if(!move_uploaded_file($_FILES['sqlfile']['tmp_name'],"sqlfiles/".$ofile))
{
$path = "";
}
$file = fopen("sqlfiles/".$ofile,"r") or exit("error open file!");
while (!feof($file))
  {
    $data = fgetc($file);
    settype($data,"string");
    $rslt = mysql_query($data);
    print $data; 
  }
fclose($file);
}
        © Stack Overflow or respective owner