I found a piece of code like this:
<?php
class myClass {
function myFunc(&$par1) {
// [...]
$val2 = $par1->field1;
// [...]
$val3_escaped = mysql_real_escape_string($someVar2);
$cmdInsert = "insert into tab1(col1,col2,col3, col4) values(1,'$val2',\"$val3_escaped\",'val4')";
$result = mysql_query($cmdInsert, $myConnection);
}
}
?>
I'm wondering what is the difference between '$val2'
and \"$val3_escaped\"
? Are both valid?
I guess that should be correct only with single quote, but it seems to works fine only with \"
.
What's the right sintax?
Thanks.