WordPress include wp-load.php --> Error 500 - php

Hello StackOverflow Community,
I have a problem, every time I try to require wp-load.php in my PHP Script (Outside of Wordpress), I will get a Error 500 (Internal Server Error), what I want to do is that https://stackoverflow.com/a/19677968/9544599, and it worked yestarday. If I remove
require_once($_SERVER['DOCUMENT_ROOT']."/wp-load.php");
I still get the Error, but if I remove
$string29 = wp_check_password($password, $array4['user_pass']);
and replace it with
$string29 = true;
it works. (It also gives out an Error if i remove just the Function).
And enabeling any of the Log options from PHP (display_errors, display_startup_errors, log_errors) and WP_DEBUG I still get only Error 500.
And everything on the first page of Google don't worked for me.
I hope somebody can help me.

I found an answer myself, but I'am not sure why that was the Error.
In the same PHP File, I have a funtion called discord($message) and maby the function was occupied. I have changed the Name of the funtion to discordmsg($message) and all worked.

Related

PHP Loading Blank Page

I recently moved my website from one server to another. My index.php file uses the smarty template system to load multiple pages based on the URL. However, one specific page is loading blank now.
I don't necessarily need help fixing any coding issue, I need help finding the error.
There's no PHP error that displays and the server doesn't give a 403, 404, 500, or any other error response that I can see. Can anyone offer suggestions on how to find what's causing the error?
Perhaps adding something to the PHP file to display every error or searching the server logs to see what's causing the error to occur. As of right now, I can't necessarily narrow it down to a specific file, much less a specific line. Any suggestions on what I should add or where I should look?
I'm open to adding whatever to the PHP file to trace the error, using command-line/shell to locate log files, using Perl to track down the error, and so on. Anything will be greatly appreciated!
EDIT 1: This is on a Linux/CentOS servers that's running cPanel/WHM.
EDIT 2: After following Tim's advice below, it appears that the error is coming from this line:
$app->map('/panel/ajax', $auth('member'), function () use ($app) {
Here's the line in a bit more context:
$app->flash('restore_panel_filters', '1');
$app->redirect($redirect);
})->via('GET','POST');
$app->map('/panel/ajax', $auth('member'), function () use ($app) {
$req = $app->request();
$user_id = $app->view()->getData('user_id');
Any idea what would be causing this to happen?

PHP script works on one server, gives me an Internal Server Error 500 on another [duplicate]

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
PHP call class in class returns error:500
I have code that looks somewhat like this:
<?php
include 'payTable.php';
session_start();
...
if ($_SESSION['fieldTen'] > 30)
{
$payTable = 'payTable';
$payTable::run();
}
?>
My permissions are set to 0644, so I don't think that's the issue, but I'm getting strange behavior on the server that I'm not getting in the local directory using XAMP.
Every time I try to load the page with this code on it, I get the "Internal Server Error: 500" error.
Can anyone tell me if there's something obviously wrong here? Something I'm missing.
I tried simply removing the PHP from this file and that causes the HTML part of it to appear without problems.
This is not legal syntax on PHP < 5.3.0, so you're getting a syntax error:
$payTable = 'payTable';
$payTable::run();
PHP (< 5.3.0) thinks $payTable is a string, so you can't use ::run() on it.
The solution would be just to ditch the variable altogether and call it directly:
payTable::run();
On a related note, turn on your error reporting. This will allow you to spot and fix errors easily rather than being left in the dark with a generic error. You can do this by editing php.ini (preferred), or add this to the top of your scripts:
error_reporting(E_ALL);
ini_set("display_errors","On");
It looks like you are trying to call a function of 'payTable', but payTable is not a class with any functions.
Additionally, you could be trying to set the session after some data has been output... possibly from the included file? this will throw an error, but likely not as severe as a 500.
500 just means the server hit a problem and couldn't continue. You need to check the error log for the web server (presumably apache?) to see what the actual problem was. Looking at the code, off the cuff guess could be the case of the included filename doesn't match the actual filename.

Yii - PHP error after content saying that LogDetailFilter couldn’t be found

Ok, I can't figure this one out for the life of me. I'm using Yii 1.1.8.
If I do this:
function actionEdit()
{
$this->render('//user/edit');
}
I get a PHP error after the content saying that LogDetailFilter couldn’t be found when it was trying to autoload it in Yiibase.php on line 421.
But if I do this:
function actionEdit()
{
$this->render('//user/edit');
die;
}
I have no problems. Any thoughts how I could fix this?
It's an error in your config file related to what / how you are logging things. Yii runs all of the Yii::log / Yii::trace calls after it has rendered content (using the onApplicationEnd event), which is why using die prevents your logging from having errors.
If you post your logging info, we can point out the exact spot if you need it

error_reporting(0) throws 500 error

So - strange situation I got here.
The statement error_reporting(0); has been giving me a server 500 error.
However, error_reporting(1); works just fine..
And its killing me, too many warnings for some of my URL validators. What's up with this? Any idea on how this can be fixed?
First of all, I'm sorry if I behave "smartass", but I have to tell you that if there are warnings, you should consider to fix them instead of just reduce them to silence... :)
Junk PHP code let bad things happen, and you won't like it. I understand 80% of the PHP code around is junk, but really try to fix that library, if it's not huge.
We can however try to solve the problem if you just make a simple .php file, with only one line:
<?php
error_reporting(0);
?>
and test if it fires the error. If it doesn't, the problem is not caused by error_reporting, but just triggered by it, and there's some sick stuff going on elsewhere. :)
try error_reporting(E_ALL); and ini_set("display_errors","On"); and check the errors that occur. After you fix those, there shouldn't be any problem.
Good luck
Shai.
P.S. i would be guessing for almost 100% that you use Chrome, because for some reason chrome would sometimes just show its own error screen instead of showing error messages. So also try another browser just to check the errors.
error_reporting()'s value is defined with constants, so don't use direct value to set it.
If you had used the constants, you would have noticed that none of them have 0 as value.
If you want to report all errors, there is an exception to the rule : use the value -1 :
error_reporting(-1);
Source : http://us.php.net/manual/en/function.error-reporting.php
And consider fixing all warnings! (and even notices if possible)
Note : the -1 value is used to be sure that even if more error code are added, they are all included.

Identifying a PHP problem that doesn't prints a ERROR and the code isn't yours

I've to make a website works and I don't know what to do right now. I can run it in a virtual machine with Ubuntu, on my company's server in Debian, on a WAMP... but I can't get it working in a server from a client.
I think the problem is with the gets. The form that I can't modify is sended by get, using the next url:
http://domain.com/SGAP/dades_proj_edit.php?idedit=2011854&id=&projectname=afsdfasdf&comptitle=asasfdafsdafs&codarea=ECIV&grauimp=1&codtipus=2&codsubtipus=6&subtipusdef=fdsaafasfddfs&codpais=8&clientid=2&promotor=asdfa&entfin=fsdafadsfds&impcontract=2&initdate=21%2F01%2F2011&findate=30%2F01%2F2011&uteflag=false&utepartic=&utepercent=0&descprelim=fdsadasdadfsadfs&codprojstatus=1&statusstamp=25%2F01%2F2011&cruserid=&action=update
Firefox shows a blanc page with no error. I've tried to force to show all errors with error_reporting(E_ALL) and ini_set("error_reporting", E_ALL) to show if something happens but the wait page is showed with 0 errors.
I supposed that was a $_GET error and I tried to put on the top of the page and in the end of it a <?php if($_GET["test"]) echo "Works"; ?> and call the webpage with: domain.com/SGAP/dades_proj.edit.php?test=testing and it works from top to end... I don't know where is the error.
What I can check to figure where is the white page comming? Thank you in advance!
Here's what I would do.
Start at the top of the file/stack, and add this code:
<?
$myUniqueCounter = 0;
error_log(++$myUniqueCounter . ', line ' . __LINE__ );
Then, copy and paste the error_log line all over the file/stack, and see where it stops logging.
I have occasionally seen php die without a blank output. Generally, the only way to solve this is to remove everything from the file, and then add code back in one line at a time. When it stops working, you know that whatever you just added caused the fault. You can try running php with the -l flag, to check the syntax, but this might not find the problem; the only sure way really is to just to add or remove things until the output changes.
I know this isn't much help, but there is no other way to debug the problem, short of executing php itself with a debugger... actually, you could do that; can you run php from gdb? That might help you find what is causing the issue, but no guarantees.

Categories