1

I'm fairly new to PHP and I've been trying to construct some code to print basic HTML, however the code causes an error 500 whenever used. I am guessing it is a syntax error since I've tried the code in a couple of forms and nothing seems to work (including removing the database lookup and just trying to compare to set values to each other). The script needs to get a variable from the db, compare it to a set value and print the HTML if true, here is the code I am trying:

<?php
    $db = &JFactory::getDBO();
    $id = JRequest::getString('id');
    $db->setQuery('SELECT #__categories.title FROM #__content, #__categories WHERE #__content.catid = #__categories.id AND #__content.id = '.$id);
    $category = $db->loadResult(); ?>
  <?php if strcmp($category,"Blog")==0 : ?>

      <div style="display: -webkit-inline-box" class="sharelogos">
        <a href="http://www.facebook.com/sharer.php?u=<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>" target="_blank">  <img src="/images/sharing-icons/facebook.png" width="30px" alt="Facebook" /></a>
      </div>

<?php endif; ?>

Any help will be appreciated, thanks!

1 Answer 1

3

You if is incorrect, try like this

<?php if (strcmp($category,"Blog")==0) { ?>

      <div style="display: -webkit-inline-box" class="sharelogos">
        <a href="http://www.facebook.com/sharer.php?u=<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>" target="_blank">  <img src="/images/sharing-icons/facebook.png" width="30px" alt="Facebook" /></a>
      </div>

<?php } ?>
Sign up to request clarification or add additional context in comments.

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.