title: Storing file in database using C# and retrieving from PHP
body: <p>I am working on a c# project where I store a file in a database into a medium blob field, the data is being stored fine and when I view it inside MySQL Workbench each line in the file is being shown on it own line in the database, i.e. the same format. </p>
  
  <p>However, when I retrieve the information from PHP it seems to remove the new lines and everything is on the same line. </p>
  
  <p>Below is the code I am using to store the file in the database. </p>
  
  <pre><code>using (ConnectDb db = new ConnectDb(appSettings))
                  {
                      FileStream fileStream = new FileStream(logFile, FileMode.Open, FileAccess.Read);
                      long fileLength = fileStream.Length;
                      byte[] myData = new byte[fileLength];
                      fileStream.Read(myData, 0, System.Convert.ToInt32(fileLength));
                      fileStream.Close();
  
                      string fileSize = Common.convertBytesToMb(fileLength);
                      string query = "INSERT INTO logfile_history (LogFile, FileSize) VALUES (@file, @size)";
                      using (MySqlCommand cmd = new MySqlCommand(query, db.conn))
                      {
                          cmd.Parameters.AddWithValue("@file", myData);
                          cmd.Parameters.AddWithValue("@size", fileSize);
                          cmd.ExecuteNonQuery();
                      }
                  }
  </code></pre>
  
  <p>When I get the file from PHP the new lines are removed, below is the code I am using to get the data from the Medium Blob in the database from PHP.</p>
  
  <pre><code>$query = "SELECT * FROM logfile_history WHERE id='$id'";
  
      $result = mysql_query($query);
      if ($result)
      {
          echo "&lt;table class=\"overview\"&gt;";
          echo "&lt;tr&gt;";
          echo "&lt;th&gt;Date&lt;/th&gt;";
          echo "&lt;th&gt;Class/Method&lt;/th&gt;";
          echo "&lt;th&gt;Message&lt;/th&gt;";
          echo "&lt;/tr&gt;";
          while ($myrow = mysql_fetch_array($result))
          {
              $logContent = $myrow['LogFile'];
              $splitContent = explode("\t", $logContent);
              $i = 0;
              $colCount = 0;
              while ($i &lt; count($splitContent))
              {
                  if ($colCount == 0)
                  {
                      echo "&lt;tr&gt;";
                  }
                  echo "&lt;td&gt;" . $splitContent[$i] . "&lt;/td&gt;";
                  if ($colCount == 2)
                  {
                      echo "&lt;/tr&gt;";
                      $colCount = 0;
                  }
                  $i++;
                  $colCount++;
              }
          }
          echo "&lt;/table&gt;";
  </code></pre>
  
  <p>I'm splitting the line as in the log file it is tab separated so I am splitting it by the tab to put it in a table, but this was before I realised everything is on the same line. </p>
  
  <p>How do I keep the line breaks when the data is retrieved from the database.</p>
  
  <p>Thanks for any help you can provide. </p>