Jump to content

Problem with showing specific details.


aktell

Recommended Posts

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

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.

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

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>";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.