PHP初心者です。
下記コードのエラーの出所が分からず、スタックしています。
エラーコードはParse error: syntax error, unexpected '}' in /Applications/****/php_test/reg.php on line 48です。
どうぞよろしくお願い致します。
<コード>
<html> <head><!-- 削除 --> <hr> <form action="reg.php" method="post"> No:<br> <input type="text" name="delno"/><br> Password:<br? <input type="password" name="pass" value=""/><br> <input type="submit" name="del" value="Delete"/> </form> <?php if(isset($_POST['del'])) { if(sha1($_POST['pass']) == $PassWord) { if(isset($_POST['delno'])) { $_POST['delno'] = htmlspecialchars($_POST['delno'], ENT_QUOTES); $Lines = file($FileName); if(isset($Lines)) { $i = 0; foreach($Lines as $Ln) { $Items[$i++] = explode("\t", $Ln); } if(isset($Items)) { $Tmp = 0; for($i=0;$i<count($Items);$i++) { if(isset($Items[$i][0])) { if($_POST['delno'] != $Item[$i][0]) { $Remain[$Tmp++] = $Lines[$i]; } else { $DelPhotoFilePath = $Items[$i][2]; } } } if(isset($Remain) && isset($DelPhotoFilePath)) { $fp = fopen($FileName, "w"); flock($fp, LOCK_EX); foreach($Remain as $Rm) { fputs($fp, $Rm); } flock($fp, LOCK_UN); fclose($fp); unlink($DelPhotoFilePath); } } } } } } ?></head> <body> <form action="reg.php" method="post" enctype="multipart/form-data"> Photo:<br> <input type="file" name="imgpath"/><br> Mention:<br> <textarea name="mention"></textarea><br> Password:<br> <input type="password"name="pass" value=""/><br> <input type="submit" name="up" value="send"/> </form> <?php //画像フォルダ名 $ImgDir = "photo"; //テキストファイル名 $FileName = "string.txt"; //パスワード $PassWord = "f5ad9d45c05a96057b00a80e678f7ecf7ddbdba3"; if(isset($_POST['up'])) { if(sha1($_POST['pass']) == $PassWord) { $No = mGetNo(); if(isset($_FILES['imgpath'])) { $_FILES['imgpath']['name'] = htmlspecialchars($_FILES['imgpath']['name'], ENT_QUOTES); $_FILES['imgpath']['tmp_name'] = htmlspecialchars($_FILES['imgpath']['tmp_name'], ENT_QUOTES); if(!empty($_FILES['imgpath']['name'])) { $ImgSize = @getimagesize($_FILES['imgpath']['tmp_name']); if(!isset($ImgSize['mime']) || !isset($ImgSize[0]) || !isset($ImgSize[1])) { print "This is not a photo"; exit; } $FilePath = $ImgDir . '/' . $_FILES['imgpath']['name']; $FilePath = str_replace("\t", "  ", $FilePath); move_uploaded_file($_FILES['imgpath']['tmp_name'], $FilePath); } else { $FilePath = ""; } } else { $FilePath = ""; } if(isset($_POST['mention'])) { $Mention = htmlspecialchars($_POST['mention'], ENT_QUOTES); $Mention = str_replace("\t", " ", $Mention); $Mention = str_replace("\r\n", "<br>", $Mention); $Mention = str_replace("\r", "<br>", $Mention); $Mention = str_replace("\n", "<br>", $Mention); } else { $Mention = ""; } if(!empty($Mention) || !empty($FilePath)) { //データを形成する $Data = "$No\t$Mention\t$FilePath\t\n"; //過去のデータの上に挿入する //テキストファイルを読み込む $Lines = file($FileName); if(isset($Lines)) { array_unshift($Lines,$Data); } else { $Lines = array(); $Lines[0] = $Data; } $fp = fopen($FileName, "w"); flock($fp, LOCK_EX); foreach($Lines as $Ln) { fputs($fp, $Ln); } flock($fp, LOCK_UN); fclose($fp); } } } function mGetNo() { global $FileName; $Lines = file($FileName); if(isset($Lines)) { if(isset($Lines[0])) { $Item = explode("\t", $Lines[0]); } } //初期値 $Number = 0; if(isset($Items)) { if(is_numeric($Items[0])) { $Number = $Items[0] + 1; } } return $Number; } ?>
</html></body>
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
2015/03/18 07:16