Link to home
Start Free TrialLog in
Avatar of justmelat
justmelat

asked on

How do I write this While statement in my php applicatin

Could someone show me how to write this while loop for my php application please?

Because of the current curl connection issue we are having, in the short term, I am just forcing curl to re-excute up to 4 times and that is working for right now.  We will address the real reason behind the connection issue later.

what I want to say is:
 while $curlValue is either 7 or curlValue is 0 or $socketValue is 111 and the $curlCounter is less 4
{
run this code
}

how do I correctly write this while state for php.  my first attempt is attached.
$curlValue = curl_errno($ch);
                         $socketValue = curl_error($ch);
                         $curlCounter = 0;
                           while($curlValue == 7 || $socketValue == 111 AND $curlCounter < 4 )

Open in new window

Avatar of Brad Brett
Brad Brett
Flag of United States of America image


$curlValue = curl_errno($ch);
                         $socketValue = curl_error($ch);
                         $curlCounter = 0;
                           while(($curlValue == 7 || $curlValue == 0 || $socketValue == 111) AND $curlCounter < 4)

Open in new window

Avatar of justmelat
justmelat

ASKER

HI Medo3337:

while(($curlValue == 7 || $curlValue == 0 || $socketValue == 111) AND $curlCounter < 4)
This doesn't work, I am getting a syntax error


now this seems to work:
(($curlValue == 7 || $socketValue == 111) AND $curlCounter < 4 )

but when I try to add || $curlValue ==0 it breaks

The code I posted should work perfectly without syntax error.

What is the full code that has syntax error?
If you're looking at curl_errno() and you find 7, nothing else matters and there is not any reason for a while() control structure.  It failed, full stop.
http://www.php.net/manual/en/function.curl-errno.php#103128

Maybe if you want to tell us at a little higher level what the objectives are, we can suggest a good design pattern for using CURL.
Hi Ray

This is just a stop gap remedy for right now so the clients can keep working.  There was a change to server environment that my app connects to, now I get sporadic curl 7 and 0 errors.  nothing is clear right now, I just have to get a quick fix in before the clients loose their minds or cause me to loose mine.  
If you can provide the code you are working in, we will be able to assist you better.
Agree with Medo3337 - we probably need to see the rest of the code.
while(($curlValue == 7 || $curlValue == 0 || $socketValue == 111) AND $curlCounter < 4)

is the syntax error you are getting on the while line or a different line?
try retyping the statement. maybe there was a typo.
ASKER CERTIFIED SOLUTION
Avatar of haloexpertsexchange
haloexpertsexchange
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That got it "haloexpertsexchange:"

thank you!!!