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,456
    Thanks
    8
    Thanked 1,084 Times in 1,075 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,281
    Thanks
    57
    Thanked 523 Times in 510 Posts
    Blog Entries
    5
    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.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

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