title: How can i insert into scraped data into mysql?
body: <p>//Here is the full script.
  I need  to send the returned array results to mysql. I have tried many variations on mySQL insert functions but mysql will still not populate with the data. The table in mysql has the column names 'date','home','score','away'. I am using xamp as a localhost, with database name:'brazil', table name: 'seriea'. Any ideas would be appreciated! thanks.</p>
  
  <pre><code>&lt;?php 
  
  $data = array();
  $html = file_get_contents('http://www.soccerstats.com/round_details.asp?league=brazil'); //get the html returned from the following url
  $doc = new DOMDocument();
  libxml_use_internal_errors(true);
  
  if(!empty($html)){
      $doc-&gt;loadHTML('&lt;meta http-equiv="content-type" content="text/html; charset=utf-8"&gt;'.$html);
      libxml_clear_errors();
      $xpath = new DOMXPath($doc);
  
      $entries = $xpath-&gt;query('//table[@class="stat"]');
      foreach($entries as $key =&gt; $value) {
  
  
  
          $data[] = array(
              'date' =&gt; trim($value-&gt;getElementsByTagName('font')-&gt;item(0)-&gt;nodeValue),
              'home' =&gt; trim($value-&gt;getElementsByTagName('font')-&gt;item(1)-&gt;nodeValue),
              'score' =&gt; trim($value-&gt;getElementsByTagName('font')-&gt;item(2)-&gt;nodeValue),
              'away' =&gt; trim($value-&gt;getElementsByTagName('font')-&gt;item(3)-&gt;nodeValue),
          );
      }
  }
  
  
  echo "&lt;pre&gt;";
  
  print_r($data);
  echo "&lt;/pre&gt;";
  
  // Create connection
  $con=mysqli_connect("***","***","***");
  mysqli_select_db('brazil', $con);
  
  // Check connection
  if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  
  else
  {
  $date = $_POST['date'];
  $home = $_POST['home'];
  $score = $_POST['score'];
  $away = $_POST['away'];
  $sql="INSERT INTO seriea (date, home, score, away) VALUES ('$date','$home','$score','$away')";
  if (!mysqli_query($sql,$con))
  {
  die('Error: ' . mysqli_error());
  }
  else{
  echo "1 record added";
  }
  }
  mysqli_close($con);
  ?&gt;
  </code></pre>
  
  <p>//Output to go to mysql//</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [date] =&gt; 1 Jun 14
              [home] =&gt; Â FluminenseÂ 
              [score] =&gt; 1 - 1
              [away] =&gt; Â InternacionalÂ 
          )
  
      [1] =&gt; Array
          (
              [date] =&gt; 1 Jun 14
              [home] =&gt; Â VitÃ³riaÂ 
              [score] =&gt; 0 - 1
              [away] =&gt; Â Sport RecifeÂ 
          )
  
      [2] =&gt; Array
          (
              [date] =&gt; 1 Jun 14
              [home] =&gt; Â CorinthiansÂ 
              [score] =&gt; 1 - 1
              [away] =&gt; Â BotafogoÂ 
          )
  
      [3] =&gt; Array
          (
              [date] =&gt; 1 Jun 14
              [home] =&gt; Â ChapecoenseÂ 
              [score] =&gt; 2 - 1
              [away] =&gt; Â BahiaÂ 
          )
  
      [4] =&gt; Array
          (
              [date] =&gt; 1 Jun 14
              [home] =&gt; Â CruzeiroÂ 
              [score] =&gt; 3 - 0
              [away] =&gt; Â FlamengoÂ 
          )
  
      [5] =&gt; Array
          (
              [date] =&gt; 1 Jun 14
              [home] =&gt; Â SantosÂ 
              [score] =&gt; 2 - 0
              [away] =&gt; Â CriciÃºmaÂ 
          )
  
      [6] =&gt; Array
          (
              [date] =&gt; 1 Jun 14
              [home] =&gt; Â GrÃªmioÂ 
              [score] =&gt; 0 - 0
              [away] =&gt; Â PalmeirasÂ 
          )
  
      [7] =&gt; Array
          (
              [date] =&gt; 1 Jun 14
              [home] =&gt; Â FigueirenseÂ 
              [score] =&gt; 1 - 3
              [away] =&gt; Â AtlÃ©tico PRÂ 
          )
  
      [8] =&gt; Array
          (
              [date] =&gt; 31 May 14
              [home] =&gt; Â SÃ£o PauloÂ 
              [score] =&gt; 2 - 1
              [away] =&gt; Â AtlÃ©tico MGÂ 
          )
  
      [9] =&gt; Array
          (
              [date] =&gt; 31 May 14
              [home] =&gt; Â CoritibaÂ 
              [score] =&gt; 3 - 0
              [away] =&gt; Â GoiÃ¡sÂ 
          )
  
      [10] =&gt; Array
          (
              [date] =&gt; 30 May 14
              [home] =&gt; Â BahiaÂ 
              [score] =&gt; 0 - 2
              [away] =&gt; Â SantosÂ 
          )
  
      [11] =&gt; Array
          (
              [date] =&gt; 29 May 14
              [home] =&gt; Â InternacionalÂ 
              [score] =&gt; 2 - 0
              [away] =&gt; Â ChapecoenseÂ 
          )
  
      [12] =&gt; Array
          (
              [date] =&gt; 29 May 14
              [home] =&gt; Â FlamengoÂ 
              [score] =&gt; 1 - 1
              [away] =&gt; Â FigueirenseÂ 
          )
  
      [13] =&gt; Array
          (
              [date] =&gt; 29 May 14
              [home] =&gt; Â AtlÃ©tico MGÂ 
              [score] =&gt; 2 - 0
              [away] =&gt; Â FluminenseÂ 
          )
  
      [14] =&gt; Array
          (
              [date] =&gt; 29 May 14
              [home] =&gt; Â AtlÃ©tico PRÂ 
              [score] =&gt; 2 - 2
              [away] =&gt; Â SÃ£o PauloÂ 
          )
  
      [15] =&gt; Array
          (
              [date] =&gt; 29 May 14
              [home] =&gt; Â CorinthiansÂ 
              [score] =&gt; 1 - 0
              [away] =&gt; Â CruzeiroÂ 
          )
  
      [16] =&gt; Array
          (
              [date] =&gt; 29 May 14
              [home] =&gt; Â GoiÃ¡sÂ 
              [score] =&gt; 0 - 0
              [away] =&gt; Â VitÃ³riaÂ 
          )
  
  )
  </code></pre>