title: Joomla add article via php script Application Instantiation Error
body: <p>i created a script in order to insert some articles via a php script. This script is working on my local machine (xampp), but when i deploy the whole joomla project to my web server i get the following error message:</p>
  <blockquote>
  <p>Error displaying the error page: Application Instantiation Error: Application Instantiation Error</p>
  </blockquote>
  <p>By adding some echo calls, i was able to find the line which causes the error:</p>
  <pre><code>$app = JFactory::getApplication('site');
  </code></pre>
  <p>Now i am wondering how to fix this behaviour and make my function also run on the web server.</p>
  <p>Below i will provide my system informations and the beginning of my php function until the line, which causes the error message:</p>
  <hr />
  <h3>Systeminformations</h3>
  <ul>
  <li>joomla version: 3.6.5 Stable</li>
  <li>db version: 5.6.34-79.1-log</li>
  <li>php version: 5.6.30-he.0</li>
  <li>web server: Apache</li>
  </ul>
  <hr />
  <h3>PHP snippet</h3>
  <pre><code>&lt;?php
  
  echo &quot;STARTING;   &quot;;
  
  // get db connection
  include('../includes/mysql.inc.php');
  
  // get all sql querys
  include('./autoNewsQuerys.inc.php');
  
  /**
   * Prepare joomla framework to insert article correctly
   */
  if (!defined('_JEXEC')) {
      define('_JEXEC', 1);
      define('JPATH_BASE','/is/htdocs/wp1088688_4E1H7PYJFK/www');
      require_once(JPATH_BASE . '/includes/defines.php');
      require_once(JPATH_BASE . '/includes/framework.php');
      defined('DS') or define('DS', DIRECTORY_SEPARATOR);
  }
  
  echo &quot;searching app;&quot;;
  $app = JFactory::getApplication('site');
  echo &quot;Found app;&quot;;
  
   
  </code></pre>
  <hr />
  <h3>Full browser output</h3>
  <blockquote>
  <p>STARTING; searching app;Error displaying the error page: Application Instantiation Error: Failed to start the session because headers have already been sent by &quot;/is/htdocs/wp1088688_4E1H7PYJFK/www/1500AutoNews/autoNews.php&quot; at line 3.</p>
  </blockquote>
  <p>So as you can see the error is caused by the JFactory call. 'Found app' is never printed out.</p>