我的代码有问题。当我发布一些东西时,它会显示:
SCREAM:忽略错误抑制
注意:未定义的变量:后缀在...
但是我已经在我的代码中定义了我的变量......那么我该如何解决这个错误呢?
<?php
$conn = mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("test", $conn);
$time = time();
if(isset($_POST['pateikti'])) {
if(empty($_POST['tekstas'])) { echo "Tekstas per trumpas!"; }
else {
mysql_query("INSERT INTO tsp (timestamp, text) VALUES ('".time()."', '$_POST[tekstas]')");
}
}
$query = mysql_query("SELECT * FROM tsp");
while($row = mysql_fetch_assoc($query)) {
$diff = $time - $row['timestamp'];
switch(1) {
case ($diff < 60):
$ago = $diff;
if($ago == 0)
$ago == "akimirką";
else if($diff < 10)
$suffix = "sekundes";
else
$suffix = "sekundžių";
break;
}
echo $row['text']." buvo parasytas prieš ".$diff." ".$suffix."</br>";
}
?>
<form action="" method="POST" >
<input type="text" name="tekstas" /><br>
<input type="submit" name="pateikti" value="Pateikti" />
</form>
预先感谢您帮助我!