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 3 of 3

Thread: too many quotes

  1. #1
    New Coder
    Join Date
    Oct 2011
    Posts
    85
    Thanks
    13
    Thanked 1 Time in 1 Post

    too many quotes

    hey all, I don't know how to fix this

    Code:
    echo "<div id='trackNav' style='float:left;'><a href='../'>Home</a> > <a href='javascript: displayCategory(' ". $category ." ', ' ');'>" . $category . "</a> > <a href='javascript: displayCategory(' " . $subCategory . " ', ' ');'>" . $subCategory . "</a></div>";
    is there an escape key for this type of situation
    basically, the quotes are cancelling themselves out when I don't want them too. I know this doesn't really matter which language your using, but since I'm using php I'm posting it here. thanks for any help

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,549
    Thanks
    8
    Thanked 1,095 Times in 1,086 Posts
    See what happens if you do this ...

    echo "<div id='trackNav' style='float:left;'><a href='../'>Home</a> > <a href='javascript: displayCategory('$category', ' ');'>$category</a> > <a href='javascript: displayCategory('$subCategory', ' ');'>$subCategory</a></div>";

  • #3
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,479
    Thanks
    63
    Thanked 538 Times in 525 Posts
    Use \" for the quotes inside the string. That will escape them without screwing up your html quotes.

    Once printed to the page you will just see "

    The quotes link in my signature might help you out a bit more.
    I can't really think of anything to write here now...


  •  

    Posting Permissions

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