Backend for songs.zachdecook.com
-php:reduce errors
Zach DeCook 2018-11-22
parent c26de1b · commit d034708
-rwxr-xr-xindex.php2
-rw-r--r--page.php8
2 files changed, 5 insertions, 5 deletions
diff --git a/index.php b/index.php
index 373b8ce..72b4bbf 100755
--- a/index.php
+++ b/index.php
@@ -4,7 +4,7 @@ if ( isset( $_GET['theme'] ) ){
$theme = $_GET['theme'];
setcookie( 'theme', $theme, time()+60*60*24*30 );
}
-if ($_POST['song'] && $_POST['name'])
+if (isset($_POST['song']) && isset($_POST['name']))
{
$song = str_replace( "'", "", $_POST['song'] );
$name = str_replace( "'", "", $_POST['name'] );
diff --git a/page.php b/page.php
index f890290..98fb3cf 100644
--- a/page.php
+++ b/page.php
@@ -82,9 +82,9 @@ function tocentry( $item ){
$class = 'incomplete';
}
$output = "<li class='$class'><a href=?song=$item[number]>$item[number]. $item[title]</a>";
- if ( $item['author'] ){ $output .= "($item[author])";}
- if ( $item['verse'] ){ $output .= "($item[verse])"; }
- if ( $item['key'] ){ $output .= "($item[key])"; }
+ if ( !empty($item['author']) ){ $output .= "($item[author])";}
+ if ( $item['verse'] ?? false ){ $output .= "($item[verse])"; }
+ if ( $item['key'] ?? false){ $output .= "($item[key])"; }
return $output;
}
@@ -269,7 +269,7 @@ function renderSS( $suggestedSong = array(), $songKeys, $transp )
$bs = array();// "bad" songs. Songs without transpositions.
//shuffle( $suggestedSong );
foreach ($suggestedSong as $songNum => $songarray) {
- $title = $songarray['title'] . ($songarray['author'] ? "($songarray[author])" : '');
+ $title = $songarray['title'] . (!empty($songarray['author']) ? "($songarray[author])" : '');
if( isset($songarray['key']) )
{
$ok = trim($songarray['key'], 'm');