• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

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

0
justmelat
Asked:
justmelat
  • 3
  • 3
  • 2
  • +2
1 Solution
 
Mohamed AbowardaSoftware EngineerCommented:

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

Open in new window

0
 
justmelatAuthor Commented:
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

0
 
Mohamed AbowardaSoftware EngineerCommented:
The code I posted should work perfectly without syntax error.

What is the full code that has syntax error?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Ray PaseurCommented:
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.
0
 
justmelatAuthor Commented:
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.  
0
 
Mohamed AbowardaSoftware EngineerCommented:
If you can provide the code you are working in, we will be able to assist you better.
0
 
Ray PaseurCommented:
Agree with Medo3337 - we probably need to see the rest of the code.
0
 
Tyler LaczkoCommented:
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?
0
 
Tyler LaczkoCommented:
try retyping the statement. maybe there was a typo.
0
 
haloexpertsexchangeCommented:
This while loop
while(($curlValue == 7 || $curlValue == 0 || $socketValue == 111) AND $curlCounter < 4)

Open in new window

should be
while(($curlValue == 7 || $curlValue == 0 || $socketValue == 111) && $curlCounter < 4)

Open in new window

AND works in vb but && is how you specify and in php

http://www.w3schools.com/php/php_operators.asp
0
 
justmelatAuthor Commented:
That got it "haloexpertsexchange:"

thank you!!!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now