1,105,450 Community Members

php quotes inside quotes

Member Avatar
hwoarang69
Posting Pro
572 posts since Feb 2012
Reputation Points: -4 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 9 [?]
 
0
 

getting a error at $item_id_g'. its bc of the quotes

<?php
    echo"
         <button type='submit' onmousedown='func('$item_id_g');'>test</button>
       ";
?>

i also tried this but didnt work

<?php
        echo"
             <button type='submit' onmousedown="func('$item_id_g');">test</button>
           ";
    ?>
Member Avatar
pritaeas
mod_pritaeas
11,318 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
0
 

getting a error

Which one? Technically it is correct PHP syntax (apart from the missing space between echo and the double quote perhaps), but not valid HTML/Javascript syntax.

Member Avatar
broj1
Posting Virtuoso
1,580 posts since Jan 2011
Reputation Points: 220 [?]
Q&As Helped to Solve: 219 [?]
Skill Endorsements: 21 [?]
Featured
 
0
 

Try it this way (escaping double quotes for javascript arguments):

<?php
echo"
<button type='submit' onmousedown='func(\"$item_id_g\");'>test</button>
";
?>

or this way (escaping double quotes for html attributes):

<?php
echo"
<button type=\"submit\" onmousedown=\"func('$item_id_g');\">test</button>
";
?>
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article