title: Insert into mySQL from php foreach loop
body: <p>I know this has been asked so many times but I can't seem to figure the issue out. Im running the following code, but it just returns the fail. When I run the output of </p>
  
  <blockquote>
    <p>$query1 --> <strong>INSERT INTO number (count,code,prize,printed) VALUES ('1','Q0stZr0g8uc4syE','','0');</strong></p>
  </blockquote>
  
  <p>straight into phpmyadmin it inserts fine. I must be doing something stupid... Any ideas?</p>
  
  <pre><code>$times_to_run = 100;
  $prize='';
  
  for($i=1;$i&lt;=$times_to_run;$i++){
  
      $array[] = array(
              'count' =&gt; $i,
              'code1' =&gt; randomString(),
              'prize' =&gt; $prize
      );
  }
  
  $codes = $array;
  
  foreach ($codes as $code){
  
      $query1 = "INSERT INTO number (count,code,prize,printed) VALUES ('". $code['count']."','". $code['code1']."','". $code['prize']."','0');";
  
      $q = mysqli_query($query1) or die (mysql_error());
  
  }
  </code></pre>
  
  <p>EDIT: I changed the query to use mysqli and got the full error which is:
  the actual error is: </p>
  
  <blockquote>
    <p>Warning: mysqli_query() expects at least 2 parameters, 1 given and the line it points to is: $q = mysqli_query($query1) or die (mysql_error());</p>
  </blockquote>
  
  <p>** If I change </p>
  
  <blockquote>
    <p>'". $code['prize']."'</p>
  </blockquote>
  
  <p>to '0' I still get the same error.</p>