PHP code problems
Can anyone see whats wrong with this code, all the file permissions are correct but when it is run i just get a blank screen with no errors at all. Was working before i added the comments box and the code to save the data from the comment, but i can not find any thing wrong with it?
Background: QR codes with a http address stored in them such as (domain.com?t=Q8YH) go to this website with the PHP code to track and count how many times they have been tracked.
<?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.开发者_如何学Gom.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;
}
}
}
?>
echo "<br><form action="index.php"
You are using double quotes inside of double quoted string.
You can spot it even regarding syntax coloring in your post
精彩评论