Ahh don't know whats wrong with this! Green Rep+

Discussion in 'PHP' started by prilep, Nov 16, 2007.

  1. #1
    Can anyone tell me what is wrong with this php code.

    <? if($locationimage == '') { echo 'images/client_area.jpg'; } else { echo $locationimage; } ?>
    PHP:
    - Prilep :D
     
    prilep, Nov 16, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Nothing... what happens when you run it? And is that the whole code? Where does $locationimage come from?
     
    nico_swd, Nov 16, 2007 IP
  3. prilep

    prilep Well-Known Member

    Messages:
    3,852
    Likes Received:
    228
    Best Answers:
    0
    Trophy Points:
    185
    #3
    It's not working. That code is suppose to echo that image images/client_area.jpg if there isn't one specified. But if there is it's suppose to put the image that is specified.

    $locationimage = 'images/cars.jpg

    - Prilep :D
     
    prilep, Nov 16, 2007 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    Yes, I get the logic. But the code itself is correct.

    Does your host support short tags? Replace <? with <?php and see if it works.
     
    nico_swd, Nov 16, 2007 IP
    prilep likes this.
  5. prilep

    prilep Well-Known Member

    Messages:
    3,852
    Likes Received:
    228
    Best Answers:
    0
    Trophy Points:
    185
    #5
    Oh! Im an idiot lol. I made it as a comment thats why it wasn't working. See the // lol.

    // $locationimage = 'cars.jpg';

    Thanks
    Green Rep added for the help.

    - Prilep :D
     
    prilep, Nov 16, 2007 IP
  6. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #6
    That's why posting your whole code usually helps...
     
    nico_swd, Nov 16, 2007 IP
  7. prilep

    prilep Well-Known Member

    Messages:
    3,852
    Likes Received:
    228
    Best Answers:
    0
    Trophy Points:
    185
    #7
    Yeah :(. O well thanks.

    - Prilep :D
     
    prilep, Nov 16, 2007 IP