title: Why won't this exit out the while loop?
body: <p>I'm trying to exit outside this while look, so my script can post to Wordpress.com blogs. However, even when I try to use break; inside the if statement, the loop continues. </p>
  
  <p>This function starts up the script and basically handles the posting:</p>
  
  <pre><code>function getFlogArticle($url, $mail) {  
  list($id, $title, $content, $tags) = getNewArticle();
  while ($id != 0)
  {
      $start = getTime(); 
      doesArticleExist($url, $id);
          if ($exist = 0)
              {
                  wordpress($title, $content, $mail, $tags, $url, $id);
                  break;  
                  $end = getTime(); 
                  echo  '&lt;strong&gt;Exist While&lt;/strong&gt;: '.round($end - $start,4).' seconds&lt;br /&gt;'; 
              }
      list($id, $title, $content, $tags) = getNewArticle();   
      echo 'I cant stop'; 
  }
  }
  </code></pre>
  
  <p>This function grabs the article from the database every time doesARticleExist() returns 1:</p>
  
  <pre><code>function getNewArticle() {
  $start = getTime(); 
  global $db;
  $count = $db-&gt;query("SELECT * FROM flog_articles");
  $count = $count-&gt;num_rows;
  $offset = mt_rand(0, $count - 1);
  $stmt = "SELECT * FROM flog_articles LIMIT 1 OFFSET $offset";
  $result = $db-&gt;query($stmt);
  $post = $result-&gt;fetch_array(MYSQLI_ASSOC);
  return array($post['article_id'], $post['article_title'], $post['article_content'], $post['article_keyword']);
  $end = getTime(); 
  echo  '&lt;strong&gt;getNewArticle()&lt;/strong&gt;: '.round($end - $start,4).' seconds&lt;br /&gt;';
  }
  </code></pre>
  
  <p>And this script checks to see if the article exists in the database. If it doesn't, it returns a 0. If it does, it returns a 1.</p>
  
  <pre><code>function doesArticleExist($url, $id) {
  $start = getTime(); 
  global $db; 
  $count = $db-&gt;query("SELECT * FROM flog_posted WHERE http = $url AND article_id = $id");
  $count = $count-&gt;num_rows;
  
  if ($count &gt; 0) {
      $exist = 1;
      return $exist;
  } else{
      $exist = 0;
      return $exist;
  }
  $end = getTime();
  echo  '&lt;strong&gt;doesArticleExist()&lt;/strong&gt;: '.round($end - $start,4).' seconds&lt;br /&gt;';
  }
  </code></pre>
  
  <p>Basically, the script gets an article from the database. After it gets the article, it checks to see if that article/url combination exists in another table of the same database. If it does not exist, i want it to post to the wordpress blog, and then break out of the loop, so it won't post again.</p>
  
  <p>The only problem is that it does not even exit the loop. Is it because the exist values are not being passed? </p>