This has been giving me a headache. I've read multiple questions but none helped me.
So I need to include php files from different folders. Here's how my structure looks like. I'm using WAMP.
/C
/wamp
/www
/project1
/main
/backend
-class.common.php
-inc.config.php
/providers
/google
-google.functions.php
So as clear from the structure above, class.common.php is under folder backend (Which is under folder main).
Now, I'm trying to include class.common.php in google.functions.php using THIS code :-
include '../../class.common.php';
However, this doesn't seem to work. I've even tried working with the __DIR__ constant. No luck. What's the most robust way to achieve my result?
PHP Error Log.
[15-Jun-2016 22:16:25 Europe/Paris] PHP Warning: include(../../_inc_config.php): failed to open stream: No such file or directory in C:\wamp\www\yele\main\backend\api_providers\rech\api_functions.php on line 3
[15-Jun-2016 22:16:25 Europe/Paris] PHP Stack trace:
[15-Jun-2016 22:16:25 Europe/Paris] PHP 1. {main}() C:\wamp\www\yele\main\backend\ajax.php:0
[15-Jun-2016 22:16:25 Europe/Paris] PHP 2. include() C:\wamp\www\yele\main\backend\ajax.php:2
[15-Jun-2016 22:16:25 Europe/Paris] PHP 3. include() C:\wamp\www\yele\main\backend\class.apibase.php:3
[15-Jun-2016 22:16:25 Europe/Paris] PHP 4. include() C:\wamp\www\yele\main\backend\api_providers\rech\base_lib.php:2
[15-Jun-2016 22:16:25 Europe/Paris] PHP Warning: include(): Failed opening '../../_inc_config.php' for inclusion (include_path='.;C:\php\pear') in C:\wamp\www\yele\main\backend\api_providers\rech\api_functions.php on line 3
[15-Jun-2016 22:16:25 Europe/Paris] PHP Stack trace:
[15-Jun-2016 22:16:25 Europe/Paris] PHP 1. {main}() C:\wamp\www\yele\main\backend\ajax.php:0
[15-Jun-2016 22:16:25 Europe/Paris] PHP 2. include() C:\wamp\www\yele\main\backend\ajax.php:2
[15-Jun-2016 22:16:25 Europe/Paris] PHP 3. include() C:\wamp\www\yele\main\backend\class.apibase.php:3
[15-Jun-2016 22:16:25 Europe/Paris] PHP 4. include() C:\wamp\www\yele\main\backend\api_providers\rech\base_lib.php:2
[15-Jun-2016 22:16:25 Europe/Paris] PHP Fatal error: Cannot redeclare class common in C:\wamp\www\yele\main\backend\class.common.php on line 5
[15-Jun-2016 22:16:25 Europe/Paris] PHP Stack trace:
[15-Jun-2016 22:16:25 Europe/Paris] PHP 1. {main}() C:\wamp\www\yele\main\backend\ajax.php:0
[15-Jun-2016 22:16:25 Europe/Paris] PHP 2. include() C:\wamp\www\yele\main\backend\ajax.php:3
I'm not sure I'm reading your diagram properly, but given the following:
if the full path to google.functions.php is
C:/wamp/www/project1/main/backend/providers/google/google.functions.php
and the full path to class.common.php is
C:/wamp/www/project1/main/backend/class.common.php
to include that file relative wherever it is, then __DIR__ should work
<?php
include_once __DIR__.'/../../class.common.php';
Update
From the looks of your error logs, you have a couple problems.
the include failure is happening in C:\wamp\www\yele\main\backend\api_providers\rech\api_functions.php which is calling a path relative include include(../../_inc_config.php), which changes depending on which file the script is included from. so this is odd for a vendor, but you can try changing the line to include(__DIR__.'/../../_inc_config.php') to force it to include relative to the actual including file, which is coincidentally my original answer for your problem.
you have a fatal error with redeclaring the common class, so use include_once or require_once
firsty, getting real/physical path can be more usable
include realpath('/../../class.common.php');
Related
PrestaShop 1.6.1.20
PHP 5.6.37
Hi,
I tried to install a new module on my website but i end up with this php error that i don't know how to debug.
[29-Nov-2018 15:58:11 Europe/Paris] PHP Notice: Undefined index: prod in C:\wamp64\www\prestashop\tools\smarty\sysplugins\smarty_internal_templatebase.php(157) : eval()'d code on line 115
[29-Nov-2018 15:58:11 Europe/Paris] PHP Stack trace:
[29-Nov-2018 15:58:11 Europe/Paris] PHP 1. {main}() C:\wamp64\www\prestashop\index.php:0
[29-Nov-2018 15:58:11 Europe/Paris] PHP 2. DispatcherCore->dispatch() C:\wamp64\www\prestashop\index.php:28
[29-Nov-2018 15:58:11 Europe/Paris] PHP 3. ControllerCore->run() C:\wamp64\www\prestashop\classes\Dispatcher.php:367
[29-Nov-2018 15:58:11 Europe/Paris] PHP 4. IndexControllerCore->initContent() C:\wamp64\www\prestashop\classes\controller\Controller.php:189
[29-Nov-2018 15:58:11 Europe/Paris] PHP 5. HookCore::exec() C:\wamp64\www\prestashop\controllers\front\IndexController.php:40
[29-Nov-2018 15:58:11 Europe/Paris] PHP 6. HookCore::coreCallHook() C:\wamp64\www\prestashop\classes\Hook.php:548
[29-Nov-2018 15:58:11 Europe/Paris] PHP 7. HomecategoriesPlus->hookHome() C:\wamp64\www\prestashop\classes\Hook.php:591
[29-Nov-2018 15:58:11 Europe/Paris] PHP 8. ModuleCore->display() C:\wamp64\www\prestashop\modules\homecategoriesplus\homecategoriesplus.php:767
[29-Nov-2018 15:58:11 Europe/Paris] PHP 9. Smarty_Custom_Template->fetch() C:\wamp64\www\prestashop\classes\module\Module.php:2309
[29-Nov-2018 15:58:11 Europe/Paris] PHP 10. Smarty_Internal_TemplateBase->fetch() C:\wamp64\www\prestashop\classes\SmartyCustom.php:308
[29-Nov-2018 15:58:11 Europe/Paris] PHP 11. content_5bfffe83b6f704_96197512() C:\wamp64\www\prestashop\tools\smarty\sysplugins\smarty_internal_templatebase.php:188
I've tried to look for 'prod' in smarty_internal_templatebase.php but i didn't found anything. would anyone have an idea about where to look and how to fix this ?
Look at the module homecategoriesplus.php at line 767. Your debug says this. I think you just need to add a condition in your homecategoriesplus.tpl to check if the variable prod exists. Something like
{if isset($prod) && $prod}
/*your code here*/
{/if}
or just set default value to the variable during creating it in the homecategoriesplus.php
I am currently using word press latest version. It was working fine yesterday but when i login again today. And when i upload image in the media library it gives this error that
An error occurred in the upload. Please try again later. wordpress
Also my uploaded images are not showing. I have searched for this. My short tags are also on.
[25-Mar-2016 11:50:46 UTC] PHP 1. {main}() E:\designbee\lifeco\wordpress\index.php:0
[25-Mar-2016 11:50:46 UTC] PHP 2. require() E:\designbee\lifeco\wordpress\index.php:17
[25-Mar-2016 11:50:46 UTC] PHP 3. require_once() E:\designbee\lifeco\wordpress\wp-blog-header.php:12
[25-Mar-2016 11:50:46 UTC] PHP 4. require_once() E:\designbee\lifeco\wordpress\wp-load.php:37
[25-Mar-2016 11:50:46 UTC] PHP 5. require_once() E:\designbee\lifeco\wordpress\wp-config.php:89
[25-Mar-2016 11:50:46 UTC] PHP 6. do_action() E:\designbee\lifeco\wordpress\wp-settings.php:376
[25-Mar-2016 11:50:46 UTC] PHP 7. call_user_func_array: {E:\designbee\lifeco\wordpress\wp-includes\plugin.php:525}() E:\designbee\lifeco\wordpress\wp-includes\plugin.php:525
[25-Mar-2016 11:50:46 UTC] PHP 8. lifeco_setup() E:\designbee\lifeco\wordpress\wp-includes\plugin.php:525
this is my log file (Last portion)
There was a div outside of the function in my custom post type.
I am using the latest WAMPServer64 with PHP 5.5.12.
What I did: From a webserver (runs PHP 5.4.16) I have copied the modx folders to localhost, then I copied the entire database. I have also changed the database credentials accordingly via manager/includes/confic.inc.php.
When opening the manager login, I see the following:
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in \manager\includes\extenders\dbapi.mysql.class.inc.php on line 93
When I try to login, the manager does not show up and I get a bunch of errors, content of php_error.log:
PHP Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in manager\includes\extenders\dbapi.mysql.class.inc.php on line 93
PHP Stack trace:
PHP 1. {main}() manager\processors\login.processor.php:0
PHP 2. DBAPI->escape() manager\processors\login.processor.php:51
PHP 3. DBAPI->connect() manager\includes\extenders\dbapi.mysql.class.inc.php:156
PHP 4. mysql_connect() manager\includes\extenders\dbapi.mysql.class.inc.php:93
PHP Notice: Undefined index: captcha_code in manager\processors\login.processor.php on line 53
PHP Stack trace:
PHP 1. {main}() manager\processors\login.processor.php:0
PHP Notice: Undefined index: rememberme in manager\processors\login.processor.php on line 54
PHP Stack trace:
PHP 1. {main}() manager\processors\login.processor.php:0
PHP Notice: Undefined variable: allowed_ip in manager\processors\login.processor.php on line 134
PHP Stack trace:
PHP 1. {main}() manager\processors\login.processor.php:0
PHP Notice: Undefined variable: allowed_days in manager\processors\login.processor.php on line 148
PHP Stack trace:
PHP 1. {main}() manager\processors\login.processor.php:0
PHP Notice: Undefined variable: newloginerror in manager\processors\login.processor.php on line 224
PHP Stack trace:
PHP 1. {main}() manager\processors\login.processor.php:0
PHP Warning: Cannot modify header information - headers already sent by (output started at manager\processors\login.processor.php:54) in manager\processors\login.processor.php on line 298
PHP Stack trace:
PHP 1. {main}() manager\processors\login.processor.php:0
PHP 2. setcookie() manager\processors\login.processor.php:298
PHP Notice: Undefined variable: sql in manager\includes\extenders\dbapi.mysql.class.inc.php on line 276
PHP Stack trace:
PHP 1. {main}() manager\processors\login.processor.php:0
PHP 2. logHandler->initAndWriteLog() manager\processors\login.processor.php:302
PHP 3. logHandler->writeToLog() manager\includes\log.class.inc.php:42
PHP 4. DBAPI->insert() manager\includes\log.class.inc.php:76
I have searched for solutions on the net, some suggested to clear the cache, which is not directly possible since the manager interface does not load. I also tried to upgrade using the default install folder, same problem remains.
So if anyone has a clue how I can solve this without installing an old version of PHP, that would be great.
To get rid of the mysql deprecated warning you have to use Evo 1.0.15+ and you should change
$database_type = 'mysql';
to
$database_type = 'mysqli';
in config.inc.php
The 'only' thing that uses the old mysql_ functions is the installer then. The deprecated warnings are disabled in there for PHP 5.5.
MODx Evolution has a lot of old code in it. As you see by your warnings it is using deprecated mysql-functions. This is long known in the MODx Forums.
As for now you have two possible solutions:
Downgrade your local php version via WAMP to some (best, the same) PHP 5.4 version.
Change your PHP error-reporting level (inside the affected files or in your php.ini) to omit deprecated errors, as long as Evo has this issue.
Can check following solution
https://toster.ru/q/125593
really works !
:)
So I am following this and I'm trying to run his first php example. I get the following error:
PHP Warning: require_once(Zend/Http/Header/HeaderValue.php): failed to open stream: No such file or directory in /opt2/sites/gdataApi/ZendGdata-1.12.13/library/Zend/Http/Client.php on line 45
I checked and the file is in fact not there. So I added it from the minimial 1.12 download. It then says Zend/Xml/Security.php doesn't exist so i add it.
Now I am getting the following error:
PHP Notice: Undefined offset: 1 in /opt2/sites/gdataApi/ZendGdata-1.12.13/library/Zend/Gdata/ClientLogin.php on line 150
PHP Stack trace:
PHP 1. {main}() /opt2/sites/gdataApi/test.php:0
PHP 2. Google_Spreadsheet->__construct() /opt2/sites/gdataApi/test.php:11
PHP 3. Google_Spreadsheet->login()/opt2/sites/gdataApi/Google_Spreadsheet.php:40
PHP 4. Zend_Gdata_ClientLogin::getHttpClient() /opt2/sites/gdataApi/Google_Spreadsheet.php:223
PHP Notice: Undefined variable: php_errormsg in /opt2/sites/gdataApi/ZendGdata-1.12.13/library/Zend/Gdata/App.php on line 834
PHP Stack trace:
PHP 1. {main}() /opt2/sites/gdataApi/test.php:0
PHP 2. Google_Spreadsheet->addRow() /opt2/sites/gdataApi/test.php:24
PHP 3. Google_Spreadsheet->getSpreadsheetId() /opt2/sites/gdataApi/Google_Spreadsheet.php:62
PHP 4. Zend_Gdata_Spreadsheets->getSpreadsheetFeed() /opt2/sites/gdataApi/Google_Spreadsheet.php:252
PHP 5. Zend_Gdata->getFeed() /opt2/sites/gdataApi/ZendGdata-1.12.13/library/Zend/Gdata/Spreadsheets.php:150
PHP 6. Zend_Gdata_App->getFeed() /opt2/sites/gdataApi/ZendGdata-1.12.13/library/Zend/Gdata.php:162
PHP 7. Zend_Gdata_App->importUrl() /opt2/sites/gdataApi/ZendGdata-1.12.13/library/Zend/Gdata/App.php:213
PHP 8. Zend_Gdata_App::importString() /opt2/sites/gdataApi/ZendGdata-1.12.13/library/Zend/Gdata/App.php:792
PHP Fatal error: Uncaught exception 'Zend_Gdata_App_Exception' with message 'DOMDocument cannot parse XML: ' in /opt2/sites/gdataApi/ZendGdata-1.12.13/library/Zend/Gdata/App.php:833
Stack trace:
#0 /opt2/sites/gdataApi/ZendGdata-1.12.13/library/Zend/Gdata/App.php(792): Zend_Gdata_App::importString('', 'Zend_Gdata_Spre...', NULL, NULL)
#1 /opt2/sites/gdataApi/ZendGdata-1.12.13/library/Zend/Gdata/App.php(213): Zend_Gdata_App->importUrl('https://spreads...', 'Zend_Gdata_Spre...', NULL)
#2 /opt2/sites/gdataApi/ZendGdata-1.12.13/library/Zend/Gdata.php(162): Zend_Gdata_App->getFeed('https://spreads...', 'Zend_Gdata_Spre...')
#3 /opt2/sites/gdataApi/ZendGdata-1.12.13/library/Zend/Gdata/Spreadsheets.php(150): Zend_Gdata->getFeed('https://spreads...', 'Zend_Gdata_Spre...')
#4 /opt2/sites/gdataApi/Google_Spreadsheet.php(252): Zend_Gdata_Spreadsheets->getSpreadsheetFeed()
#5 /opt2/sites/gdataApi/Google_Spreadsheet.php(62): Google_Spreadsheet->getSpreadsheetId('test spreadshee...')
#6 /opt2/sites/gdataApi/test.php(24): Google_Spreadsheet in /opt2/sites/gdataApi/ZendGdata-1.12.13/library/Zend/Gdata/App.php on line 833
I have a google spreadsheet that I would like to update programatically using php. Can you tell me whats going wrong with this script? Seems like this is an old article. Are there more recent articles I am missing?
Download Zend framework minimal version. Then extract archive and copy /library/Zend/Http/Header directory to your GData's /Zend/Http/ directory.
PHPUnit seems to execute properly (appropriate tests are executed & pass), but during code coverage an error is thrown. We are using PHPUnit 3.5 with ZF 1.11. Any insight would be greatly appreciated!
(FYI: I looked at some related StackOverflow posts, but nothing seemed to solve this issue for us.)
[24-Jan-2012 00:11:09 UTC] PHP Fatal error: Cannot redeclare class Zend_View_Helper_FormSpecial in /home/za/application/modules/proposal/views/helpers/FormSpecial.php on line 23
[24-Jan-2012 00:11:09 UTC] PHP Stack trace:
[24-Jan-2012 00:11:09 UTC] PHP 1. {main}() /usr/local/zend/bin/phpunit:0
[24-Jan-2012 00:11:09 UTC] PHP 2. PHPUnit_TextUI_Command::main() /usr/local/zend/bin/phpunit:49
[24-Jan-2012 00:11:09 UTC] PHP 3. PHPUnit_TextUI_Command->run() /usr/local/zend/share/pear/PHPUnit/TextUI/Command.php:129
[24-Jan-2012 00:11:09 UTC] PHP 4. PHPUnit_TextUI_TestRunner->doRun() /usr/local/zend/share/pear/PHPUnit/TextUI/Command.php:188
[24-Jan-2012 00:11:09 UTC] PHP 5. PHP_CodeCoverage_Report_HTML->process() /usr/local/zend/share/pear/PHPUnit/TextUI/TestRunner.php:363
[24-Jan-2012 00:11:09 UTC] PHP 6. PHP_CodeCoverage->getSummary() /usr/local/zend/share/pear/PHP/CodeCoverage/Report/HTML.php:128
[24-Jan-2012 00:11:09 UTC] PHP 7. PHP_CodeCoverage->processUncoveredFilesFromWhitelist() /usr/local/zend/share/pear/PHP/CodeCoverage.php:354
Thanks!
Chris
The error means that /home/za/application/modules/proposal/views/helpers/FormSpecial.php is declaring a class named Zend_View_Helper_FormSpecial which is already declared by some other module--probably .../Zend/View/Helper/FormSpecial.php in the Zend Framework. If you intended to replace Zend's FormSpecial with your own, you need to give it a different class name.
The problem is that PHP_CodeCoverage will load every PHP file in the whitelist that hasn't already been loaded. If one of those modules defines a class with the same name, you get this error.