PHP - post data ends when '&' is in data.
Posted
by Phil Jackson
on Stack Overflow
See other posts from Stack Overflow
or by Phil Jackson
Published on 2010-04-14T06:11:29Z
Indexed on
2010/04/14
6:12 UTC
Read the original article
Hit count: 441
Hi all, im posting data using jquery/ajax and PHP at the backend. Problem being, when I input something like 'Jack & Jill went up the hill' im only recieving 'Jack' when it gets to the backend.
I have thrown an error at the frontend before that data is sent which alerts 'Jack & Jill went up the hill'.
When I put die(print_r($_POST));
at the very top of my index page im only getting [key] => Jack
how can I be loosing the data?
I thought It may have been my filter;
<?php
function filter( $data ) {
$data = trim( htmlentities( strip_tags( mb_convert_encoding( $data, 'HTML-ENTITIES', "UTF-8") ) ) );
if ( get_magic_quotes_gpc() ) {
$data = stripslashes( $data );
}
//$data = mysql_real_escape_string( $data );
return $data;
}
echo "<xmp>" . filter("you & me") . "</xmp>";
?>
but that returns fine in the test above you & me
which is in place after I added die(print_r($_POST));
.
Can anyone think of how and why this is happening?
Any help much appreciated. Regards, Phil.
© Stack Overflow or respective owner