Mailinglisten-Archive |
Hi Liste, ich hab folgendes phänomen, wenn ich meine Datenbank vor dem Filezugriff aufrufe funktioniert es noch, nacher nicht mehr. Ich weiss nicht warum und hab auch keine Erklärung dafür. Weis jemand von euch vielleicht, warum ich danach keinen Datenbank-Zugriff mehr habe. Ist das ein Bug in php oder ein Fehler in der dir.php??? Danke schon im Voraus. Gruss Martin <?php include ("dir.php"); $TRUE=1; $FALSE=0; $oDir = new CDir(); $db_connection = mysql_connect("localhost", "root", ""); if ($db_connection == 1) { $db_connection = mysql_select_db("mmp"); } else { echo("FALSE"); } $result = mysql_query("SELECT * from mp3data"); $result_db[$x] = mysql_fetch_array($result); */ ab hier kein Datenbank Zugriff mehr $oDir->Read( "c:/eigenedateien/mp3/","()\$" , "true_", "true_", "false_", "c:/eigenedateien/mp3/", "(_vti_)|(vssver.scc)" ); */ Übeltäter */ $db_connection = mysql_connect("localhost", "root", ""); if ($db_connection == 1) { $db_connection = mysql_select_db("mmp"); } else { echo("FALSE"); } $result = mysql_query("SELECT * from mp3data"); $result_db[$x] = mysql_fetch_array($result); ?> <?php // // $Archive: /iPage/V1.1/include/dir.php $ // $Author: Hannesd $ // $Date: 28.11.00 14:12 $ // $Revision: 5 $ // // $History: dir.php $ // // ***************** Version 5 ***************** // User: Hannesd Date: 28.11.00 Time: 14:12 // Updated in $/iPage/V1.1/include // // Class for reading a directory structure. // aFiles contains multiple aFile entries // aFile: Path => relative path eg. ../xx/yy/ // File => filename eg. filename (without extension) // Extension => ext // IsDirectory => true/false // FullName => Path . File . "." . Extension // FileName => File . "." . Extension // Notes // Filenames with multiple Extensions: only the last extensions is saved as extensions // eg: aaa.bbb.ccc results in File=aaa.bbb and Extension=ccc // Filenames are stored in the same case as the are stored in the filesystem // sFilter is only applied to files. file://if ( !defined( "INCLUCDED_DIR" ) ) file://{ file://define( "INCLUCDED_DIR", TRUE ); Class CDir { var $aFiles; Function CDir() { $this->Init(); } Function Init() { unset( $this->aFiles ); $this->aFiles = array(); } // Read // sPath path eg. "../xx/yy/" (note the last "/") // sInclude regular expression for filtering path- and filenames // fRecursive true/false: go down the whole structure // fFiles result set will contain entries which are files // fDirectory result set will contain entries which are directories // sRoot Root-Path. Will be appended to the entries. // sExclude regular expression for filtering path- and filenames Function Read( $sPath, $sInclude = "", $fRecursive, $fFiles, $fDirectories, $sRoot = "", $sExclude = "" ) { $oHandle = opendir( $sPath ); while ( $sFilename = readdir( $oHandle ) ) { $fInsert = true_; if ( $sFilename == "." || $sFilename == ".." ) continue; $fIsDirectory = is_dir( $sPath . $sFilename ); if ( !$fFiles && !$fIsDirectory ) $fInsert = false_; if ( !$fDirectories && $fIsDirectory ) $fInsert = false_; if ( $fInsert && !$fIsDirectory && ( !empty( $sInclude ) || !empty( $sExclude ) ) ) { $sFullname = $sRoot; $sFullname .= $sFilename; if ( !empty( $sInclude ) ) if ( !ereg( $sInclude, $sFullname ) ) $fInsert = false_; if ( !empty( $sExclude ) ) if ( ereg( $sExclude, $sFullname ) ) $fInsert = false_; } if ( $fInsert ) { $i = strrpos( $sFilename, "." ) + 1; if ( substr( $sFilename, $i - 1, 1 ) == "." ) { $sFile = substr( $sFilename, 0, $i - 1 ); $sExtension = substr( $sFilename, $i ); } else { $sFile = $sFilename; $sExtension = ""; } $aFile = array ( "Path" => $sRoot, "File" => $sFile, "Extension" => $sExtension, "IsDirectory" => $fIsDirectory ); file://Insert current file into aFiles array $this->aFiles[] = $aFile; } file://Recursion? if ( $fRecursive && $fIsDirectory ) $this->Read( $sPath . $sFilename . "/", $sInclude, $fRecursive, $fFiles, $fDirectories, $sRoot . $sFilename . "/", $sExclude ); } closedir( $oHandle ); } Function Output() { reset( $this->aFiles ); while( list( $sKey, $aFile ) = each( $this->aFiles ) ) $this->OutputFile( $aFile ); } Function OutputFile( $aFile ) { printf( "Path: %s<br>\n", $this->GetPath( $aFile ) ); printf( "File: %s<br>\n", $this->GetFile( $aFile ) ); printf( "Extension: %s<br>\n", $this->GetExtension( $aFile ) ); printf( "IsDirectory: %s<br>\n", $this->GetIsDirectory( $aFile ) ? "true" : "false" ); printf( "IsFile: %s<br>\n", $this->GetIsFile( $aFile ) ? "true" : "false" ); printf( "FullName: %s<br>\n", $this->FullName( $aFile ) ); printf( "FileName: %s<br>\n", $this->FileName( $aFile ) ); printf( "DirectoryName: %s<br>\n", $this->DirectoryName( $aFile ) ); echo "<hr>\n"; } Function GetPath( $aFile ) { return( $aFile[ "Path" ] ); } Function GetFile( $aFile ) { return( $aFile[ "File" ] ); } Function GetExtension( $aFile ) { return( $aFile[ "Extension" ] ); } Function GetIsDirectory( $aFile ) { return( $aFile[ "IsDirectory" ] ); } Function GetIsFile( $aFile ) { return( !$this->GetIsDirectory( $aFile ) ); } Function FullName( $aFile ) { return( $this->GetPath( $aFile ) . $this->FileName( $aFile ) ); } Function FileName( $aFile ) { $sBuffer = $this->DirectoryName( $aFile ); if ( $this->GetIsDirectory( $aFile ) ) $sBuffer .= "/"; return( $sBuffer ); } // DirectoryName returns the same as FileName, but without a ending "/" for Directories. Function DirectoryName( $aFile ) { $sBuffer = $this->GetExtension( $aFile ); if ( !empty( $sBuffer ) ) $sBuffer = "." . $sBuffer; $sBuffer = $this->GetFile( $aFile ) . $sBuffer; return( $sBuffer ); } } file://} // if ( !INCLUCDED_DIR ) ?>
php::bar PHP Wiki - Listenarchive