0

ファイルに書き込む必要があるphpスクリプトにリンクするこのURLを呼び出すJavaアプレットがありますが、サイコロはありません。http 500 エラーが発生します。どんな手掛かり?

http://127.0.0.1/DBoperations.php?operation=write&UserId=james&Score=10

#DBoperations.php
<?php
$operation = $_REQUEST["operation"]
$UserId = $_REQUEST["Userid"];
$Score = $_REQUEST["Score"];

if (operation =="write"){
write();
}
if (operation =="read"){
read();
}

function write()
{
$myFile = "testsroce.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "$UserId - $Score";
fwrite($fh, $stringData);
fclose($fh);
}

function read()
{
$file = new SplFileObject('testscores.txt');
$file->setFlags(SplFileObject::DROP_NEW_LINES);
$match = false;
foreach($file as $line){
if( false !== stripos( $line, $UserId ) ){
    $match = true;
    break;
}
}
if( true === $match ){
echo $file;
} else {
echo "No Match Found";
}
}
?>
4

1 に答える 1

0

次の行の後にセミコロンがありません:

$operation = $_REQUEST["operation"]

する必要があります

$operation = $_REQUEST["operation"];

$また、いくつかの場所で標識が欠落しています。

if (operation =="write"){

次のようにする必要があります。

if ($operation =="write"){
于 2012-10-22T19:37:27.407 に答える