O
O
olifem2017-07-16 16:23:34
PHP
olifem, 2017-07-16 16:23:34

What is the problem with Fatal error: Cannot break/continue 1 level?

When I try to update the file, it gives -
Fatal error: Cannot break/continue 1 level in C:\OpenServer\domains\AnnaMarcus\admin\inc\update_info.php on line 12
Form

<form method="post" action="inc/update_info.php">
<textarea name="info"></textarea>
<input type="submit" title="Отправить"/>
</form>

update_info.php handler
include "class.main.php";

  $classes=new classes;
  $error=false;

  $text = $_POST['info'];
  $id  = 1;

  if(!$classes->update_info($text, $id))	{
    $error=true;
    break;
  }
  if(!$error){echo "<script> location.replace('../info.php'); </script>";}

Class
class classes extends db{
function update_info($text, $id){
    $quest = "UPDATE info SET `text` = ".$text." WHERE `id` =".$id;
    if($result=$this->connection->query($quest)){
      return(true);
    }
    else{
      return(false);
    }
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Combat7, 2017-07-16
@Combat7

Why do you need a break in the condition?

if(!$classes->update_info($text, $id)) {
$error=true;
break;
}

Take it away

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question