if ($Funct == "BUILD" AND $Mode == "GROUND")
{
$sql = "SELECT * FROM $landCon WHERE North = '" . $North . "' AND West = '" . $West ."'" ;
$result = mysql_query($sql) or die("Error occurred in [$sql]: " . mysql_error());
$count = mysql_num_rows($result);
If ($Count == 0 )
{
$sql = "INSERT INTO $landCon (West,North,Type1) VALUES ($West,$North,'$Char')";
mysql_query($sql) or die("Error occurred in RootA as:[$sql]: " . mysql_error());
}
else
{
$result=mysql_query("UPDATE $landCon SET Type1= '$Char' WHERE North = $North AND West=$West") or die( "Database Error: ".mysql_error());
}
echo "SUCCESS";
}
它不是更新条目存在的位置,而是插入。我的意图是在已经存在指定的 $North
和 $South
条目时更新它,以便每个 map 网格只有一个北/南值。
最佳答案
$count = mysql_num_rows($result);
If ($Count == 0 )
是 $count
$Count
吗?
captcha:当你输入错误时自动初始化新变量的语言
关于php - 为什么我的 PHP/MySQL 是插入而不是更新?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15422169/