string issue with addslashes
<p>I have a loop that builds a table with camera names.  In that table is a button:</p>

<pre><code>&lt;button id="editbutton" onClick='edit(this, "&lt;?php echo addslashes($_SERVER['REQUEST_URI']); ?&gt;", "&lt;?php echo addslashes($result_cameras[$i]["camera_name"]); ?&gt;")'&gt;Edit&lt;/button&gt;
</code></pre>

<p>What I want to do is accept special characters such as single quote, double quote and backslash because I pass this to a javascript function that does some extra stuff:</p>

<pre><code>var edit = function(t, to, cameraname)
{

var mydiv = $("#editform");

if (mydiv.find("form").length) {
    mydiv.show();
} else {
    // fields
    var $myform = $("&lt;form id='EditCameraForm' name='' method='post' action='" + to + "'&gt;&lt;/form&gt;");
    var $myfieldset = $("&lt;fieldset&gt;&lt;legend&gt;Edit camera settings&lt;/legend&gt;&lt;/fieldset&gt;");
    var $mylabel = $("&lt;label for='CameraName'&gt;Camera name:&amp;nbsp;&lt;/label&gt;");
    var $myinput2 = js('&lt;input/&gt;').attr('size','25').attr('name','camera_name').attr('id','CameraName').val(cameraname);
...
}
</code></pre>

<p>My problem is <code>cameraname</code> is not escaping the special characters.  In another post I've been steered down the road of using <code>addslashes</code>.  Sounds good but I believe the problem is my string: <code>$result_cameras[$i]["camera_name"]</code>.  I can do a simple test:</p>

<pre><code>&lt;?php $str="a's camera";
$str=addslashes($str);
echo $str; 
?&gt;
</code></pre>

<p>This returns <code>a\'s camera</code> as expected.  But if I do:</p>

<pre><code>&lt;?php $str=$result_cameras[$i]["camera_name"];
$str=addslashes($str);
echo $str; 
?&gt;
</code></pre>

<p>This just returns <code>a's camera</code>.  I'm sure I'm missing something brain dead here, why is this not being treated as a string with addslashes?</p>

<p>Note: magic_quotes_gpc is off</p>
