CakePHP showing blank page - php

I have a website that is finished and uploaded, at first it works fine but after a while it stops working.
By stops working I mean whatever page I go to just shows a blank page, empty source.
In Chrome though, I get HTTP Error 500 (Internal Server Error)
To fix this all I need to do is change debug to 2, refresh and then change it back to 0.
I do not know what triggers this to happen, I have tried clearing the cache folders.
There are no log entries in /app/tmp/logs/error from the last week.
Any ideas would be great. Thanks.

In the end it was APC cache conflicts between multiple Cakes on the same server.
All I had to do was change $prefix in config.php and it worked.

Cakephp can show also blank page, if you have some component included in your controller and it contains error, and if for some reason debug does not work(though debug level in core.php is 2 or 3 ) in your component , it just shows blank page.

this post is getting old, but today I upload a new website to a server and get the blank page so I share my experience. I have no access to server logs so I was stuck. I was very confused because that server has running another sites with cakephp so I think the problem was mod_rewrite. After several ours of testing the problem was that the server's php version was too old to run cake 2.8.3. so I use an older version of cake and everything works fine. Hope this help someone.

Happened to me when I had a constant defined, did not notice this and defined another one with the same name.
const VISIBLE = 1;
const DELETED = 0;
const VISIBLE = 1;
A few years later I will add a comment here:
This would mean there was a syntax error, make sure u display these.

It might be due to white space in end of file
Please check your all files if white space is there after ‘?>’ tag it redirects it to blank page
or you can remove ‘?>’(closing php tag) to remove this problem.

In my case i had
public function appError($error) {}
on AppController which was supposed to redirect to a 404 page and i commented the redirect. this led to me having blank page.

In my case the problem was not the cache.
Enabling CakePHP debug should be useful. Change the value to
Configure::write('debug', 0);
to
Configure::write('debug', 1);
in app/cake/core.php
to show the real errors.

I had the exact same problem, it was the folder app/tmp/cache/models that didn't exist. After creating it, no more problem.

Related

Why is the browser returning 404 on an existing script?

I have to debug a wordpress site. The backend throws an 404 error on an existing file. (permissions checked, 777 on it did't help)
I can call the url in my browser, the script is shown, but the console still shows the 404 error.
The problem presumably exists since a redesign, where the previous template was copied and edited, but I did not touch the certain files. I can still call the script url from the previous template, it works fine.
The url where the error occurs is: https://sunball-tennis.de/wp-content/themes/sunball%20blue/assets/js/admin.js.php
I'd appreciate any help.
Update 1:
This is how the script is called:
<script type='text/javascript' src='https://www.sunball-tennis.de/wp-content/themes/sunball%20blue/assets/js/admin.js.php?ver=5.0.2'></script>
Update 2:
The call for the script is generated with this code:
wp_register_script('frontact_admin_js', get_bloginfo('template_url').'/assets/js/admin.js.php', array('jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-sortable', 'media-upload', 'thickbox', 'farbtastic', 'jquery-tools-tooltip', 'jquery-uniform'), false, true);
But as I said: It was exactly the same code and files in the previous template and it also still works when I activate the previous template, but not in the actual one. Driving me nuts.
All right I've found an answer. In the beginning of the admin.js.php script was a request for wp-blog-header.php which did not work for unknown reasons. Fixed it with adding
status_header(200);
nocache_headers();
after the request.
Got the solution from: https://wordpress.org/support/topic/integrating-wp-in-external-php-pages/?replies=22 and https://wordpress.stackexchange.com/questions/85384/mysterious-http-404-header-in-my-own-scripts
Cheers!

Wordpress "insert-php": php code from file not executing

I have a WP site, I installed Insert-PHP plugin. (I am really new to WP).
On a new page I wrote in the "text" tab:
[insert_php]
require_once(realpath($_SERVER["DOCUMENT_ROOT"]) ."/firstfolder/nextfolder/test-1.php");
[/insert_php]
Then, in "/firstfolder/nextfolder/test-1_1.php" I have:
<?php
print 'something';
?>
At first I had problems w/ require_once because the path wasn't good. Then I managed and the page was working fine, displaying the word "something" as content.
A few hours later it's not working anymore. If I write PHP code between [insert_php] tags it's doing fine, but if I do the same thing in "test-1.php" nothing happens. No errors or warnings, nothing, just a blank page.
I even tried to write code to force an error and nothing happened. I cleared the cache, I tried created another file w/ that code ... nothing. I intentionally misspelled the path in require_once and that did produce an error.
The only thing happened between the time the code was executing and now is that I installed a "Yoast SEO" plugin.
What could have possibly happen? :(
So, thank you very much for support :| that was great.
I must say that I did not solve the mystery. Maybe I did something wrong somewhere or there is an issue with the "Insert PHP" plugin.
I'll write here what solution I came up with, maybe someone in the future will find a similar problem.
I installed another plugin called "Include Me". I used that to enter the path to the needed php file and after that everything was fine.

Old Joomla site returns bool(false) in browser after server move

I have moved to a new server, and intend to update this old Joomla site to current version. Currently on Joomla 1.5.26
I initially had an installation/index.php redirect loop after removing the installation directory displaying a 404 error (configuration.php was writable and contained the correct information). In order to attempt to fix this error, I added:
var_dump(file_exists(JPATH_CONFIGURATION.DS.'configuration.php'));
to administrator/includes/define.php
and I changed lines 23 - 32 in administrator/framework.php
if (file_exists(JPATH_INSTALLATION.'/index.php')) {
header('Location: '.substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'index.php')).JPATH_INSTALLATION.'/index.php');
Now, the web page (www.chesterandcrick.com) is displaying bool(false) in the browser, and I can still access the administrator section.
I'm frustrated and confused now and I'd really appreciate any advice or suggestions that anyone has. Also happy to pay for a solution.
The var_dump() is returning the boolean. And as you have sent that to the browser you can no longer successfully execute a header() as output has been sent.
Remove the var_dump(file_exists(JPATH_CONFIGURATION.DS.'configuration.php')); and it may well start working again, assuming you completed the move correctly.
If you really need to see the output from the file_exists() write it to a file like this
$x = file_exists(JPATH_CONFIGURATION.DS.'configuration.php') ? 'Exists' : 'Does not exist';
file_put_content('debug.txt', $x);
Then you will not have written output to the browser, and check the result using FTP or whatever you use to see the web site directories.

CakePHP DebugKit / Plugins webroot not being found

I've installed CakePHP's debug kit but it's not loading correctly on my pages, its just a mess of text and arrays at the bottom of the page. My browser is saying that it's getting a 404 on:
/debug_kit/css/debug_toolbar.css
/debug_kit/js/jquery.js
/debug_kit/js/js_debug_toolbar.js
/debug_kit/img/cake.icon.png
...so it's not finding the webroots for plugins properly. I have directed my browser to these pages and other combinations i could think of (e.g: /debugkit/css... or /debug_kit/webroot...) but nothing is working.
From my google searches it seems like a problem that a few people have had but I haven't seen a solution yet.
I have removed the 'sql_dump' element from the bottom of the layout page and still nothing.
Any ideas?
Thanks
To anyone else having this problem:
It's not a direct solution, but sort of a little hack
copy the contents of app/Plugin/DebugKit/webroot
to a new folder app/webroot/debug_kit
The problem is that CakePHP is not seeing the Plugins webroot, but this will bypass this problem.
Firstly have you got the right version of DebugKit for the version of CakePHP that you are using?
Secondly have you included it in your $components (usually in the App Controller) ?
public $components = array(
'Session',
'Cookie',
'DebugKit.Toolbar'
);
Are you loading it in bootstrap? i.e. CakePlugin::load('DebugKit');
Lastly have you got Configure::write('debug', 2); in core.php?
When working it will appear as an icon top right of the screen.

URL problem on IIS, using PHP

I've developed an application, using LAMP, and everything works fine, after migrating over to IIS, some pages don't work correctly.
I have a service_edit.php, which carries over URL parameters from the previous page, e.g.:
service_edit.php?id=5&serv=22
After updating the record, the following variable should redirect the browser to:
$updateGoTo = "freelancer_details.php?id=" . $row_rsFreeLancer['freeid'] . "";
But the browser produces a HTTP 500 error with service_edit.php?id=5&serv=22 in the address bar.
If I use:
$updateGoTo = "freelancer_list.php;
Everything works fine.
Does anyone know what I'm doing wrong, or if there is a setting in IIS to get this to work?
EDIT
OK, getting a bit closer to the problem now...
I've found that on my LAMP server, after the record has been updated, the page goes back to the freelancer_details.php page, with the correct details displayed, however, the parameters from the previous page are carried over too.
The URL, instead of displaying:
freelancer_details.php?id=5
displays:
freelancer_details.php?id=&id=5&serv=22
How do I remove the URL parameters from the previous page, so the URL displays correctly, and therefore work on the IIS server?
I can't say specifically what the problem is from what you have here (it's hard to understand what you're saying without seeing the rest of the script), but I can almost guarantee that IIS isn't the problem. Most likely there is some confusion with the page you are trying to forward to - either it's not there, or not being forwarded properly.
Try doing this:
$updateGoTo = "freelancer_details.php?id=" . $row_rsFreeLancer['freeid'] . "";
echo("<a href='".$updateGoTo."'>Click Me</a>");
and try clicking. That will tell you if there is truly a page at that URL, or if it's off.
Also, how are you forwarding to the next page? Are you using header() or something else?
Edit
Hi,
What this means ?id=&id=5 is that instead of having $_GET['id'] available as 5, it will be an array with two values, one of which will be blank, and the other will be 5.
You need to figure out why the id is being added twice and fix that. Without code, I can't tell you much else.
If it is a DEV box, go in the IIS and/or IE and remove the "Friendly http error" that way, you should get a more verbose error message.

Categories