Hello
I am trying to add a poll function to a forum. the adding forum has radio buttons which asks the user whether he wants to add a poll or not. If he chooses yes the questions and the answers will be added to the database. I have included five inputs for answers of the poll. since the user sometimes does not put answers in all of them (the poll he inserts has three options for example) so I included empty function as seen below in the code. However I am receiving an error that maximum execution time of of 30 seconds exceeded.

When I remove the empty function I do not receive this error, however all of the five answers will be inserted even if they did not contain any text.

Can someone help?
here is the script

if ($apt->post[pollcheck] == 1)
		{
$question = $apt->format_data($apt->post[pollq]);
$apt->query("INSERT INTO threadquestion (question,thread,userid) VALUES ('$question','$id','$userid')");

         $qid = $apt->insertid();
         $i = 1;
         while ($i <= 5)
         {
             $answer = $apt->format_data($polla[$i]);
			 if (!empty($answer)) {
             $apt->query("INSERT INTO threadanswers (quesid, text, results) VALUES ('$qid','$answer', '0')");
             $i = $i + 1;
			}
		}
		}

$i = $i + 1;

Should be outside of the if. It is now not incremented, so you'll have an infinite loop.

thanks a million!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.