I have a problem in a payment solution I have made. In this, I use ereg to extract a returned Transaction ID from the payment provider, and with PHP 5.3 this does not work anymore. The code used was:

ereg('<TransactionId>(.+)</TransactionId>',$resultat_3,$c);

I have tried to use this instead: (but it doesn't work)

preg_match("/<TransactionId>(.+)<\/TransactionId>/",$resultat_3,$c);

Does anybody have an idea what to do?

Recommended Answers

All 5 Replies

Member Avatar for diafol

Hmm, the pattern seems to work for me.

"fsbefrb<TransactionId>Help me</TransactionId>s;bmfefb" gave 'Help me' with the pattern you supplied.

OK, thanks. So, something else must be wrong, then. Do you see anything wrong with the rest of my code for making the registry call and extracting the answer as $transactionid?:

        $ch = curl_init ();         
        $payment_url = "https://MyPaymentProvider.com";
        curl_setopt( $ch , CURLOPT_SSL_VERIFYPEER , false );
        curl_setopt( $ch , CURLOPT_SSL_VERIFYHOST , false );
        curl_setopt( $ch, CURLOPT_URL, $payment_url);
        curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);

        $resultat_3 = curl_exec ($ch);
        curl_close($ch);

        preg_match('/<TransactionId>(.+)<\/TransactionId>/',$resultat_3,$c);

        $transactionid=$c[1];
Member Avatar for diafol
echo htmlentities($resultat_3);

Do that and then search for '<TransactionId>' with the browser's search-in-page. You won't find it. The page looked like normal html to me as opposed to xml.

So, it's the registry call at my payment provider that has stopped working then?

echo htmlentities($resultat_3);

Member Avatar for diafol

Your call.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.