Page 1 of 1

500 - internal server error

Posted: Sat Jul 12, 2008 3:54 pm
by shero4ever
I got this error with a very weird behavior.

There is a break statement, if i commented, the code runs with no problem, but if i use it, i got the following strange message:

500 Internal Server Error

The server has encountered an internal error or misconfiguration and was unable to complete your request.

while(true)
{
$temp = $currentString;
$currentString = strstr($currentString,"<way id=");
if($currentString == false)
{
echo "out";
break;
}
$wayPosition = strpos($currentString,"<way id=",$nextWay);
$nextWay = $wayPosition + 1;
$wayID = substr($currentString, 8,9);
echo $i." way ID = ".$wayID."<br>";
$x= 0;
$nodePosition = 0;
$position = 0;
$next = 0;
$temp = $currentString;
while(true)
{
$position = strpos($temp,"<nd ref=",$next);
$next = $position + 1;
echo "initial pos = ".$position."<BR>";
$nodePosition = $nodePosition + $position;
$nodePosition = (int)$nodePosition;
echo "node pos = ".$nodePosition."<BR>";
$wayPosition = $wayPosition + 0;
echo "way pos = ".$wayPosition."<BR>";
$wayPosition = (int)$wayPosition;
if(((int)$nodePosition) > ((int)$wayPosition))
{
echo "OUT <BR>";
break; => this is the break statment, i meant
}
$currentString = strstr($currentString,"<nd ref=");
$nodeRef[$x] = substr($currentString, 8,11);
$x++;
}

for($y=0;$y<count($nodeRef);$y++)
{
echo " Node Ref = ".$nodeRef[$y]."<br>";
}
$i++;
}


Hope I can find a solution for this

thanks
Sherif attia

Re: 500 - internal server error

Posted: Sat Jul 12, 2008 4:24 pm
by alex.barylski
Just a wild shot in the dark but...if your getting a 500 error and only when you un-comment the code...

A quick look at your code shows me your potentially encountering a infinite loop with that while(true)

Double check the code which is supposed to break out of the loop. Maybe that is what is causing the 500 error...that would be my first guess anyways.

Re: 500 - internal server error

Posted: Sun Jul 13, 2008 2:44 pm
by shero4ever
well actually, with no break statement the code runs correctly, but there is no termination condition

I checked the results, by echoing values, and assured that the if condition is entered