Output the $scriptname variable to see what it is being set to because obviously the if statements are never returning true. Using the below bit of code with yours will put the first menu item as the $scriptname variable just to make it a little easier to see on your page.
Also, you may want to check out your PHP error log. Something may be coming up in there.
/Applications/MAMP/logs/php_error.log
PHP:
<?php
$scriptname = basename(__FILE__);
echo '<li>', $scriptname, '</li>';
...
Also, you may want to check out your PHP error log. Something may be coming up in there.
/Applications/MAMP/logs/php_error.log