나는 파일을 쓰지 말고 주사위를 쓰지 않는 PHP 스크립트에 링크하는이 URL을 호출하는 자바 애플릿을 가지고 있습니다. HTTP 500 오류가 발생합니다. 어떤 단서?파일에 쓰기 및 파일 검색 PHP
$operation = $_REQUEST["operation"]
당신은 또한, 예를 들어, 몇 군데에 $
기호 누락
$operation = $_REQUEST["operation"];
해야합니다
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";
}
}
?>
그것은 당신이 "읽기"및 파일 이름이 다르다 "쓰기"하는 것을 목적인가? –
@Kolink'testsroce'는 합법적 인 소리 xD – TheZ
PHP 스크립트에서 표시되는 에러 메시지는 무엇입니까? 필요한 경우 오류 메시지를 켜십시오 .. –