Some good suggestions, but I have to explain more:
$if_empty_query = "SELECT count FROM song_count LIMIT 0,1";
This query works fine, the problem is in the for loop (I know this because the table indeed does get emptied).
With the dual for loop, here is an explaination:
The first loop grabs distinct artists, so that I have a list of all the artists (in the larger lyrics table, if a particular artist has 20 lyrics, then there are 20 rows, so I grab distinct artists to simply get a list).
I then grab all the songs from that particular artist, which is query 3, and count them.
Then I insert that artist, and the number of songs for that artist.
(And yes, $letter++ works).
It's tough to get any help on this because I get no specific error, it just says page not found.
And I want to emphesize that the last insertion query does indeed work, as after I run the script, I check the table, and some entries have been added, but here's the strange thing:
I can do a reload after every failure, and I get a different number of items that were inserted every single time.
It's not like the script is failing on one particular artist, it simply randomly decides to crap out.
I'm really at a loss as to why the script can't complete, and why it (or the server) seems to have a mind of it's own when it decides it wants to crap out.