所以我试图做一个简单的 MySQL 数据库/表更新,但有些东西不起作用,我不知道是什么。我会放代码:
morepoints.php(处理加分):
<?php
if(!isset($_COOKIE["name"]))
{
echo "<a href='index.php'>Username/points cookie not existent! Please login!</a>";
}
$con=mysql_connect("sqlserverip","name","password");
if(!$con)
{
echo "Error while connecting to the MySQL server: " . mysql_error();
}
mysql_select_db("gendb1",$con);
$name=$_COOKIE["name"];
$pts=$_COOKIE["points"];
mysql_query("UPDATE \"users\" SET \"pts\" =\"" . $pts . "\" WHERE name=\"" . $name . "\"");
echo "<div id='wrapper'>Updated database...checking if values match...</div>";
$result=mysql_query("SELECT * FROM users");
while($row=mysql_fetch_array($result)
{
if($row["name"]==$name)
{
if($row["pts"]==$pts)
{
echo "<a href=\"index.php\">Points awarded! Please login again.</a>";
mysql_close($con);
}
}
}
?>
如果你想要设置 cookie 的登录页面,这里是
<?php
$con=mysql_connect("mysqlserverip","name","password");
if(!$con)
{
echo "Connection to the MySQL server failed successfuly! " . mysql_error();
}
mysql_select_db("gendb1",$con);
$result=mysql_query("SELECT * FROM users");
//Getting Login Form Data
$name=$_POST['u'];
$pass=$_POST['p'];
$points;
//$valid=1;
if($name=="" or $pass=="")
{
echo "<div id=\"wrapper\">Name/pass cannot be blank. <a href=\"javascript:history.go(-1)\">Try again</a></div>";
}
while($row=mysql_fetch_array($result))
{
if($row['name']==$name and $row['pass']==$pass)
{
setcookie("name",$row['name'],time()+300);
setcookie("points",$row['pts'],time()+300);
echo "<div id=\"wrapper\">Login successful! <a href=\"user.php\">Go to your page</a></div>";
goto done;
break;
}
}
echo "<script>history.go(-1);</script>";
done:
?>
已解决:我得到的是 HTTP 错误 500.0 - 带有错误代码的内部服务器错误:0x00000000 我通常会在由于我的脚本中的一些错误而无法解释(或其他)PHP 代码时得到它:数据库/表没有更新(当我运行脚本时没有抛出错误,但数据库似乎没有更新)