【发布时间】:2014-04-19 20:45:24
【问题描述】:
我正在尝试从 php 存档更新我的数据库,但我不能: 在你问之前:来自 db 的名称写得正确,if 也有效......
<?php
if(isset($_GET["ans"]) && isset($_GET["name"]))
{
include("con.php");
$con = con();
$answer = $_GET["ans"];
$nam = $_GET["name"];
if($answer="firefly" ||$answer="Firefly" ||$answer="FIREFLY")
{
$le=2;
$sc=50;
$update = "UPDATE User SET Level='$le', Score='$sc' where Name = '$nam'";
mysql_query($update,$con);
// header("Location: lv1b.php?n=$nam");
}
else {
echo "try again..." ;
}
}
?>*
这是con.php...
<?php
function con()
{ $server="localhost"; $user="root"; $pass="";
$con= mysql_connect($server, $user,$pass);
mysql_select_db("games"); return $con;
}
【问题讨论】:
-
怎么不行?你得到什么错误?你做了什么来解决这个问题?您还对 SQL 注入和使用过时的 API 持开放态度。
-
它不会在 MySQL 上更新等级和分数...
-
你的 if 语句也有错误。
-
mysql_error() 说什么?
-
能不能得到
con();的包含内容