phpmagic-quotes

php special characters problem


I am having a problem with the special characters in my script:

This is what I have so far:

$curlstrip = explode("&", $data);
$filename = substr(htmlEntities($curlstrip[5]), 2);

and if $data contains any special charaters like ' which is ', then instead of getting the chunk of string that I need, I get only the first part. A more detailed example:

$data = "12er&sdsretdgsd&file=Chris ' 19 &blabla"

the script will read the ' after Chris as ' and $curlstrip[5] will have a different value.

Hope is clear enough.

LE. Following this example:

$data = "12er&sdsretdgsd&file=Chris ' 19 &blabla"
$curlstrip = explode("&", $data);
$curlstrip[0] = '12er';
$curlstrip[1] = 'sdsretdgsd';

but

$curlstrip[2] = 'file=Chris' instead of 'file=Chris ' 19'

and that is because the ' is being read as

'

Thx,

Cristian.


Solution

  • Try:

    $curlstrip = explode("&", html_entity_decode($data));
    $filename = substr(htmlEntities($curlstrip[5]), 2);
    

    As I cant replicate your error given the code supplied, I have a hunch- try:

    $data=str_replace("'","'", $data);
    $curlstrip = explode("&", html_entity_decode($data));
    $filename = substr(htmlEntities($curlstrip[5]), 2);
    

    If, for whatever reason, you have && (two ampersands) occurring in $data next to one another, it will interfere with the explode function.