1
我得到以下錯誤:錯誤:您的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>"
$ citytable1 = mysql_query($ citytable); $ sql =「INSERT INTO $ citytable1 VALUES('','$ citypost')」; 授予: 錯誤:您的SQL語法有錯誤;檢查與您的MySQL服務器版本對應的手冊,在第1行的'VALUES('','Almelo')'附近使用正確的語法。 因此,可以解決部分錯誤! – TdeLange
嘗試在'die'行中輸出查詢以及錯誤。然後你會看到它有什麼問題。 – pilotcam
搜索3天后,我發現它的SQL: $ sql =「INSERT INTO $ citytable1 VALUES(默認,'$ citypost')」; – TdeLange