title: My PHP code doesnt seem to want to connect to the database and/or display the data, can someone point out what's wrong?
body: <p>So basically I am trying to simply just connect to my local mysql database with a football table to display on the site, but it doesn't seem to be able to connect. I feel like it's really obvious but I just can't see it.. I have checked the password is correct also, and it is.</p>
  
  <pre><code>&lt;?php
  $servername = "localhost";
  $username = "root";
  $password = "password"
  $dbname = "import_excel_to_mysql";
  
  /* Create connection */
  $conn = new mysqli("localhost", "root", "password", "import_excel_to_mysql");
  /* Check connection */
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error . mysql_error());
  } 
  
  $sql = "SELECT position, team_name, played, wins, draws, losses, goals_scored, goals_against, goal_difference, points FROM football table";
  $result = $conn-&gt;query($sql);
  if ($result-&gt;num_rows &gt; 0) {
      echo "&lt;table&gt;&lt;tr&gt;&lt;th&gt;Pos&lt;/th&gt;&lt;th&gt;Team Name&lt;/th&gt;&lt;th&gt;P&lt;/th&gt;&lt;th&gt;W&lt;/th&gt;&lt;th&gt;D&lt;/th&gt;&lt;th&gt;L&lt;/th&gt;(etc)&lt;/tr&gt;";
      /* output data of each row */
      while($row = $result-&gt;fetch_assoc()) {
          echo "&lt;tr&gt;&lt;td&gt;" . $row["position"]. "&lt;/td&gt;&lt;td&gt;" . $row["team_name"]. " " . $row["played"]. " " . $row["wins"]. " " . $row["draws"]. (etc)"&lt;/td&gt;&lt;/tr&gt;";
      }
      echo "&lt;/table&gt;";
  } else {
      echo "0 results";
  }
  ?&gt;
  </code></pre>
  
  <p>It should display the table just on its own, but instead it displays all the php code starting at <code>connect_error(</code>. The rest of the site is unaffected.</p>