Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question unterminated string literal

    Hi all,
    I'm having trouble getting rid of this error ("unterminated string literal" in Firefox and "unterminated string constant" in IE).
    Here is the code responsible for the error:
    Code:
    $temp .= '<span id="'.$dir.'/" title="open" class="dir" onclick=\'browse(this.title, this.id);document.getElementById("'.$test.'/Info").innerHTML = "";\' />'.$dir.'</span>';
    The error occurs when the php variable $test has single quotes in it.
    I tried to use addslashes($test) but the error is still there.
    Can anyone help me out with this?
    Thanks.

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,778
    Thanks
    19
    Thanked 155 Times in 146 Posts
    Give that a shot:

    PHP Code:
    $temp .= "<span id='$dir/' title='open' class='dir' onclick='browse(this.title, this.id);document.getElementById(\"$test/Info\").innerHTML = \"\";' />$dir</span>"
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #3
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the reply.
    I see you tried to use double quotes instead. This solution seemed perfect, however I wasn't showing completely what my code was, in order to make it simple. Here is what it looks like:

    Code:
    $temp .= '<span id="'.$dir.'/" title="open" class="dir" onclick=\'browse(this.title, this.id);document.getElementById("'.$test.'/Info").innerHTML = "";\' />'.$this->hyphens($dir).'</span>';
    Well in fact I only changed $this->hyphens($dir).

    So I applied your solution, but it shows this error now: "Undefined property: myclass::$hyphens"

    I have no clue what's wrong.

  • #4
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,778
    Thanks
    19
    Thanked 155 Times in 146 Posts
    that's a weird error...Do you have a property and a method both named "hyphens"? Is the error for that exact line of code?

    and I'm just guessing here:

    PHP Code:
    $temp .= '<span id="'.$dir.'/" title="open" class="dir" onclick="browse(this.title, this.id);document.getElementById(\''.$test.'/Info\').innerHTML = \'\';" />'.$this->hyphens($dir).'</span>'
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #5
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You guessed right! I don't get it, I was sure I already tried your suggestion, but it's often confusing with all these quotes and escapes I guess.
    Cheers!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •