php error, I have no idea but should be simple

Discussion in 'PHP' started by Swerd, May 22, 2009.

  1. #1
    Hey,

    Just wondering if somebody can show off some php skills for me.

    Im using <?php echo $mid; ?> on one of my pages and I get the page error: xxxxxx is undefined. (xxxxxx = whatever i set it as)

    At the very top of my page i have this in the code:
    <?php
    $gid = $_COOKIE['gid'];
    $yid = $_COOKIE['yid'];
    $mid = $_COOKIE['mid'];
    $sid = $_COOKIE['sid'];
    ?>

    It echos properly and the pages loads however I get that error on page message.

    Any ideas?

    Any suggestions would be great.

    Cheers,
    Swerd
     
    Swerd, May 22, 2009 IP
  2. krishmk

    krishmk Well-Known Member

    Messages:
    1,376
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    185
    #2
    What output do you see when you use the echo statement.
    I mean are you getting the expected value set by the cookie - thru the $_COOKIE array?
    Also check if you are using this code in the very first page where you are trying to set cookie.
    If it is so, you can read the cookie value only on the subsequent pages only.
     
    krishmk, May 22, 2009 IP
  3. bozghiyy

    bozghiyy Peon

    Messages:
    19
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I think you have somewhere a misspelling. I guess it is something like echo $$mid instead of $mid.
    If you show exactly the code will be easier
     
    bozghiyy, May 22, 2009 IP
  4. iyokz

    iyokz Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Perhaps your browser not supporting cookie ..
    just enable the cookie
     
    iyokz, May 22, 2009 IP
  5. Swerd

    Swerd Active Member

    Messages:
    1,657
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    90
    #5
    Hey,

    this is the full code:

    [CODE
    <SCRIPT>
    microsoft_adcenterconversion_domainid = <?php echo $mid; ?>;
    microsoft_adcenterconversion_cp = 5050;
    </script>
    <SCRIPT SRC="http://0.r.msn.com/scripts/microsoft_adcenterconversion.js"></SCRIPT>
    <NOSCRIPT><IMG width=1 height=1 SRC="http://<?php echo $mid; ?>.r.msn.com/?type=1&cp=1"/></NOSCRIPT>[/CODE]

    If i remove that code from the page it loads fine. But with it, I get the page error with the little yellow icon in the status bar.

    krishmk - yes, it displays what has been set as the cookie properly
    bozghiyy - no mispellings, though i wish it were something simple like that.
    cookies are enabled.

    Thanks for the help guys.
     
    Swerd, May 22, 2009 IP
  6. Swerd

    Swerd Active Member

    Messages:
    1,657
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    90
    #6
    hmm, just did a bit of playing around. it actually seems to be a problem with the conversion tracking code.. not with my echo's.

    I just took out the echos and put in text and the page still shows an error.
     
    Swerd, May 22, 2009 IP
  7. NatalicWolf

    NatalicWolf Peon

    Messages:
    262
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Message me...I'll be happy to help you via instant messenger.
     
    NatalicWolf, May 22, 2009 IP
  8. Swerd

    Swerd Active Member

    Messages:
    1,657
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    90
    #8
    Ok, I just added quotes around the echo like this:

    microsoft_adcenterconversion_domainid = "<?php echo $mid; ?>";

    This has fixed the page error. However my question now is:
    Will these quotes affect the tracking?
     
    Swerd, May 22, 2009 IP
  9. NatalicWolf

    NatalicWolf Peon

    Messages:
    262
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Shouldn't. All the quotes are going to do is define it as a string.
     
    NatalicWolf, May 22, 2009 IP
  10. Swerd

    Swerd Active Member

    Messages:
    1,657
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    90
    #10
    cool.. looks like the problem is solved then :)

    thanks again

    Swerd
     
    Swerd, May 22, 2009 IP