title: Displaying images from a MySQL Database with MAMP
body: <p>I'm trying to query images from a MySQL Database through MAMP on MacOS.</p>
  
  <p>I'm using this code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;!-- &lt;meta name="viewport" content="width=device-width, intial-scale=1.0"/&gt; --&gt;
  &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"&gt;
  &lt;title&gt;Show Image in PHP&lt;/title&gt;
  &lt;style&gt;
      body{background-color: #f2f2f2; color: #333;}
      .main{box-shadow: 0 .125rem .25rem rgba(0,0,0,.075)!important; margin-top: 10px;}
      h3{background-color: #4294D1; color: #f7f7f7; padding: 15px; border-radius: 4px; box-shadow: 0 1px 6px rgba(57,73,76,0.35);}
      .img-box{margin-top: 20px;}
      .img-block{float: left; margin-right: 5px; text-align: center;}
      p{margin-top: 0;}
      img{width: 375px; min-height: 250px; margin-bottom: 10px; box-shadow: 0 .125rem .25rem rgba(0,0,0,.075)!important; border:6px solid #f7f7f7;}
  &lt;/style&gt;
  &lt;/head&gt;
      &lt;body&gt;
      &lt;!-------------------Main Content------------------------------&gt;
      &lt;div class="container main"&gt;
          &lt;h3&gt;Showing Images&lt;/h3&gt;
          &lt;div class="img-box"&gt;
      &lt;?php
  
          $username="root"; $password="root"; $database="SomeImages";
  
          $con = mysqli_init();
          mysqli_options($con, MYSQLI_OPT_LOCAL_INFILE, true);
          mysqli_real_connect($con, "localhost", $username, $password, $database);
  
          mysqli_select_db($database);
  
          $image_query = mysqli_query($con, "SELECT framing,im FROM images");
  
  
          while($rows = mysqli_fetch_array($image_query))
          {
              $img_name = $rows['framing'];
              $img_src = $rows['im'];
          ?&gt;
  
          &lt;div class="img-block"&gt;
          &lt;img src="&lt;?php echo $img_src; ?&gt;" alt="" title="&lt;?php echo $img_name; ?&gt;" width="300" height="200" class="img-responsive" /&gt;
          &lt;p&gt;&lt;strong&gt;&lt;?php echo $img_name; ?&gt;&lt;/strong&gt;&lt;/p&gt;
          &lt;/div&gt;
  
          &lt;?php
          }
      ?&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;/body&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>When I "run" it from my IDE (CodeRunner), I get totally functional html in the console (and no error messages), like this:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;!-- &lt;meta name="viewport" content="width=device-width, intial-scale=1.0"/&gt; --&gt;
  &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"&gt;
  &lt;title&gt;Show Image in PHP - Campuslife&lt;/title&gt;
  &lt;style&gt;
      body{background-color: #f2f2f2; color: #333;}
      .main{box-shadow: 0 .125rem .25rem rgba(0,0,0,.075)!important; margin-top: 10px;}
      h3{background-color: #4294D1; color: #f7f7f7; padding: 15px; border-radius: 4px; box-shadow: 0 1px 6px rgba(57,73,76,0.35);}
      .img-box{margin-top: 20px;}
      .img-block{float: left; margin-right: 5px; text-align: center;}
      p{margin-top: 0;}
      img{width: 375px; min-height: 250px; margin-bottom: 10px; box-shadow: 0 .125rem .25rem rgba(0,0,0,.075)!important; border:6px solid #f7f7f7;}
  &lt;/style&gt;
  &lt;/head&gt;
      &lt;body&gt;
      &lt;!-------------------Main Content------------------------------&gt;
      &lt;div class="container main"&gt;
          &lt;h3&gt;Showing Images from database&lt;/h3&gt;
          &lt;div class="img-box"&gt;
  
  Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in index.html on line 31
  
          &lt;div class="img-block"&gt;
          &lt;img src="images/0.jpg" alt="" title="3" width="300" height="200" class="img-responsive" /&gt;
          &lt;p&gt;&lt;strong&gt;3&lt;/strong&gt;&lt;/p&gt;
          &lt;/div&gt;
  
  
          &lt;div class="img-block"&gt;
          &lt;img src="images/2.jpg" alt="" title="3" width="300" height="200" class="img-responsive" /&gt;
          &lt;p&gt;&lt;strong&gt;3&lt;/strong&gt;&lt;/p&gt;
          &lt;/div&gt;
  
  
          &lt;div class="img-block"&gt;
          &lt;img src="images/2.jpg" alt="" title="3" width="300" height="200" class="img-responsive" /&gt;
          &lt;p&gt;&lt;strong&gt;3&lt;/strong&gt;&lt;/p&gt;
          &lt;/div&gt;
  &lt;/div&gt;
      &lt;/div&gt;
      &lt;/body&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>However, when I open the html/php code from a browser with <a href="http://localhost:8888/SomeImages/" rel="nofollow noreferrer">http://localhost:8888/SomeImages/</a>, I get this, where the php part in commented:</p>
  
  <p><a href="https://i.stack.imgur.com/ewYje.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ewYje.png" alt="enter image description here"></a></p>
  
  <p>What am I doing wrong?</p>