I have developed a script but whenever i open admin panel it shows just a blank page, however the same script works fine on my another server. I tried changing chmod of files and folders 644, 755, 775 and 777 but still it outputs a blank page.
The main script works fine but its only admin panel thats not working. I check .htaccess also same on both servers.
Any idea what is wrong?
Thank You.
Check the error log of your HTTP server (e.g. Apache). In 99% of cases of a blank page, PHP has experienced a fatal error and exited before generating any output.
If this script works on another server, I'd check that the script can find everything it needs to include or require. Files not found are common fatal errors when moving a script from one environment to another. For instance, if you deployed the file to the new server without configuring the include_path correctly.
Re your comment about the notice you got:
Notice: Undefined index: submit in /var/www/admin/index.php on line 8
the function on line 8 is if($_POST['submit'] == 'Login')
This means your $_POST array does not contain a field 'submit'. Referencing a non-existant array index in PHP is an E_NOTICE. You can fix this in the following way:
if (array_key_exists('submit', $_POST) && $_POST['submit'] == 'Login')
put this at the top of your admin page
ini_set('display_errors',1);
error_reporting(E_ALL);
The servers probably have different things installed which is causing an error that you can see.
This may sound stupid, but seeing as you all you said was it "outputs a blank page", are you sure there's no output at all? Have you checked the page source, just in case? Remember that if your page starts with a bad HTML tag or something similar, there will be output but that doesn't mean anything is actually rendered in the browser.
Also make sure output buffering isn't on... I can't remember if this can cause issues when trying to debug, but who knows?
Related
So I am trying to get shell_exec to give me the response of the program, but it is not giving me any response when I put it into echo. I have tried rewriting the output variable without a input variable, and have tried to produce errors hoping the error would give me some sort of output, but still nothing. Here is the code I am having issues with
<?php
$key = $_GET['key'];
$output = shell_exec("node totp.js ".$key."");
echo "Your output is = $output";
?>
Thanks!
Edit:
I tried defining where node is /usr/bin/node and where the totp.js is /var/www/html/totp.js and it gives an error in my log: No such file or directory. I took off everything other than trying to execute node, and I get the same no such file error. When I go back to what I had to begin with, I now get an error that command is not found, which was not appearing before. Is there a way to allow PHP to roam outside of the execution folder, I.E. the htdocs/html folder?
Edit 2:
Tried changing permissions, chowning, discovered my PHP runs under the user apache, which now owns and has 755 permissions to my entire web folder, and now it recognizes the /usr/bin/node.... but it has no permissions. I have tried adding permissions in every possible way, I've tried giving it 777 although I knew I would not leave it at that, and it still has no permission to access it. I am clueless, and I guess this has become a linux issue rather than a php issue... lol - Also changing the title of the post as it is no longer a shell_exec issue, it is an issue with permissions
Edit 3: Something is royally wrong, it now gives 2 error messages. One is "No such file or directory" and the other is "Permission denied". It gives both, leading me to believe it is running on 2 seperate users/2 seperate locations. Idk what I should do, so I am going to reset my server as I have not done much, and start again. Saving the code first to see if that clears it up for me.
I have a WooCommerce website that has been created by other party. When I was editing a template file and checking a minor change, a PHP error appeared on top of the page (literally the first line in the document, above )
[12-Jun-2017 19:08:58 UTC] PHP Fatal error: Call to undefined function add_action() in /home/SITENAME/public_html/wp-content/themes/booklovers/widgets/top10.php on line 8
I do know what it means, but it appears that the error itself is not the issue. The time does not change, it constantly displays 19:08:58. I've also tried renaming/moving the file to see what happens - and nothing happens at all. It is being executed, because the page results with a white screen when I put exit; in it. Renaming made no difference. Checking this path by file_exists() called in index results with false. In my opinion it has something to do with Wordpress, because if I put exit; on top of the index.php the page is totally blank, without error, so it is not being merged with the response by Apache or something. Also setting the error reporting in index/config has no effect (I realize that this is generally a bad idea, and would not leave production with a workaround like this).
My guess is that the error might be some kind of a cached artifact. But this WooCommerce has no cache plugins installed so far... I have only a minor experience with Wordpress, I do know the basics, but debugging this type of issues is a terrible pain. I would appreciate any tips suggesting where should I look.
Additional information worth mentioning: shared hosting on GoDaddy (not my choice...), php 5.6.
Resolved. A theme's error_log file was being prepended to the response.
Hi I have got project where I have to do some changes, but then I do some changes in php files I can't see any changes in web browser, only then I deleted files, when I see error in windows, but if I comment all lines from same file, and want see changes, when I refreshed the page where will be page like before, what means I see page like normally, and if I download the file and open it I see commented lines.
So I am using YII framework, I understand that I should turn on debugging on, so in [project-name]/index.php file in the top I pasted code.
defined('YII_DEBUG') or define('YII_DEBUG',true);
But it didin't work for me, still can't see any changes.
I also try ctrl+f5 on page refresh.
Maybe I should look in to Apache configuration?
If some one know please help.
I believe that defined('YII_DEBUG') or define('YII_DEBUG',true); causes a debug dump to be sent to the screen when an exception is thrown. Without that code there will be a single line exception error.
I have a weird problem I cannot seem to solve (as a php noob).
I am working on simple php site (no sql involved). Everything was working perfectly till the moment I decided to copy over the files and edit them on another computer. All worked fine on the other computer as well. Then I took the files and copied them to the first computer again. Here came the problem: if I try to open ANY file copied from the second computer, it doesn't show anything, just a blank page. Even if the file was not edited at all on the second computer.
For example my index.php:
1. Copied from comp 1 to comp 2, no edits done
2. Copied from comp 2 to comp 1
3. Opened in the browser -> blank page
What's going on here and how to solve it? Is it some cache that apache is keeping? How to clear it? Both computers with OSX, however the second one was running MAMP, while the first had php/apache/sql set up.
Your permissions need to be set up correctly. Do the following:
Change the owner of the group to your user
chmod 0755 all the directories
chmod 0644 all the files
Then you are good to go!
You need to make sure that your permissions are set up correctly.
Apache Permissions
The blank page is displaying because Apache is encountering a PHP error somewhere, but is not set to display PHP errors.
Check out what is going on in your Apache error log and work from there. You could also look in the Developer Tools of a browser like Chrome, or use Firebug, to see what response your browser is getting from the server (most likely a HTTP 500 error).
I wouldn't recommend blindly changing ownership on files and directories until you know what is going on.
I have my index.php page and just afrer my header i want to include a message.php file.
This message.php file executes some mysql queries, runs a couple of functions and in the end makes echo of some text.
If i go to mysite.com/message.php - i can see all the text i need in my browser. But if i add the following line:
<?php include "message.php"; ?>
to my index.php, the page loads only until the include statement and then produces 500 internal server error. How is that even possible? I'm totaly stuck here...
EDIT: I've figured it out, thanks for pointing me to the right direction with apache logs. Even though i didn't have the log access, i've made the edit to .htaccess with a statement php_value error_log log.txt. It dumped the error in the txt file in the same directory. The error was produced by a function that was a name that was already in use. That's why a separate enviroment wasn't producing the error.
Add the following to the top of your message.php:
ini_set('display_errors',1);
error_reporting(E_ALL);
As everyone has said, there is probably a simple error (maybe a missed quotation mark) that is throwing the error, but in that environment, it gets thrown as a 500 error rather than output to the screen. Enabling the above should reveal the problem.
As dm03514 pointed out, it might be that there's something in your message.php which is breaking your code. If there's a fatal error in that file, it'll cause a similar error in your main file.
Ask support for your error_log - this really helps debugging.
This is possible becuase you have an error in your message.php file! The next step is to figure out what is throwing the error. You can look at your web servers error logs to see the exact line. To solve this problem you only have to focus on the code in your message.php file.
Well, if you don't have access to the log files, try to run the same file in any other environment where you can see the errors.
That's the only way available.
Asking strangers to tell you what error you have in your php file makes very little sense, you know ;)
Try to make a copy of index.php, say copy.php, insert a test.ph include, displaying just some "KILLROY WAS HERE".
If that does work, go for <?php echo "..."; ?>.
if that does not work, place the include elsewhere and/or remove code.
One cause could be a hidden redirect, blocked because output already happened.
More likely some global variable was shared.