title: Retrieveing data from database results in 0 results
body: <p>I've got multiple entries in my database, yet my php code <code>returns 0</code> entries.</p>
  
  <p>Here's my php:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>error_reporting(E_ALL);
  ini_set('display_errors', 1);
  
  $conn = new mysqli($host, $user, $pass, $databasename);
  
  // Check connection can be established
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  }
  
  $sql = "SELECT charts_URL, charts_date, charts_retrace, charts_start_of_swing_trade, charts_end_of_swing_trade, charts_bull_flag, charts_bear_flag, charts_ema_crossover, charts_trading_instrument FROM charts";
  
  $result = $conn-&gt;query($sql);
  
  if($result &amp;&amp; $result-&gt;num_rows &gt; 0) {
      // output data of each row
    echo "
       &lt;table&gt;
         &lt;tr&gt;
           &lt;td&gt;&lt;strong&gt;&lt;u&gt;Chart&lt;/u&gt;&lt;/strong&gt;&lt;/td&gt;
           &lt;td&gt;&lt;strong&gt;&lt;u&gt;Date&lt;/u&gt;&lt;/strong&gt;&lt;/td&gt;
           &lt;td&gt;&lt;strong&gt;&lt;u&gt;Retrace&lt;/u&gt;&lt;/strong&gt;&lt;/td&gt;
           &lt;td&gt;&lt;strong&gt;&lt;u&gt;Start of Swing Trade&lt;/u&gt;&lt;/strong&gt;&lt;/td&gt;
           &lt;td&gt;&lt;strong&gt;&lt;u&gt;End of Swing Trade&lt;/u&gt;&lt;/strong&gt;&lt;/td&gt;
           &lt;td&gt;&lt;strong&gt;&lt;u&gt;Bull flag&lt;/u&gt;&lt;/strong&gt;&lt;/td&gt;
           &lt;td&gt;&lt;strong&gt;&lt;u&gt;Bear flag&lt;/u&gt;&lt;/strong&gt;&lt;/td&gt;
           &lt;td&gt;&lt;strong&gt;&lt;u&gt;EMA Crossover&lt;/u&gt;&lt;/strong&gt;&lt;/td&gt;
           &lt;td&gt;&lt;strong&gt;&lt;u&gt;Trading Instrument&lt;/u&gt;&lt;/strong&gt;&lt;/td&gt;
         &lt;/tr&gt;";
      while ($row=mysqli_fetch_array($sql)) {
          echo  "&lt;tr&gt;&lt;td&gt;&lt;a href=" . $row['charts_URL']. "&gt;&lt;img src=". $row['charts_URL']. "&gt;&lt;/a&gt;&lt;/td&gt;";
          echo  "&lt;td&gt;" . $row['charts_date']. "&lt;/td&gt;";
          echo  "&lt;td&gt;" . $row["charts_retrace"]. "&lt;/td&gt;";
          echo  "&lt;td&gt;" . $row["charts_start_of_swing_trade"]. "&lt;/td&gt;";
          echo  "&lt;td&gt;" . $row["charts_end_of_swing_trade"]. "&lt;/td&gt;";
          echo  "&lt;td&gt;" . $row["charts_bull_flag"]. "&lt;/td&gt;";
          echo  "&lt;td&gt;" . $row["charts_bear_flag"]. "&lt;/td&gt;";
          echo  "&lt;td&gt;" . $row["charts_ema_crossover"]. "&lt;/td&gt;";
          echo  "&lt;td&gt;" . $row["charts_trading_instrument"]. "&lt;/td&gt;&lt;/tr&gt;";
      }
       echo "&lt;/table&gt;";
  } else {
      echo "0 results";
  }
  $conn-&gt;close();   
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Obviously, I cut out the actual database info such as username, password, etc.  Here's a snippet from my php code that I used to submit data into the database which submits data successfully into the database.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code> $sql = "INSERT into charts (charts_URL, charts_date, charts_retrace, charts_start_of_swing_trade, charts_end_of_swing_trade, charts_bullflag, charts_bearflag, charts_ema_crossover, charts_trading_instrument) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";</code></pre>
  </div>
  </div>
  </p>
  
  <p>So you can double check the variables between my data retrieval/display code and my data insertion code.  My data insertion code works perfectly.  I see data inthe database that I submitted through a form.  But when I try and retrieve the data and display it, I get a "0 results" message.   Any ideas?</p>