我正在尝试对数据库进行简单的插入,但无法找到问题所在。如果有人能提供帮助那就太好了。我的代码:
if(isset($_POST['s1']))
{
$q1 = "INSERT INTO tienda (title,desc) VALUES ('$title', '$desc')";
mysql_query($q1) or die(mysql_error());
echo "<div class=alert fade in><b>Group added!</b></div>";
}
事情的一面:
<tr>
<b>Titulo</b>
<input type=text name=title value="<?=$aset['title']?>" size=50> <br>
</tr>
<tr>
<b>Descripcion</b>
<input type=text name=desc value="<?=$aset['desc']?>" size=50> <br>
</tr>
</div>
</div>
<tr>
<td> </td>
<td>
<input type=submit name=s1 value=Upload class="btn btn-primary">
错误:
You have an error in your SQL syntax; check the manual that corresponds
to your MariaDB server version for the right syntax to use near 'desc)
VALUES (' Title ', '1')' at line 1
答案 0 :(得分:3)
desc
是MySQL中的reserved keyword(描述的缩写,按语句的顺序使用)。尝试将其包含在反复出击中,如
$q1 = "INSERT INTO tienda (title,`desc`) VALUES ('$title', '$desc')";