Javascript/Php quotes problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • WSM
    New Member
    • Dec 2007
    • 5

    #1

    Javascript/Php quotes problem

    Hi,
    My problem is about slashes and quotes. Im developing a Php game, where I have to generate some Javascript with PHP. The problem I'm currently facing is where the heck should the slashes be :P I have been experienting with this for some time, but without any effect.

    $clothing_optio ns value:
    Code:
    <input type=\"submit\" value=\"Take off\" onclick=\"player_image(\"user_image\",'.$item['id'].')\">'
    String I'm printing out
    Code:
    echo "<td><a href=\"#\" onClick='popout(this,\"Amount: ".$items[$a][1]."<br />$clothing_options\");return false;' onmouseout=\"exittoolarea(1250);\"><img src=\"images/things/$item[pilt]\" border=\"0\"></a></td>";
    The problem is, that the Take off button doens't work. The javascript (ajax) paar worked fine before I started to recode the window part...Now it gives me "syntax error on line 2", however neather the line 2 in the index.php/module.php or javascript file has anything to do with that.
    I know the code is messy and Im sorry for that (but it still is a result of hours of random experiments :P), but any hints what to do would be fine. Or is it even possible to call a function in a function like that?
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    How does this turn out in JavaScript/HTML? You can use double quotes within single quotes without escaping them and vice versa.

    Comment

    Working...