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 02-26-2009, 01:19 PM CURL and Variabls
Average Talker

Posts: 15
Trades: 0
Hello everyone. I have a CURL statement below and for some reason my variable ($result1) does not want to work in my if statement that follows. I can get the variable($result1) to echo onto the page but for some reason I cannot get the if statement to work with $result1. Any ideas?
PHP Code:
$ch curl_init();
curl_setopt($chCURLOPT_HEADER0);
curl_setopt($chCURLOPT_URL"http://socket.somewebsite.com:8080/?UID=1234&REQUEST=INV&VIN=$myVin&INV_DATE=N&ONE_OWNER=Y");
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
$result1 curl_exec($ch);
curl_close($ch);
echo 
$result1;
if(
$result1 == 'Yes 1') {
        echo 
"<br />We have a Winner!";
        }
    if(
$result1 == 'Yes N') {
        echo 
"<br />Not a One Owner";
        } 
macbaby is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-26-2009, 02:26 PM Re: CURL and Variabls
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
What you can conclude is that the returned value doesn't match either.
If you are certain the word is in there, just use strpos or a regular expression match.
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 02-26-2009, 02:55 PM Re: CURL and Variabls
Average Talker

Posts: 15
Trades: 0
I am not sure I follow what you are saying. I have been able to get this far with it but for some reason I am still not able to capture the 'N' value on its own. When I view the source it appears as though there is a line break but when I try trim() it still does not work. So if I get a value of 'Yes' with a $oneOwner value of '1' my code works but if I get a value of 'Yes' with a $oneOwner value of 'N' my code does not work. Again I tried trim() to remove any ASCII characters but still does not appear to work.

PHP Code:
$rest substr($result103);
echo 
"This is the first result: ".$rest;

echo 
"<br />";

$oneOwner substr($result14);
$oneOwner rtrim($oneOwner);
echo 
"This is the second result: ".$oneOwner;

if(
$rest == 'Yes') {
    if(
$oneOwner == 'N') {
        echo 
"<br />Report has been run but not a 1 owner.";
            }
    if(
$oneOwner == '1') {
        echo 
"<br />One Owner";
            }
        }
    if(
$rest == 'No') {
        echo 
"<br />Report Not Run";
        } 
macbaby is offline
Reply With Quote
View Public Profile
 
Old 02-26-2009, 03:52 PM Re: CURL and Variabls
Average Talker

Posts: 15
Trades: 0
Thanks for the info. I was able to come up with a solution based off of what you gave me. All though I must say my CURL execution time is taking quite a while. Any ideas on how to speed this up or possible quicker solution(s) for sending data to a remote server and capturing the response back on my end.
macbaby is offline
Reply With Quote
View Public Profile
 
Old 02-26-2009, 05:18 PM Re: CURL and Variabls
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
It's taking long because of the server you're sending it too, I think.
cURL is quick enough that there aren't any improvements you could make.
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 02-26-2009, 05:39 PM Re: CURL and Variabls
Average Talker

Posts: 15
Trades: 0
I wish that were the case. If you type the URL directly in the browser the time it takes for the remote server to execute a response is less than 1 second. So somehow or somewhere this is bottlenecking and I can't quite figure it out.
macbaby is offline
Reply With Quote
View Public Profile
 
Old 02-27-2009, 08:11 AM Re: CURL and Variabls
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
Hmm.
Maybe you should put in some timers in your script at certain places?

Like before and after the curl exec.
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>

Last edited by Insensus; 02-27-2009 at 08:12 AM..
Insensus is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to CURL and Variabls
 

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.79917 seconds with 12 queries