Bricktop Posted September 9, 2009 Share Posted September 9, 2009 Hi all, I have s cript which reads in an SQL file and then restores it to the database. It works like: $filename = 'test.sql'; mysql_connect, select blah blah $lines = file($filename); foreach($lines as $line) { do restore here } However, my $filename variable will be things like "backups/bigdatabase/backup.sql" or backups/someotherdb/backup.sql". I have no problem passing the filename variable to the above function but the file() function only seems to open filenames, not filenames containing the oflder structure. What can I do to pass a full path to the file() function? Thanks Link to comment https://forums.phpfreaks.com/topic/173655-solved-using-file-on-a-file-within-a-folder/ Share on other sites More sharing options...
Bricktop Posted September 9, 2009 Author Share Posted September 9, 2009 Edit. Link to comment https://forums.phpfreaks.com/topic/173655-solved-using-file-on-a-file-within-a-folder/#findComment-915394 Share on other sites More sharing options...
TeNDoLLA Posted September 9, 2009 Share Posted September 9, 2009 You can get the file's dir with pathinfo() or give full path for the $file variable. $i = pathinfo($file); print_r($i); // OR $file = 'full/path/to/file.sql'; Link to comment https://forums.phpfreaks.com/topic/173655-solved-using-file-on-a-file-within-a-folder/#findComment-915401 Share on other sites More sharing options...
Bricktop Posted September 9, 2009 Author Share Posted September 9, 2009 Thanks TeNDoLLA Link to comment https://forums.phpfreaks.com/topic/173655-solved-using-file-on-a-file-within-a-folder/#findComment-915411 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.