title: php read data from sql database
body: <p>I'm trying to learn php and I can't read any data from my database!. I know the connection to the server is live and working but this line seem to be giving me problems.</p>
  
  <p><code>$result = $conn-&gt;query($sql);</code></p>
  
  <p>Where  <code>$sql = "SELECT firstName, middleName, lastName FROM Base";</code>
  I'm not sure what the problem is but any hints or answer are appreciated .</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;My first PHP page&lt;/h1&gt;
  &lt;?php
  // connect to database
  $user_name = "superUser";
  $password = "";
  $database = "Base"$server = "127.0.0.5";
  // open connection to the server
  $conn = new mysqli($server, $user_name, $password);
  // echo "Connection to the server is open";
  // check connetion
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  }
  else {
      print "Connection to the server is open";
  }
  // load the data from the table
  $sql = "SELECT firstName, middleName, lastName FROM Base";
  // echo $conn-&gt;server_info;
  $result = $conn-&gt;query($sql);
  if ($result) {
      echo "Table was found";
  }
  else echo "no";
  /*while($row = $result-&gt;fetch_assoc()) {
  echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "&lt;br /&gt;";
  }
  print $result["firstName"];// ": Number of Rows!" ;*/
  // if ($result-&gt;num_rows &gt; 0) {
  // output data of each row
  // close server connection
  $conn-&gt;close();
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>