所以我做了一个记分板系统,但是每当我的添加/更新代码块运行时,它都会给我一个解析错误:语法错误,包含 mysqli_query() 的行上的意外 T_VARIABLE; 如果它失败了,这是我的代码。
<form method="post" action="">
<center>
<font color="green">Your name Max length is 15</font>
<input type="text" name="username" maxlength="15">
<input type="submit" name="submit" value="Submit">
</center>
</form>
<font color='red'><center>
<?php
if (isset($_POST['username']))
{
$link = mysqli_connect("host","user","pass","db") or die("Error " . mysqli_error($link));
// $getname = $_POST['username'];
$getname = mysqli_real_escape_string($link,$_POST['username']);
$percentage = "10";
$querycheck = ("SELECT * from scoreboard where name = $getname")
$result = mysqli_query($link, $querycheck);
if (mysql_num_rows($querycheck) > 0)
{
$queryexist = ("UPDATE scoreboard set percentage = 20 where name = $getname");
$resultexist = mysqli_query($link, $queryexist);
echo "<center><font color='green' size='2'>Your score has been updated successfuly</font></center>";
}
else
{
$querydoesnt = ("INSERT INTO scoreboard (name,percent) VALUES ('$getname',$percentage)");
echo "<center><font color='green' size='2'>Your name has been added to the scoreboard successfuly </font></center>!";
}
?>
</font></center>
它给我一个错误,显然是说我的 mysqli_query 行有问题,虽然是第一个。