1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Get a value of variable

Discussion in 'PHP' started by ipunkbali, Jun 11, 2015.

  1. #1
    How do i get the value of $image['link'] and insert it into the meta property <INSERT IMAGE LINK HERE> in the head tag??

    i tried <meta property="og:image" content="<?php echo $image['link']; ?> />" /> but gave me error. thanks
     
    ipunkbali, Jun 11, 2015 IP
  2. pentaxial

    pentaxial Active Member

    Messages:
    101
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    78
    #2
    Hi, Your code looks fine, Just make sure, your data on 'echo $image['link'];' should not have double Quote ' " ', use
    <meta property="og:image" content="<?php echo addslashes($image['link']); ?> /> and try it and let me know if any issues
     
    pentaxial, Jun 11, 2015 IP
  3. ipunkbali

    ipunkbali Well-Known Member

    Messages:
    276
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    123
    #3
    Its not working. But when i put it inside the bodytag, the image link shows up, and when i put it in the head, its just empty. no error.

    All php codes are below the metatag
     
    ipunkbali, Jun 11, 2015 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    That's because the $image['link'] doesn't exist when you try to use it. If you need to include it in the meta-tag, you need to move the php code above the meta-tag you're including it in. That should be fairly obvious...
     
    PoPSiCLe, Jun 11, 2015 IP
  5. pmf123

    pmf123 Notable Member

    Messages:
    1,447
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    215
    #5
    is this file a .php file or a .html?

    like PoPSiCLe said, you need PHP code above this to setup that array (load from mysql or whatever)
     
    pmf123, Jul 2, 2015 IP