我收到以下错误:错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 'country FROM countries WHERE idcountry=4 VALUES ('','Almelo')' 附近使用正确的语法
提前感谢您帮助我解决这个问题,因为我现在尝试修复它 3 天。
我通过 $POST 从我的表单中获取 2 个数据。这是表格:
form action="inc/add/addcity.php" method="post">
Select country:
$query="SELECT idcountry,country FROM countries ORDER BY country ASC";
$result = mysql_query ($query);
echo "<select name='countrybox' id='countrybox' value=''>Country</option>";
while($nt=mysql_fetch_array($result)){
echo "<option value=$nt[idcountry]>$nt[country]</option>";}
echo "</select>";<br>
City to add: <input type="text" name="addcity" id="addcity"/>
<input type="submit" name="sumit" value"sumit"/>
</form>
选项值来自我的数据库现在操作 php 文件
include 'addmysql.php';
$data = $_POST;
$citypost = $data['addcity'];
$cityselected = $data['countrybox'];
$cityselected1 = "SELECT country FROM countries WHERE idcountry=$cityselected";
$citytable = "cities";
$citytable .= "$cityselected1";
$sql= "INSERT INTO $citytable VALUES ('','$citypost')";
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
echo "<script type='text/javascript'>window.location='../../add.php'; </script>"