Link to home
Start Free TrialLog in
Avatar of mwheeler_fsd
mwheeler_fsd

asked on

How to remove back slashes when stripslashes() and str_replace() won't work

Hello All;

I'm throwing in the towel and hoping and expert can help me with this one.

I'm trying to post a rather simple XML schema, but am having problems with the following line:

    $xmlcontent  = '<?xml version="1.0"?>';

when $xmlcontent actually get's assigned, it becomes: <?xml version=\"1.0\"?>

The people on the other end are saying the reason the transaction is failing is because of the back slashes. I've tried stripslashes() and str_replace(), but am having no luck. My magic quotes are set to on, but I thought stripslashes would override this.

Under the gun on this one, any help is appreciated.

Thanks in advance,
Mike
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

>The people on the other end

how do you send the data to the other end?
Avatar of mwheeler_fsd
mwheeler_fsd

ASKER

   $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_HEADER, 1);

    curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);  
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

    curl_setopt($ch, CURLOPT_TIMEOUT, 20);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
     
    $result = curl_exec($ch);

Where $url is there URL and $payload is the encoded version of the contents of $xmlcontent.
ASKER CERTIFIED SOLUTION
Avatar of snoyes_jw
snoyes_jw
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Update - I just ran my transaction without encoding (even though encoding was specified) it prior to execution and it worked. I was a little curious why an escape character might cause the failure. Even so, I am still interested in knowing why I was unable to remove the slashes.

Many thanks,
Mike
If I turn them off, can I turn them back on? I have some queries that might blow-up if I don't?
Try setting magic quotes off while necessary:

set_magic_quotes_runtime(0);
// do your stuff
...
// after sending you can use:
set_magic_quotes_runtime(1);

to restore the previous situation...

I HATE magic quotes and never use it. I recommend you turning it off as well...
ini_set did the trick! Thanks to all....