just use if statment to check the file:
if(!file_exists("location-with-file-name")){
echo "link for midi is not avalible";
}
just use if statment to check the file:
if(!file_exists("location-with-file-name")){
echo "link for midi is not avalible";
}
Originally posted by Mistah Roth
ok weedpacket that helps a lot... would there be a way to display "No Soundtrack Available" if there isnt a music file matching the page.php? so it checks and decides if there is one or not first.
Yep; that's built into my code. If the page is found in the list, you'd have the code embed the HTML for linking to the MIDI. If the page isn't found, PHP will do whatever is specifed in the else{Do something else instead} block; that's where you'd put the HTML for your "No Soundtrack Available" notice.
ok so I made a file called music.php and stuck this code into it:
<?php
$soundtracks = array(
'shop.php' => 'shop.mid',
'chocobo.php' => 'chocobo.mid',
'intro.php' => 'welcome.mid',
);
if(isset($soundtracks[$_SERVER['PHP_SELF']])){
$soundtrack = $soundtracks[$_SERVER['PHP_SELF']];
}
else{
echo "No Soundtrack Available";
}
?>
and then I have a MIDI called welcome.mid and I made a file called intro.php with this code at the bottom:
<?php include("music.php");?>
and it should work but it just says No Soundtrack Available
Originally posted by Weedpacket
Yep; that's built into my code. If the page is found in the list, you'd have the code embed the HTML for linking to the MIDI. If the page isn't found, PHP will do whatever is specifed in the else{Do something else instead} block; that's where you'd put the HTML for your "No Soundtrack Available" notice.
Ahh, logic!
Try this:
echo "$_SERVER[PHP_SELF]";
Quite likely, your array should be:
$soundtracks = array(
'/shop.php' => 'shop.mid',
'/chocobo.php' => 'chocobo.mid',
'/intro.php' => 'welcome.mid',
'cause PHP_SELF generally has a leading slash.....
Is that because $_SERVER[PHP_SELF] returns music.php? Maybe it shouldn't be included, or the
$soundtrack = $soundtracks[$_SERVER['PHP_SELF']];
shouldn't be included, rather put in each page that music.php is being included into.
Matt
Ok I figured out why it was saying "No Soundtrack Available", it was because it was located in the items folder of the main site, so I had to put /items/shop.php or whatever in the array, now that doesnt show up but no music actually plays.....
is it just me or is there no actual code that PLAYS the music... it just assigns it to the soundtrack variable and leaves it... (what is the PHP code for the playing part?)
Um, not aware of "MIDI functions" in the PHP manual....
Aren't we just talking HTML here, maybe <embed> or some such?
So, you'd have PHP echo "<embed>........." or whatever....
<embed src="XXX.XXX" console="smallconsole" loop="XXX | false(default)" volume="XX" autostart="false" height="60" width="145">
...so I had to put /items/shop.php or whatever in the array,...
Just checked the manual, yeah: absolute name. Or use basename($POST[$SERVER['PHP_SELF']]).
is it just me or is there no actual code that PLAYS the music... it just assigns it to the soundtrack variable and leaves it...
Well I didn't write any; didn't know what the HTML was to embed a MIDI file. Thought you did
alright thanks... I got it all working perfectly thanks for your help everyone
actually one more thing.... im trying to make the link thing so it takes whats ALREADY THERE + &music=yes
so if I click it from
index.php?nav=menu&main=news
it will goto
index.php?nav=menu&main=news&music=yes
what do I link to, to make that happen?