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 Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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>"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.