0

I am trying to query the mysql DB and if there is a picture for the record I would like to have that image displayed. If there is no picture associated with the record then there should be no image displayed and no broken image link showing on the page.

    if ($data['picture'] > 0)
    {
    echo "<td><img style='float: left; padding: 2px 7px 2px 0px;' src='../images/pictures/' .'"$data['picture']"'. .'"$data['message']"'. .'</td>
                          </tr>'";
    }
  else
    {
    echo ".'<td>'. .'"$data['message']"'. .'</td>
                          </tr>'";
                          }

I'm sure it's something pretty small that I'm missing but I cannot seem to find the problem.

Currently this page returns a 500 error when I try to view the page.

1
  • '500' errors get logged in the server's error_log - the basic 500 error page is intentionally sparse on details. Check the log and you'll get much more info as to what really went wrong. Commented Jan 24, 2011 at 21:23

3 Answers 3

1

I think you need to add some more code in order to determine what the 500 error is from. But I can tell you that you are including your array vars incorrectly in the html strings. The correct way to echo an array var in a string is:

echo "<td>html html".$phpCode['array']." html html</td>";
Sign up to request clarification or add additional context in comments.

Comments

0

I'd assume it would be something else, like a htaccess problem. Trouble in php usually doesn't turn into a http 500 server error.

Is all your .htacces code ok? What does your log say?

Comments

0

Your quotes and concatenation are all wrong.

echo ".'<td>'. .'"$data['message']"'. .'</td>
                          </tr>'";

Should be

echo '<td>'.$data['message'].'</td></tr>';

And

echo "<td>
      <img style='float: left; padding: 2px 7px 2px 0px;' src='../images/pictures/' 
      .'"$data['picture']"'. .'"$data['message']"'. .'</td>
                          </tr>'";

Should be:

echo "<td>
      <img style='float: left; padding: 2px 7px 2px 0px;' src='../images/pictures/'" 
      .$data['picture'].$data['message']."</td></tr>";

You also need to make sure you close your <img> tag.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.