Base Directory Change Issue
<p>In my app, I'm using an AJAX call to retrieve information, which requires the inclusion of a db_connect.php file. db_connect.php requires other files for it to work.</p>

<p>If I include db_connect.php from the AJAX file, naturally, errors are returned from includes within the db_connect.php file because db_connect.php's includes are relative to the base directory of my application.</p>

<p>How can I change the working directory to the base directory of the application, so the included files will function properly?</p>

<p>What I've tried is using the <code>chdir</code> function:</p>

<pre><code>echo getcwd() . "&lt;br/&gt;";
chdir("../../");
echo getcwd();
</code></pre>

<p>This correctly outputs:</p>

<pre><code>/my/webserver/app/lib/ajax  
/my/webserver/app
</code></pre>

<p>However, the include errors act like I haven't just changed the directory:</p>

<blockquote>
  <p>Warning: include_once(functions/clean_string.func.php) [function.include-once]: failed to open stream: No such file or directory in my/webserver/app/lib/ajax/ajax.php on line 8</p>
</blockquote>

<p>What am I doing wrong?</p>
