-2

first sorry my english.. have problem in my project, I can not solve, see.

Warning: require_once(../action/config.php): failed to open stream: No such file or directory in C:\wamp64\www\maismaranhao\index.php on line 5 Call Stack

Fatal error: require_once(): Failed opening required '../action/config.php' (include_path='.;C:\php\pear') in C:\wamp64\www\maismaranhao\index.php on line 5

my index.php is correct, and the settings also. See

<?php

session_start();

require_once "action/config.php";
require_once LIB."system/Utils.class.php";
require_once LIB."system/Data.class.php";

$ACTION = Utils::getAction();

//echo "<pre>"; //var_dump($_GET);exit; 

$_GET["DEBUG"] = false;

Utils::utf8_filter(); ...

config.php

<?php

 define("DOCUMENT_ROOT",$_SERVER["DOCUMENT_ROOT"]);
 define("WORKSPACE",DOCUMENT_ROOT . "action/");
 define("TEMP",DOCUMENT_ROOT . "temp/"); 
 define("LIB",WORKSPACE ."lib/"); 
 define("CLASS_PATH",DOCUMENT_ROOT . "classes/");
 define("ADMIN_PATH","admin/"); 
 define('SMARTY_PATH',LIB .'external/Smarty/libs/');
 define('TEMPLATE_PATH',DOCUMENT_ROOT .'smarty_templates/'); 
 define("URL","localhost");
 define("ADMIN_URL",URL . ADMIN_PATH);
 define("SITE_NAME","MaisMaranhão");
 define("SITE_SLOGAN","Mais Notícias do Maranhão para Você!");

 set_include_path(get_include_path() . PATH_SEPARATOR . WORKSPACE .PATH_SEPARATOR . LIB . PATH_SEPARATOR . CLASS_PATH);
?>
Borgtex
  • 3,235
  • 1
  • 19
  • 28
  • I think there is a problem in the location of your file(config.php) check the path of the file – odai Sep 04 '16 at 18:04
  • You need to create a Virtual Hosts for each of your projects http://stackoverflow.com/questions/23665064/project-links-do-not-work-on-wamp-server/23990618#23990618 – RiggsFolly Sep 04 '16 at 18:12
  • Already created a Virtual Hosts – Werik Da Silva Pires Sep 04 '16 at 18:17
  • 1
    CONFUSED: Your error suggests you are using `../action/` as the path but your code uses `action/` So which one is it? – RiggsFolly Sep 04 '16 at 18:29
  • Yeah, i tried both ways – Werik Da Silva Pires Sep 04 '16 at 19:05
  • Try to replace the '\' by '/' on require_once paths Long time I do not use windows systems, but, seems to me thats may do the trick ! based on your error message : " Failed opening required '../action/config.php' (include_path='.;C:\php\pear') in C:\wamp64\www\maismaranhao\index.php " [pt-br] Cara, as barras invertidas nao sao padrao no windows, e vc esta tentanto incluir um caminho usando elas. tente as barras normais ... – Diego Favero Sep 04 '16 at 19:44
  • Não há barras erradas, conferi todo o projeto. – Werik Da Silva Pires Sep 05 '16 at 13:38

1 Answers1

0

The problem is that you are using a relative path in your require_once "action/config.php";. This is wrong, is unreliable, and will generate errors like the one you have encountered.

You should use an absolute path, potentially using _DIR_.

You can read about why this is happening, and how to fix it, in this post: PHP - Failed to open stream : No such file or directory

Community
  • 1
  • 1
Vic Seedoubleyew
  • 9,888
  • 6
  • 55
  • 76