Problems with CURL - need a bit of help

software development

#1

I have been trying to run a script that pulls in some advertising links. Originally I was given a script to use that was like this:

<?php if($_SERVER['REQUEST_URI']=="/") { $page=$_SERVER['PHP_SELF']; } else { $page = $_SERVER['REQUEST_URI']; } $lnkvar = file_get_contents("http://links.cyl0n.com/outbound/multi_links.php?site=53&page=".$page); echo $lnkvar; ?>

But Dreamhost security stops that from working, so it’s been changed to this:

<?php if($_SERVER['REQUEST_URI']=="/") { $page=$_SERVER['PHP_SELF']; } else { $page = $_SERVER['REQUEST_URI']; } $site_url = 'http://links.cyl0n.com/outbound/multi_links.php?site=53&page=' . $page; $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, $site_url); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); ob_start(); curl_exec($ch); curl_close($ch); $file_contents = ob_get_contents(); ob_end_clean(); echo $file_contents; ?>

[based on advice given here: http://wiki.dreamhost.com/CURL]

The problem is it just isn’t working for me - it’s trying to pull in the file and partly works but errors:

Warning: eregi() [function.eregi]: REG_EMPTY in /usr/home/cyl0n/domains/cyl0n.com/public_html/links/outbound/multi_links.php on line 33
Yahoo Google Quality Virtual Servers

You can see it on this page: http://vwkombi.com/index.html

So, the question is:

Is the problem with the CURL script that I have on my page, or is there a problem with the page that I’m trying to pull in?

I think it’s the latter, but I’m unfamiliar with CURL, so I don’t want to go pointing the finger at them just yet :slight_smile:

Would appreciate any comments that enlighten me!


#2

The problem is with the multi_links.php page.

On a side note, I’m not sure why output buffering would be needed. The curl option returntransfer should be set to true, which returns the results as a string, meaning that there will be no output until it is echoed so there should be no reason to use the output buffer.


Read my blog. You know you want to…