Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 12-11-2008, 01:55 AM cURL Help
Skilled Talker

Posts: 64
Name: Ralph Freshour
Trades: 0
Here is a simple cURL test. Obviously this domain does not exist yet when I run this script it returns True - huh? I'm just trying to write a PHP script to determine if the URL connects or not.

PHP Code:
$ch curl_init(); 
curl_setopt($chCURLOPT_URL"http://sfhsfhshfjsdhf.com"); 
curl_setopt($chCURLOPT_POST0); 
curl_setopt($chCURLOPT_RETURNTRANSFER1); 
curl_setopt($chCURLOPT_TIMEOUT0); 
$status curl_exec($ch); 
curl_close($ch); 
if (
$status
   { 
     print 
"true"
   } 
else 
   { 
     print 
"false"
   } 
__________________
RalphF
Business Text Messaging Services

Please login or register to view this content. Registration is FREE
rfresh is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-11-2008, 02:23 AM Re: cURL Help
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
Because you set the CURLOPT_RETURNTRANSFER, curl_exec will return the data from the page you requested. I think you should get a false if you remove that line, or set it to 0 instead of 1.
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 12-11-2008, 12:02 PM Re: cURL Help
Skilled Talker

Posts: 64
Name: Ralph Freshour
Trades: 0
Nope...it always returns true...regardless of the URL...
__________________
RalphF
Business Text Messaging Services

Please login or register to view this content. Registration is FREE
rfresh is offline
Reply With Quote
View Public Profile
 
Old 12-11-2008, 12:43 PM Re: cURL Help
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
Hmm, that's kinda weird.
Try checking if your script throws an error that is hidden.
error_reporting(E_ALL)
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 12-11-2008, 02:05 PM Re: cURL Help
Skilled Talker

Posts: 64
Name: Ralph Freshour
Trades: 0
Always returns error 6135...
__________________
RalphF
Business Text Messaging Services

Please login or register to view this content. Registration is FREE
rfresh is offline
Reply With Quote
View Public Profile
 
Old 12-12-2008, 05:47 PM Re: cURL Help
Skilled Talker

Posts: 64
Name: Ralph Freshour
Trades: 0
This is the code that works:

PHP Code:
$ch curl_init();
curl_setopt($chCURLOPT_URL"http://mywebsite.com");
curl_setopt($chCURLOPT_POST0);
curl_setopt($chCURLOPT_RETURNTRANSFER1);
curl_setopt($chCURLOPT_TIMEOUT0);
$view curl_exec($ch);
if (
eregi("a string from my site home page"$view))
   {
     echo 
"ok";
   }
else
   {
     echo 
"fail";
   }
curl_close($ch); 
__________________
RalphF
Business Text Messaging Services

Please login or register to view this content. Registration is FREE
rfresh is offline
Reply With Quote
View Public Profile
 
Old 12-12-2008, 06:28 PM Re: cURL Help
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Is it that the domain you called for doesn't exist, or only the page? When you type that URL into your browser, do you get a parked page? Could it be something like that, or a 404 error you're seeing in code?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to cURL Help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.31964 seconds with 12 queries