非常奇怪,未知的内部服务器错误原因

时间:2012-01-19 00:06:39

标签: php mysql function internal-server-error

当我请求此功能时

    //Add the content to the database
function articleadd() {
    mysql_query("INSERT INTO site_content (title,content,reference,author,userid,authorip,day,month,year,token) VALUES ('$title','$articlebody','$reference','$author','$userid','$ipaddress','$day','$month','$year','$token')");
}

由于某种未知原因,它会产生内部服务器错误。老实说,我不明白为什么,我在下面请求这个功能,它工作正常

    //Add a message if the user is not logged in
function message() {
mysql_query("INSERT INTO messages (from,to,subject,content,type,ip) VALUES ('$userid','$userid','The content $title is pending completion.','A article was attempted to be saved, however when the we tried to saved it there was no-one logged in. As a result we saved the article but quarantined it so it will not show on the website. To correct this error, please click the link below, review the article and confirm it should display on the site. <a href=$url>$url</a>','$type','$ipaddress')");

}

我和他们一个接一个地请求他们如下

    articleadd()
    message()

我有,在不起作用的函数中用非常简单的

替换了所有的mysql查询
    echo "hello world";

然而我收到了错误。

我试过复制和粘贴“功能”这个词,以确保我没有犯下愚蠢的错误。遗憾的是,我无法访问我的托管服务提供商的服务器日志。最后我知道我没有传递变量,这是一个单独的问题,但是基于一个人使用变量和“hello world”测试,这不是问题。

1 个答案:

答案 0 :(得分:0)

正如我所看到的,函数内部使用的变量没有值。 您需要设置变量的值,如$ userid,$ author,$参数或全局变量

function articleadd($title,$articlebody,$reference,$author,$userid,$ipaddress,$day,$month,$year,$token) {
mysql_query("INSERT INTO site_content (title,content,reference,author,userid,authorip,day,month,year,token) VALUES ('$title','$articlebody','$reference','$author','$userid','$ipaddress','$day','$month','$year','$token')");}

并像这样调用函数

articleadd('title','articlebody','reference','author','userid','ipaddress','day','month','year','token');