Salve,
quando eseguo la query mi dice 'Insertion Failed:' (che è la mia stringa di errore) e null'altro,la funzione si trova in un altro file php e la richiamo da un altro.
L'errore si trova nella parte di 'else if(is_file($orig)==true){'

Codice PHP:
function createfol($path,$name,$orig){
    
$username=$_SESSION['user_nick'];
    
    
$path=trim($path);
    
    
$original_path=$path;
    
$frutto=$path;
    
$frutto=trim($frutto);
    
    if(
is_file($path)==true){
        
$pos =strripos($path'/');
        
$path=substr($path,0,$pos);        
    }
    
    
$pos =strripos($stringa'/');
    
$name=trim($name);
    
$check=str_replace('/','',$name);
    
$position=strpos($name,'+');
    
$check=str_replace(' ','',$name);
    
$check=trim($check);
    
    
$username=$_SESSION['user_nick'];
    
    if(
$check!='' && $position==false && trim($username)!=''){
        if(
$frutto!='tree'){
            
$checkfol=file_exists($path.'/'.$name);
            if(
$checkfol==false){    
                
$file fopen('pippo.txt'"a+");    
                
fwrite($file,'no 1');
                
fclose($file);

                
$structure $path.'/'.$name;    
    
                
mkdir($structure0761true);
        
                
$infofile=$path.'/'.$name.'/80299006de825f7a6bb189747d90bf19.txt';
                
$file fopen($infofile"a+");                
        
                
$message='Folder created: '.date("Y-m-d H:i:s");
                
fwrite($file,"\n".$message);
                
fclose($file);
                
chmod($infofile0700);                
                
                
pulisci($infofile);
                
$pathf=str_replace('tree/','',$path);
                
                
$original_path.='/'.$name;
                
$original_path=trim($original_path);
                
$sql_insert "INSERT into `folder`(`owner`,`folder_name`, `folder_level`, `folder_path`)VALUES ('$username','$name', '2', '$original_path')";
                
mysql_query($sql_insert,$link) or die("Insertion Failed:" mysql_error());
                    
            }
        }
        else{
            if(
is_dir($orig)==true){
            
$file fopen('pippo.txt'"a+");    
                
fwrite($file,'no 2,psth='.$original_path);
                
fclose($file);
                
                
$beta_path=$original_path.'/'.$username.'rdrtrdygbhjvbnapops';
                
$beta_path=trim($beta_path);
                
                
$sql_insert "INSERT into `folder`(`owner`,`folder_name`, `folder_level`, `folder_path`)VALUES ('$username','$name', '1', '$beta_path')";
                
mysql_query($sql_insert,$link) or die("Insertion Failed:" mysql_error());
                
$folder_id mysql_insert_id($link); 
                
                
$final_path=$original_path.'/'.$folder_id.'/'.$name;
                
mysql_query("UPDATE folder SET folder_path= '$final_path' WHERE idd = '$folder_id'");
                
                
$structure $path.'/'.$folder_id;            
                
mkdir($structure0761true);
                
$id=$_SESSION['user_id'];
                
$permfile='permfol/'.$id.'/'.$username.'.txt';
                
$file fopen($permfile"a+");
                
fwrite($file,"\n".$folder_id);
                
fclose($file);
                
                
/*Info File*/    
                
$infofile=$path.'/'.$folder_id.'/80299006de825f7a6bb189747d90bf19.txt';
                
$file fopen($infofile"a");    
                
$message="\n"."Folder created: ".date("Y-m-d H:i:s");
                
fwrite($file,$message);
                
fclose($file);
                
chmod($infofile0700);
                
                
/* File for share*/
                
$infoshare=$path.'/'.$folder_id.'/0bc734760437fc73d61871198467b094.txt';
                
$file fopen($infoshare"a+");                
            
                
fwrite($file,"\n".$username);
                
fclose($file);
                
chmod($infoshare0700);
                    
                
pulisci($infofile);
                
pulisci($permfile);
                
pulisci($infoshare);
                
                
deleteori($beta_path);
                return(
$structure);
                
                
            }
            else if(
is_file($orig)==true){
                
                
$beta_path='tree/'.$name.'rdrtrdygbhjvbnapops';
                
$beta_path=trim($beta_path);
                
$beta_path=str_replace('.','',$beta_path);
                
$beta_path='http://farebury.exofire.net/'.$beta_path;
                
                
                
$file fopen('pippo.txt'"a+");    
                
fwrite($file,'path='.$path."\nbeta path=".$beta_path."\nusername=".$username."\nname=".$name);
                
fclose($file);
                
                
$link mysql_connect(DB_HOSTDB_USERDB_PASS) or die("Couldn't make connection.");
                
$db mysql_select_db(DB_NAME$link) or die("Couldn't select database");
                
                
$sql_insert "INSERT into `folder`(owner,folder_name,folder_path,folder_level) VALUES ('$username','$name', '$beta_path', '1')";
                
mysql_query($sql_insert,$link) or die("Insertion Failed:" mysql_error($link));
                
$folder_id mysql_insert_id($link); 
                
                
$final_path=$original_path.'/'.$folder_id;
                
mysql_query("UPDATE folder SET folder_path= '$final_path' WHERE idd = '$folder_id'");
                
                
$structure $path.'/'.$folder_id;            
                
mkdir($structure0761true);
                
$id=$_SESSION['user_id'];
                
$permfile='permfol/'.$id.'/'.$username.'.txt';
                
$file fopen($permfile"a+");
                
fwrite($file,"\n".$folder_id);
                
fclose($file);
                
                
/*Info File*/    
                
$infofile=$path.'/'.$folder_id.'/80299006de825f7a6bb189747d90bf19.txt';
                
$file fopen($infofile"a");    
                
$message="\n"."Folder created: ".date("Y-m-d H:i:s");
                
fwrite($file,$message);
                
fclose($file);
                
chmod($infofile0700);
                
                
/* File for share*/
                
$infoshare=$path.'/'.$folder_id.'/0bc734760437fc73d61871198467b094.txt';
                
$file fopen($infoshare"a+");                
            
                
fwrite($file,"\n".$username);
                
fclose($file);
                
chmod($infoshare0700);
                    
                
pulisci($infofile);
                
pulisci($permfile);
                
pulisci($infoshare);
                
deleteori($beta_path);
                return(
$structure);
                
            }
        }
        
    }
    else
       echo
"There is an error inside the name,please retry'</script>";

Qualcuno mi puo aiutare?
Grazie