Page 1 of 1

Error like failed to open the stream.no such directory in C:

Posted: Wed Aug 12, 2009 12:00 am
by phphunger
Hi,
As iam new to this forum. and also iam new to php programming. i am getting the following error. Can any one solve it.

Code: Select all

Warning: include(includes/dbconfig.php) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\kspicydeals\admin\login_index.php on line 6
 
Warning: include() [function.include]: Failed opening 'includes/dbconfig.php' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\kspicydeals\admin\login_index.php on line 6
My original code:

Code: Select all

<?php
ob_start();
session_start();
extract($_REQUEST);
//include('../includes/dbconfig.php');
include("includes/dbconfig.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; cha$et=iso-8859-1" />
<LINK href="images/style.css" type=text/css rel=stylesheet>
 
 
<title><?= $retlogo['title'] ?></title>
 
</head>
 
<body onLoad="javascript&#058;document.formx.username.focus();">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><table cellspacing="0" cellpadding="0" width="100%" bgcolor="#ffffff" border="0">
      <tbody>
        <tr>
          <td width="100%"><table bordercolor="#00ffff" cellspacing="0" cellpadding="0" width="100%" 
      border="0">
              <tbody>
                <tr>
                  <td width="100%" height="70"><table cellspacing="0" cellpadding="0" width="100%" 
            background="images/bg-admin-top1.gif" border="0">
                      <tbody>
                        <tr>
                          <td width="71%" align="left" valign="top"><img 
                  src="images/<?= $logo ?>" align="absmiddle" /></td>
                  
                <td class="whttext" style="BACKGROUND-REPEAT: no-repeat" 
            valign="top" align="right" width="29%" 
            background="images/bg-admin-top2.gif" 
            height="70">Copyright &copy; 2007 <?php= $sitevar ?>. <br />
                  
                 
                            All rights reserved.&nbsp;&nbsp;<br />
                            <br />
                            <br />
                            <font color="#ffffff"><b>
                              <?= date("M d,Y") ?>
                            </b></font>&nbsp;&nbsp; </td>
                        </tr>
                      </tbody>
                  </table></td>
                </tr>
              </tbody>
          </table></td>
        </tr>
      </tbody>
    </table></td>
  </tr>
  <tr>
    <td><table height="400" cellspacing="0" cellpadding="0" width="100%" border="0">
      <tbody>
        <tr>
          <td valign="top"><p>
              <script language="JavaScript" type="text/javascript">
<!--
 
function SymError()
{
  return true;
}
 
window.onerror = SymError;
 
//-->
      </script>
              <script language="JavaScript1.2" 
      src="images/jlogin.js" type="text/javascript"></script>
            </p>
              <p>&nbsp;</p>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <table cellspacing="0" cellpadding="0" width="469" align="center" border="0">
                <tbody>
                  <tr>
                    <td colspan="3"><table cellspacing="0" cellpadding="1" rules="group" width="100%" 
            align="center" border="0">
                        <tbody>
                          <tr>
                            <td class="whttext22bold" 
                background="images/logo_loginpage.gif" 
                  height="54"><div align="center">Administrator Login </div></td>
                          </tr>
                          <tr>
                            <td align="center" 
                background="images/bodybg.gif" class="style1" id="loginForm"><center>
                              <font class="errormsg"></font>
                            </center>
                                <br />
                                <p><span class="itemstyle1">Please Enter Your Login Information Correctly </span>.</p>
                              <form action='login.php' method="post" name="formx" id="formx">
                                  <table class="formFields" cellspacing="0" width="55%" align="center" 
                  border="0">
                                    <tbody>
                                      <tr>
                                        <td class="bmatter1" align="right"><label 
                        for="login_name">Login :</label></td>
                                        <td><input id="username" maxlength="255" size="25" 
                        name="username" /></td>
                                      </tr>
                                      <tr>
                                        <td class="bmatter1" align="right"><label 
                        for="passwd">Password :</label></td>
                                        <td><input id="password" type="password" maxlength="14" size="25" 
                        name="password" /></td>
                                      </tr>
                                    </tbody>
                                  </table>
                                <table cellspacing="0" width="100%" border="0">
                                    <tbody>
                                      <tr>
                                        <td class="main" id="get_password" width="38%"></td>
                                        <td class="misc" height="40"><input name="image" 
                        type="image" 
                        style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" 
                    src="images/login.gif" /></td>
                                      </tr>
                                    </tbody>
                                </table>
                            </form></td>
                          </tr>
                        </tbody>
                    </table></td>
                  </tr>
                  <tr>
                    <td><img src="images/bott-leftcorner.gif" /></td>
                    <td width="100%" 
            background="images/bott-cornerbg.gif"><img height="1" src="images/spacer.gif" width="1" /></td>
                    <td><img src="images/bott-rightcorner.gif" /></td>
                  </tr>
                </tbody>
            </table>
            <p>&nbsp;</p>
            <p>&nbsp;</p></td>
        </tr>
      </tbody>
    </table></td>
  </tr>
  <tr>
    <td valign="bottom"><table cellspacing="0" cellpadding="0" width="100%" border="0">
        <tr>
          <td align="right">
          <table cellspacing="0" cellpadding="0" width="100%" border="0">
        <tr>
          <td align="right" height="6">
          </td>
        </tr>
        <tr>
          <td align="right">
          <?php
            include("includes/footer.php");
          ?></td>
        </tr>
    </table></td>
        </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
 

Re: Error like failed to open the stream.no such directory in C:

Posted: Wed Aug 12, 2009 12:08 am
by neuroxik
Are you sure the included files exist, or are in the right place? I have too little context to see.

Re: Error like failed to open the stream.no such directory in C:

Posted: Wed Aug 12, 2009 1:58 am
by phphunger
Thanks for your immediate reponse..

i have included and the file also exists..i kept the dbconfig file in the includes folder of the current project.

Re: Error like failed to open the stream.no such directory in C:

Posted: Wed Aug 12, 2009 3:01 am
by neuroxik
Thanks for adding more detail, although the lines after 7 seem irrelevant.

Where exactly is dbconfig.php ? I know (well, presume) that it's inside includes/ , but is includes/ in the admin folder or in the root ?

Because the way you're including it, it looks for it in admin folder. If it's in the directory above the admin/ folder, you'd need to do include('../includes/dbconfig.php') as done on your line 6 which is commented out.

Side note: because this is a config file, which usually is static, you could use include_once() instead. This will not resolve the "where's the file issue", but it will atleast use less memory on each execution after it. You might also want to use "require_once()" if it's crucial that dbconfig.php be included (which the filename suggests).