There's no of course there at all. Quotes only matter in PHP source code--echo absolutely does not look inside the contents of a variable and do something special with quotes, so perhaps your problem is elsewhere (e.g. perhaps you do an eval() of the stored code, which does treat the contents of a variable as if it were code.
Maybe you could post a condensed-down version of the minimal code that causes the problem? And btw, quotes are never a problem in retrieving data from mysql, only in storing it, so you should be able to recreate the problem scenario just by using variables in your example, e.g. just initialize the data into $problem instead of showing all the code to retrieve the data from your dbms:
$problem = "This is the \'example\'"; // or whatever
echo "This is what goes wrong: <br>";
echo $problem;