【发布时间】:2018-05-19 22:25:45
【问题描述】:
错误
警告:odbc_exec():SQL 错误:[Microsoft][ODBC Microsoft Access Driver] INSERT INTO 语句中的语法错误。,E:\DEP\Prog\PHP6\starcraft\starcraft\personnage_traitement 中 SQLExecDirect 中的 SQL 状态 37000。第 61 行的 php [Microsoft][ODBC Microsoft Access Driver] INSERT INTO 语句中的语法错误。
使用 Ajouter 操作时的 SQL 查询(英文添加)
$nom =$_POST["nom"];
$faction = $_POST["faction"];
$age = $_POST["age"];
$race = $_POST["race"];
$description = $_POST["description"];
$fichier = $_POST["image"];
if ($_POST["action"] == "Ajouter") {
$sql="Insert into personnage (nom, faction, race, age, description, image) values ('$nom', $faction, $race, $age,'$description', '$fichier')";
odbc_exec($odbc, $sql) or die(odbc_error($odbc));
我的代码
<fieldset>
<legend>New hero</legend>
<label for="nom">Nom : </label><input type="text" name="nom" id="nom" size="40" required><br>
<label for="age">Âge : </label><input type="number" name="age" id="age" size="40" required><br>
<label for="race">Race : </label><select name="race" id="race" size="1" >
<?php
$sql2 = "SELECT NomRace FROM Race;";
$resultat2 = odbc_exec($odbc, $sql2) or die(odbc_error($odbc));
odbc_fetch_row($resultat2, 0);
while (odbc_fetch_row($resultat2)) {
$idS = odbc_result($resultat2, "IDRace");
$race = utf8_encode(odbc_result($resultat2, "NomRace"));
echo "<OPTION VALUE=\"$idS\">$race</OPTION>";
}
?>
</select> <a href="race.php">Édition des races</a><br>
<label for="faction">Faction : </label><select name="faction" id="faction" size="1" >
<?php
$sql3 = "SELECT NomFaction FROM Faction;";
$resultat3 = odbc_exec($odbc, $sql3) or die(odbc_error($odbc));
odbc_fetch_row($resultat3, 0);
while (odbc_fetch_row($resultat3)) {
$idS = odbc_result($resultat3, "IDFaction");
$faction = utf8_encode(odbc_result($resultat3, "NomFaction"));
echo "<OPTION VALUE=\"$idS\">$faction</OPTION>";
}
?>
</select> <a href="faction.php">Édition des factions</a><br>
<label for="description">Description : </label><input type="text" name="description" id="description" size="40" required>
<br>
<br>
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
<label for="fichier">Fichier d'image : </label>
<input type="file" onchange="readURL(this);" name="fichier" id="fichier">
<img alt="Image" id="preview" title="image" src="#" />
<br>
<br>
<input type="submit" name="action" value="Ajouter">
</fieldset>
【问题讨论】:
-
你的sql查询完全错误
-
oups 忘记了我的部分代码:抱歉!第一次在这个网站上提问!
-
编辑您的问题并添加您忘记的代码。将帮助每个人正确理解您的问题。
-
MySQL和SQL Server是不同公司生产的不同软件包。即使它们都实现了 SQL,它们也以不同的方式扩展它,有时它们使用不同的语法约定,从而使查询在它们之间不兼容。请仅使用与您正在使用的软件匹配的标签。
-
好主意!
标签: php html mysql sql sql-server