Just wondering if its possible to do a "find and replace" on the content pulled in from a php include...??

I'm including some pages into my site (from an affiliate) but would like to change a bit of the code...

Cheers.

Twey

11-01-2005, 04:57 PM

You need to use an output buffer.

<?php
ob_start();
include("http://www.affiliate.com/page.php");
$inc = ob_get_contents();
ob_end_clean();
?>
You can then use str_replace() and friends on $inc, which is a string containing the page, before echoing it.

nikomou

11-01-2005, 08:00 PM

use str_replace() and friends on $inc, which is a string containing the page, before echoing it.

(in the body)
if (isset($_COOKIE["tracking"]))
include ("http://www.affiliatewebsite.com/?tracking=" . $_COOKIE["tracking"]);

Twey

11-02-2005, 07:44 PM

setcookie("tracking", $tracking, time()+31536000);
$tracking = $_GET['tracking'];You've used $tracking before declaring it. The second argument to setcookie() will always be blank, and will throw a warning with E_STRICT error reporting.

if i use ?tracking=adwords after the url, a cookie is made, and everything works, but if i refresh the page, removing the ?tracking=adwords, the cookie gets deleted!

How can I stop this from happening??

The include also doesnt show if there is no "?tracking=xxxx" after the url

Twey

11-02-2005, 08:31 PM

The include doesn't show because the cookie doesn't get set. The cookie doesn't get set because you set a blank cookie if $_GET['tracking'] isn't set. Just use an if(isset($_GET['tracking'])) before the setcookie() call.