500 - internal server error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shero4ever
Forum Newbie
Posts: 2
Joined: Sat Jul 12, 2008 3:36 pm

500 - internal server error

Post 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
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: 500 - internal server error

Post 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.
shero4ever
Forum Newbie
Posts: 2
Joined: Sat Jul 12, 2008 3:36 pm

Re: 500 - internal server error

Post 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
Post Reply