Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php wordpress-提交评论时获得空白页_Php_Wordpress_Comments - Fatal编程技术网

Php wordpress-提交评论时获得空白页

Php wordpress-提交评论时获得空白页,php,wordpress,comments,Php,Wordpress,Comments,在functions.php中,我有以下内容: add_action('comment_post', 'comment_posted'); function comment_posted() { $MyClass = new MyClass(); //if I comment this line out the problem goes away } 评论发布成功,但浏览者被困在一个带有url的白色页面上,如下所示: http://mydomain.com/wp-comments-p

在functions.php中,我有以下内容:

add_action('comment_post', 'comment_posted');

function comment_posted() {
    $MyClass = new MyClass(); //if I comment this line out the problem goes away
}
评论发布成功,但浏览者被困在一个带有url的白色页面上,如下所示:

http://mydomain.com/wp-comments-post.php#comment-33
在firebug中我可以看到:405方法是不允许的

我需要在MyClass php文件中进行调用,所以我需要在其中进行调用。我在函数中使用这个类.PHP,所以我不明白为什么它会导致这种情况下的空白屏幕。

编辑-MyClass构造函数:

public function __construct()
    {
        $this->someVar='abc';
        mysql_connect("localhost", "dbname", "pwd");
        mysql_select_db("somedb");

    }

无论是否是Wordpress,处理PHP时出现的空白屏幕通常是PHP错误的标志。有你?您是否看到任何错误消息

你说你注释掉了构造器中的行,它就工作了。这导致我倾向于数据库连接问题。或者,可能是没有类字段,someVar


看看这些东西,然后在这里报告。我会尽我所能提供帮助。

在Firebug中,你能看到使用什么HTTP方法发布评论吗?获取、发布、发布等…您有多少评论被标记为垃圾邮件?如果有加载尝试删除它们,则会出现一个清晰的垃圾邮件按钮。请参阅POST wp-comments-POST.php并获取wp-comments-POST.phpcomment-33 MyClass的构造函数做什么?Votey-当我注释掉MyClass构造函数中的3行时,它会工作!问题是我需要这三条线。在上面添加了它们。感谢您的帮助。MyClass肯定没有问题,它用于其他函数。打开errors会给我这样的提示:警告:无法修改标题信息-标题已经由/home1/path/wp content/themes/mytheme/functions中启动的输出发送。php:210之前有什么吗?该错误通常是在写入页面的另一个PHP错误之后发生的,这是消息头已经发送的原因。你能发布这两个文件吗?实际上我刚刚清除了一个关于未定义变量的php警告。现在我没有收到任何警告。我仍然得到空白页,而且注释仍然正确地发布,我必须点击后退按钮来查看ItReST注释构造函数中的每一行,一次一个从底部开始,看哪一个抛出空白页。