i have a java applet that calls this url that links to a php script that SHOULD write to file but...no dice. i get a http 500 error. Any clue?
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";
}
}
?>
You are missing a semicolon after this line:
$operation = $_REQUEST["operation"]
Should be
$operation = $_REQUEST["operation"];
You are also missing a $
sign in a few places, e.g.
if (operation =="write"){
Should be:
if ($operation =="write"){