Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';

Discussion in 'PHP' started by Rhys Davies, Mar 15, 2009.

  1. #1
    After adding some code I am getting this error

    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in (blah blah page) on line 50

    ====
    This is line 50
    ====

    document.write(unescape("%3Cscript src='"+document.location.protocol+"//s3.buysellads.com/1237918/1237918.js?v="+Date.parse(new Date())+"' type='text/javascript'%3E%3C/script%3E"));
     
    Rhys Davies, Mar 15, 2009 IP
  2. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #2
    Use of quotes seems fine to me.
    If it is enquoted within a php string for example i fit is within a double quoted string then each " in this string must be added a slash before that is \". And if it is within a single quoted string each sing quote within this string must (too) be added a backslash, that is \'.

    Examples :

    print "This is 'a' double \"quotes\" test";

    print 'This is "a" single \'quotes\' test';


    I hope it helps.
     
    Vooler, Mar 15, 2009 IP