title: I'm having trouble with php while loop inserting data in to mysql database
body: <p>All the php code is below. </p>
  
  <p>The script works fine up until the insert in to cinema database table part. I've echo'd
  the contents of the variables each run through the loop to ensure that they have all
  the correct data inside them. But for some reason some of the data is not being inserted in to the database even though it is contained in the variables just before the insert statement. There are 18 loops all together, but only 12 rows of data are being inserted in to the database. I thought maybe its too much data for one insert statement so tried limiting it to ten, then I planned on selecting the rest using the from id desc query, but of the first 10 only 7 inserted telling me that it must be the insert statement, not the database table. I have searched for a reason and tried lots of different things but still no joy. This is literally a last resort for me, as I am very much a DIY person and don't like asking for help. Thanks in advance for any help I get!</p>
  
  <pre><code>&lt;?php
  
  require('../php/connect.php');
  
  $table = "CREATE TABLE IF NOT EXISTS cinema (
      id int(20) NOT NULL AUTO_INCREMENT,
      tags VARCHAR(200) NOT NULL,
      title VARCHAR(200) NOT NULL,
      description VARCHAR(300) NOT NULL,
      image VARCHAR(100) NOT NULL,
      link VARCHAR (200) NOT NULL,
      PRIMARY KEY(id))";
  
  $result = mysqli_query ($dbc, $table);
  
  
  $select = "SELECT * FROM search";
  
  $r = mysqli_query ($dbc, $select);
  
  while ( $row = mysqli_fetch_array( $r , MYSQLI_ASSOC ))
  {
      $tags = $row['tags'];
      $title = $row['title'];
      $description = $row['description'];
      $image = $row['image'];
      $link = $row['link'];
  
      echo $tags;
      echo $title;
      echo $description;
      echo $image;
      echo "$link &lt;br /&gt;";
      echo "one &lt;br /&gt;&lt;br /&gt;";
  
      $insert = "INSERT INTO cinema (tags, title, description, image, link)
                  VALUES ('$tags', '$title', '$description', '$image', '$link')";
  
      $run = mysqli_query ($dbc, $insert);                        
  }
  
  
  if($result) {
      echo 'success';
  }
  
  else {
      echo 'failed';
  }   
  </code></pre>