php include_once not working in cacti on archlinux box - php

I had cacti installed on my ArchLinux box but I don't know after upgrading my system php include_once() has stopped working and it doesn't include files any more.
However if I replace include_once() with include() things start working again, but some files get included twice which causes some other issues.
I don't know how this problem can be fixed, I've almost tried everything but can't get it to work, can someone help me fixing this problem please.

There must be a error or something, because include and include_once do the same work, one repeats one doesn't.
So first try to use include_once to include a php file in a new file (check the permissions given to files). If there is any error, post it here.
If still you're having this problem, put the content of file you want to include it using include_once here and the file that includes that file.
(P.S.: If nothing helped, consider reviewing the php configuration files, or re-installing the PHP)

Related

include_once not working when using in shell script

I am running a php file using shell script like ./first.sh
In first.sh I am running a php file using following command
COMMAND="/usr/bin/php /home/mydirectory/public_html/members/cron/cron.php"
Under cron file I have this code
mail('myemail#gmail.com','fff','aaa');
include_once '/home/mydirectory/public_html/members/wp-config.php';
mail('myemail#gmail.com','fff1','aaa1');
when I am executing .sh file I am only getting first email and not getting second email. Below second email I have written some more coding to fetch wordpress posts but not working. And if I am hitting the cron.php in browser using domain url, it is working absolutely fine.
I have tested so many other stackoverflow answers but nothing is working for me.
Please help me.
If you examine wp-config.php (I suppose this is a WordPress configuration file), then at the ~bottom of the script you will see the line
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
Unfortunately, WP includes a "bootstrap" file directly into config... wp-settings.php includes many other wp files and initializes things etc. So, this must be debugged at Wordpress level. WP ends execution somewhere in wp-settings.php or other include file, so your php cron exits/dies.
Currently, I have not a local wp installation to debug (sorry), but I am 99% sure wp ends execution.
You can hardcode the info you need from wp-config like database host, username etc. into your cron.
Otherwise, you may parse the php file with token_get_all to retrieve the values (I had faced similar problem 2 years ago, unfortunately I have the code in old job office).
http://php.net/manual/en/function.token-get-all.php

PHP 5.5 -> 5.6: Include not working any more (Codeigniter)

I´m moving an application from a PHP 5.5 server to a PHP 5.6 server. The application is based on Codeigniter 2.2.
On the old server I had something like this in my views to include other template parts:
include('header.php');
This simple and direct include works like a charm on the old server.
On the new server I get the exception, that the file for inclusion could not be found.
I found out, that the PHP preprocessor tries to grab the file from the linux include paths and also from the "system/core" directory. But not from the directory where the view itself is located.
I´ve not idea what makes the difference between these two systems... Has anybody an idea where I can search for the issue?
Check the file path. Whether its inside some other folder or not.
Also can try with
$this->load->view('header.php');
or can load header in Controller as well
As well there are some useful keyword.
APPPATH - Outputs application path. Ex application/
Thanks guys for all your input - I´ve already tried most of these debugging attempts.
Now I digged a little deeper and found the reason for my problems. The short_open_tag directive in PHP caused the issue. Cause this new server had some slight differences in php.ini.
In core/loader.php Codeigniter tries to replace short open tags with normal tags, if the .ini setting for short_open_tags is disabled. For any reason this replacement isn´t working as expected and that caused my issues.
So if anyone has the same issue after moving a Codeigniter installation from one machine to another, that might be a point where you can start.
Thanks to all of you,
Michael

Php files show blank page

i have php 5.3.1 installed on apache2 in ubuntu 12.04 server .
my site was working fine untill last week when i found some of the files were missing and website was not showing.I uploaded site again on server and now when i browse any php pages it shows a blank page and also when i try to see the source code in browser for the blank page it dosnt show any source code.the html files are all showing up.
i dont think it is the server or appache2 probelm as i have other site with php on the same server working fine.
i checked with php files they are alrite.checked with the htacces.txt and that is same as the other working site on the same server.
can anyone here help what the problem could be.
thanks
Rida
Check error logs in /var/log/apache2/error.log
I got the same problem while installing a third party LAMP application and the cause was missing php5-mysql package.
Hope this helps others.
Sometime this white screen may occur because of the php page that is included by include() and include_once() functions, which may have some error or any syntax error that are not reported by the php server.
This happens because the included php page are executed first before the actual php page and if any error that is present in the included file occurs that suppresses the error catching then further php codes are not executed and a blank page is displayed.
First try to find that which dependent file has the problem by // toggling each include() or includ_once() one at a time.
After the culprit dependent file is found try to check it for the errors.
In my case this happened when I un-installed Zend using its uninstall.sh, I then needed to edit the Apache config /etc/apache2/sites-enabled/000-default.conf to remove any references to Zend Server. I did restart Apache, but restarting the whole machine helped to revive PHP bindings.
In my case I find out that the include_once() function which I put on the top of the page was the problem . I red the answer by Gaurav Kispotta , that is where I got the tip . so if you have the same problem first comment that out , maybe even the entire code depending on that include .
You should never ever use require_once or include_once.
It will burst your server memory.
Just go with include or require.
php is a server side language so viewing source from browser will not yield any result if the whole codes are surrounded by php tags. Download the files from the server using an ftp client and try to open in an editor to see if there are still codes in it.

Index.php doesn't work on VPS but other files do

I've got really interesting problem with my VPS.
I've already installed www server using this instructions set: http://wiki.debian.org/LaMp and everything looks fine, but index.php file doesn't work.
It's main file of whole service and it's contains some initializations and includes. When I add there some echo, it display correctly. It seems that include function doesn't work.
Phpmyadmin works fine, other php files works but no index.php. I'm pretty sure it's not problem with file because it works great on old hosting.
Any ideas? I've searched the net, reinstalled everything twice but still i don't have any solution and i'm starting to feel helpless. If you need some additional information - ask.
My main guess is, that it throws an error which is not displayed.
Try adding this to the top of your PHP file:
error_reporting(E_ALL);
ini_set('display_errors', '1');
that should show you all the errors.
alternatively, you can check your error-log

New line before header()

I'm working with a custom made Joomla script that generates an image from a blob in a database. However, when we moved it from an Apache server to an IIS server, the script is breaking.
Upon investigation, it seems that now, there is a line break that is getting appended before the header function is being run (when I comment out the image portion, and do an echo "test";, test gets printed on line 2 of the source code.
I've gone through the script over and over again, and through the many files in the component, and can't seem to find out where this new line is coming from. At all.
I've tried using ob_start() and many similar functions, but nothing seems to work.
I'm completely out of ideas, and don't know where to turn.
Is there a way to trace what files are being called in the page, perhaps? Any thoughts on further steps?
Look out for additional whitespace at the end of PHP files. If a PHP file ends in more than a single return after the last ?>, that stuff gets printed regardless of where the file is/was included. That is a common error source in larger PHP projects and would meet your symptoms.
(To circumvent this, some have started with a coding standard that prohibits the last ?> in their source files, which is perfectly legal PHP.)
Be careful, maybe it's an encoding problem. Open the file with vim under linux to see if there an ^M or something like that.

Categories