php - How do I INSERT the character "&" into a MySQL database? -
php - How do I INSERT the character "&" into a MySQL database? -
i think have seen question before don't think it's answered plenty yet because can't work.
the case: want insert url mysql database so:
$url = $_post["url"]; //$_post["url"] = "http://example.com/?foo=1&bar=2& ..."; $sql = mysql_query("insert table(url) values('$url')") or die ("error: " . mysql_error()); now, url inserted database when @ it, looks this:
http://example.com/?foo=1 it's url cutting right @ "&" character. have tried: mysql_real_escape_string, htmlspecialchars, escaping doing "\" etc. nil seems work.
i have read might able "sql plus" or that.
thanks in advance.
regards, vg
chances problem here nil database query, , more how url passed page. suspect you'll find url used load page like:
http://mydomain.com/?url=http://example.com/?foo=1&bar=2 this result in $_get looks this:
array ( 'url' => 'http://example.com/?foo=1', 'bar' => '2' ) what need phone call page url looks more this:
http://mydomain.com/?url=http://example.com/?foo=1%26bar=2 note & has been encoded %26. now $_get this:
array ( 'url' => 'http://example.com/?foo=1&bar=2' ) ...and query work expected.
edit i've noticed you're using $_post, same rules apply body of request , still think problem. if are, suspect, using javascript/ajax phone call page, need pass url string through encodeuricomponent().
php mysql insert special-characters
Comments
Post a Comment