aktell Posted February 9, 2007 Share Posted February 9, 2007 Hi there, A small problem I hope. I'm trying myself in different items out of books so I can learn more about Php and Mysql, and I came accross four different code snippets One is working and three have the same problem no correct readout. <? if ($artist_fn != "") { $artist_fullname = trim("$artist_fn $artist_ln"); //************ error is in here - else - ??? *************** $artist_fullname } else { $artist_fullname = trim("$artist_ln"); } //************************************************ if ($date_acq == "0000-00-00") { $date_acq = "[unknown]"; $display_block .= "<P><strong>$title</strong> on $rec_label, by $artist_fullname<br> $my_notes <em>(acquired:$date_acq, format:$format)</em></P>"; } ?> Thanks for any help aktell Link to comment https://forums.phpfreaks.com/topic/37720-problem-with-showing-specific-details/ Share on other sites More sharing options...
alpine Posted February 9, 2007 Share Posted February 9, 2007 Look at the colored part, the variable is just written outside any definition or echo and it misses the mandatory ; if ($artist_fn != "") { $artist_fullname = trim("$artist_fn $artist_ln"); //************ error is in here - else - ? *************** $artist_fullname; } else { $artist_fullname = trim("$artist_ln"); } //************************************************ Look at this <?php if ($artist_fn != "") { $artist_fullname = trim("$artist_fn $artist_ln"); } else { $artist_fullname = trim("$artist_ln"); } if ($date_acq == "0000-00-00") { $date_acq = "[unknown]"; $display_block .= "<P><strong>$title</strong> on $rec_label, by $artist_fullname<br> $my_notes <em>(acquired:$date_acq, format:$format)</em></P>"; } ?> FYI: I was only fixing your problem, not made any other improvements or changes. Link to comment https://forums.phpfreaks.com/topic/37720-problem-with-showing-specific-details/#findComment-180474 Share on other sites More sharing options...
artacus Posted February 9, 2007 Share Posted February 9, 2007 Well this is wrong: $artist_fullname } else { It doesn't make sense. Its not a complete statement. Just take out '$artist_fullname' and it should be ok. Link to comment https://forums.phpfreaks.com/topic/37720-problem-with-showing-specific-details/#findComment-180477 Share on other sites More sharing options...
aktell Posted February 9, 2007 Author Share Posted February 9, 2007 Well this is wrong: $artist_fullname } else { It doesn't make sense. Its not a complete statement. Just take out '$artist_fullname' and it should be ok. Thanks alot both ways worked. No error problem shown. But there is no print out either as yet, i will give it another try. Thanks again Link to comment https://forums.phpfreaks.com/topic/37720-problem-with-showing-specific-details/#findComment-180492 Share on other sites More sharing options...
artacus Posted February 9, 2007 Share Posted February 9, 2007 Well did you echo $display_block any where? And it looks like your } might be in the wrong place. See if this isn't what you want to do instead //old if ($date_acq == "0000-00-00") { $date_acq = "[unknown]"; $display_block .= "<P><strong>$title</strong> on $rec_label, by $artist_fullname<br> $my_notes <em>(acquired:$date_acq, format:$format)</em></P>"; } //new if ($date_acq == "0000-00-00") { $date_acq = "[unknown]"; } // otherwise display block only gets filled out if there is no date. $display_block .= "<P><strong>$title</strong> on $rec_label, by $artist_fullname<br> $my_notes <em>(acquired:$date_acq, format:$format)</em></P>"; Link to comment https://forums.phpfreaks.com/topic/37720-problem-with-showing-specific-details/#findComment-180766 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.