1

この機能をリクエストすると

    //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」テストを実行することを考えると、これは問題にはなりません。

4

1 に答える 1

0

ご覧のとおり、関数内で使用される変数の値はありません。パラメータまたはグローバル変数から$userid、$ author、$titleなどの変数の値を設定する必要があります

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');
于 2012-03-23T16:05:38.413 に答える