Problems with inserting an image

Discussion in 'PHP' started by homemadejam, Jun 11, 2009.

  1. #1
    Hey everyone,

    I know this is a simple task, but I seem t be doing something wrong, and I cannot figure it out for the life of me. (I'm still quite new at PHP)



      <?php
      
        switch ($tag) {
         case 'Cubs':
          echo '<img src=\"../imgs/cubs.jpg\" /><br /><br />';
          break;
         case 'Scouts':
          echo '<img src=\"../imgs/scouts.jpg\" /><br /><br />';
          break;
         case 'Explorers':
          echo '<img src=\"../imgs/scouts.jpg\" /><br /><br />';
          break;
        }
        
      ?>
    PHP:

    For some reason, the images are not displaying. If I change the image tag for just a word... it will display. The images are definitely in that directory! I am right by putting a black-slash before the double quotations?

    Thank you in advice,
    Jam
     
    homemadejam, Jun 11, 2009 IP
  2. alfa_375

    alfa_375 Active Member

    Messages:
    445
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #2
    <?php
    switch ($tag) {
    case 'Cubs':
    echo "<img src='../imgs/cubs.jpg' /><br /><br />";
    break;
    case 'Scouts':
    echo "<img src='../imgs/scouts.jpg' /><br /><br />";
    break;
    case 'Explorers':
    echo "<img src='../imgs/scouts.jpg' /><br /><br />";
    break;
    }
    ?>
     
    alfa_375, Jun 11, 2009 IP
  3. technolojik

    technolojik Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    did you checked safe_mod? it must be off
     
    technolojik, Jun 11, 2009 IP
  4. technolojik

    technolojik Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    yes you don't need to back-slash

    change it to

    echo "<img src='../imgs/cubs.jpg'><br /><br />";
     
    technolojik, Jun 11, 2009 IP
  5. SHOwnsYou

    SHOwnsYou Peon

    Messages:
    209
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Or just remove the backslashes since you're starting the echo with the single quote '.
     
    SHOwnsYou, Jun 11, 2009 IP