任何人都可以看到这段代码有什么问题,所有的文件权限都是正确的,但是当它运行时,我只是得到一个没有错误的空白屏幕。在我添加评论框和代码之前正在工作,以保存评论中的数据,但我发现它没有任何问题吗?
背景:存储在其中的http地址的QR码(例如(domain.com?t=Q8YH))使用PHP代码访问此网站,以跟踪和计算他们被跟踪的次数。
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
$tag = $_GET["t"];
$file = "tags/" . $tag . ".txt";
if (file_exists($file)) {
echo "<p>You found tag: <b>" . $tag . "</b></p>";
$f1 = fopen($file, 'r');
$number = fread($f1, 10);
fclose($f1);
if (isset($_COOKIE[$tag])) {
} else {
$f2 = fopen($file, 'w') or die("ERROR: Can't open file");
$newnumber = $number + 1;
fwrite($f2, $newnumber);
fclose($f2);
setcookie($tag, "TAG", time()+3);
$logfile = "tags/logs/" . date("Y.m.d");
$time = time();
$f3 = fopen($logfile, 'w') or die("ERROR: Can't open file");
fwrite($f3, "\nTag: " . $tag . " Time: " . $time);
fclose($f3);
}
echo "<p>This TAG has been found <b>" . $number . "</b> times before you.</p>";
if ($number == 0) {
echo "<p>You are the first to find this TAG!</p>";
if(!$_POST) {
echo "no post";
} else {
$comment = $_POST["comment"];
$commentfile = "tags/comments/" . $tag . ".txt";
$f4 = fopen($commentfile, 'w') or die("ERROR: Can't open file");
fwrite($f4, $comment . "\n\n\n\n");
fclose($f4);
echo "<br><br>First to find comment";
echo "<br><form action="index.php" method="post">Comment:<textarea type="text" name="comment" lenght="50" ROWS="10" COLS="50"></TEXTAREA><br><input type="submit" /></form>";
}
} else {
$filecomment = "tags/comments/" . $tag . ".txt";
if (file_exists($filecomment)) {
$f5 = fopen($filecomment, 'r');
$commentread = fread($f5, 10);
fclose($f5);
echo "<br><br>";
echo "First to Tag comment: " . $commentread;
}
}
}
?>
答案 0 :(得分:4)
echo "<br><form action="index.php"
您在双引号字符串中使用双引号。
即使您的帖子中的语法着色,您也可以发现它