There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen boot computer connection crash css dell drive driver drivers email error ethernet excel explorer firefox firefox 3 hard drive internet internet explorer itunes laptop linux malware monitor network networking outlook outlook 2003 outlook express password printer problem problems ram router security slow software sound sprtcmd.exe trojan usb virus vista windows windows xp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Solved: Problems using CURL


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
deepdiver01's Avatar
Senior Member with 729 posts.
 
Join Date: Dec 2004
Location: Cairns, Australia
Experience: Intermediate
10-Jun-2007, 07:33 PM #1
Solved: Problems using CURL
Hi all.

I am trying to set up a TGP feed on an affiliate site that I am setting up.

I have used the following bit of code on the test server at home which works fine:
Code:
<? @readfile("http://www.theirdomain.com/?account=xxxxxx&optr=2&def=su&tour=best
&sites=2716|1&lang=us&revm=ppsst&tgpst=thmb&gtype=p_m&sort=last&nc=1&nr=1&t=_blank&cs=4&cttxt=0
&tsize=88x88&codemode=php") ?>
However, when I upload the code to the host account, it does not work. On contacting my host, I was advised that the statement will have to be wraped in CURL.

Looking through a couple of tutorials, I have tried using
Code:
<?
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, http://www.theirdomain.com/?account=xxxxxx&optr=2&def=su&tour=best
&sites=2716|1&lang=us&revm=ppsst&tgpst=thmb&gtype=p_m&sort=last&nc=1&nr=1&t=_blank&cs=4&cttxt=0
&tsize=88x88&codemode=php');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec();
curl_close($ch);
?>
PS. I added the line breaks in the url's so it will not run off the page.

This is returning an error stating curl_exec() is not valid.

Can someone help me with this bit of code,or point me to a tutorial that will help me understand CURL better.

Just one other thing. It appears from what I have read that the CURL statement must be used everytime that the url changes. Is there any way that a CURL statement can be used to include a number of different url's.

Thanks all.

Deep.
__________________
Six mumfs ago I coodnt spel injineer. Now I are wun.

Domain Names, Web Hosting
Free Online Games | Free Flash Games
Australian Domain Names
Motor Finance Wizard Information Base
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
10-Jun-2007, 07:38 PM #2
You're missing a ' at the beginning of the URL, and curl_exec() takes a parameter ($ch in your case.)
deepdiver01's Avatar
Senior Member with 729 posts.
 
Join Date: Dec 2004
Location: Cairns, Australia
Experience: Intermediate
10-Jun-2007, 08:39 PM #3
Thanks for the quick reply Brendon.

The missing ' is in the code on the page. I missed it when pasting. My bad.

So, as the code stands, it still does not work. Still getting the error.

I haven't given the variable $data anything to do. All I am trying to run is what you see here.

What am I missing.

Sorry for the silly questions. This is my first try at CURL.
__________________
Six mumfs ago I coodnt spel injineer. Now I are wun.

Domain Names, Web Hosting
Free Online Games | Free Flash Games
Australian Domain Names
Motor Finance Wizard Information Base
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
10-Jun-2007, 11:22 PM #4
Did you add the parameter $ch to curl_exec()?
deepdiver01's Avatar
Senior Member with 729 posts.
 
Join Date: Dec 2004
Location: Cairns, Australia
Experience: Intermediate
10-Jun-2007, 11:43 PM #5
I think so.

Now have $data = curl_exec($ch);

Hope that's right. I no longer get the error. It just doesn't do anything. Will try it on the live site.
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
11-Jun-2007, 07:49 AM #6
Sounds like it's probably working. You have to do echo $data; if you want it to display the results.
deepdiver01's Avatar
Senior Member with 729 posts.
 
Join Date: Dec 2004
Location: Cairns, Australia
Experience: Intermediate
11-Jun-2007, 07:05 PM #7
Thanks Brendon.

That's perfect. Should have known to echo $data. Brain not in gear.

What I did change was to delete
Code:
curl_setopt($ch, CURLOPT_HEADER, 1);
as it was returning the sending servers' details. All else aok.

Thanks again.

Deep.
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
11-Jun-2007, 09:20 PM #8
yourewelcome
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 07:30 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.