PHP - Help With Reading Lines In A File
I have a text file that has a list of filenames that are in a queue to be played. I would like to create a script that will read each line (each song's file path) and then search my MYSQL database to display a nice list, instead of the file path. Any help would be great!
Here is the code for the MYSQL search: PHP Code:
|
I'm not sure what your question is, but you can just use fgets to read lines from a file handle.
Code:
$fh = fopen('playlist.txt', 'r'); Code:
while($row = mysql_fetch_assoc($result)) { |
Thanks, let me see what I can do with that. I'm trying to come up with a script to read a line and then search my mySQL database.
|
I get this error in my error_log file:
Code:
[client 68.73.129.207] PHP Parse error: parse error, unexpected $ in /var/www/html/shoutcast/request_queue2.php on line 43 PHP Code:
|
Nevermind, I commented out something I shouldn't have. This it great!
One last question and it should be done. File names in the queue look like this: Code:
/video3/MythMusic/Radio Queue/Toad the Wet Sprocket/Coil/Whatever I Fear.mp3 Code:
Radio Queue/Toad the Wet Sprocket/Coil/Whatever I Fear.mp3 |
You want to use:
strpos -- Find position of first occurrence of a string substr -- Return part of a string giving you something like: $newPath = substr($oldPath, strpos($oldPath, "Radio Queue")); |
That seems to do the trick for the file name, thanks!
My sql search doesn't seem to be returning anything now. I'm going to try a few things and see what I get. |
All times are GMT -5. The time now is 04:18 AM. |