Question: PHP Programming - Please help me fix the following code. The objective is to: Create a Song Organizer script that stores songs in a text
PHP Programming - Please help me fix the following code. The objective is to:
Create a Song Organizer script that stores songs in a text file. Include functionality that allows users to view the song list and prevents the same song name from being entered twice. Also, include code that sorts the songs by name, deletes duplicate entries, and randomizes the song list with the shuffle() function.
I am getting error on line 58 and lines 91 through 101. Please help me salvage the same code rather than writing new or different code as this a text book exercise. Please add comments in the code if you can.
Song Organizer
0) { $NewSongs = implode($SongArray); $SongStore = fopen( "SongOrganizer/songs.txt", "wb"); if ($SongStore === false) echo "There was an error updating the song file "; else { fwrite($SongStore, $NewSongs); fclose($SongStore); } } else unlink("SongOrganizer/songs.txt"); if (isset($_POST['submit'])) { $SongToAdd = stripslashes( $_POST['SongName']) . " "; $ExistingSongs = array(); if (file_exists("SongOrganizer/songs.txt") && filesize("SongOrganizer/songs.txt") > 0) { $ExistingSongs = file( "SongOrganizer/songs.txt"); else { $SongFile = fopen( "SongOrganizer/songs.txt", "ab"); if ($SongFile === false) echo "There was an error saving your message! "; else { fwrite($SongFile, $SongToAdd); fclose($SongFile); echo "Your song has been added to the list. "; } } } } } if ((!file_exists("SongOrganizer/songs.txt")) || (filesize("SongOrganizer/songs.txt") == 0)) echo "There are no songs in the list.
"; else { $SongArray = file( "SongOrganizer/songs.txt"); echo "| " . htmlentities($Song) . " | "; echo "
Sort Song List
Remove Duplicate Songs
Randomize Song list
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
