插入数据库未知错误
insert into database unknown error
我正在尝试对数据库进行简单的插入,但找不到问题所在。如果有人可以提供帮助,那就太好了。我的代码:
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
desc
是MySQL中的reserved keyword(描述的缩写,用在order by语句中)。尝试将其括在反引号中,例如
$q1 = "INSERT INTO tienda (title,`desc`) VALUES ('$title', '$desc')";
我正在尝试对数据库进行简单的插入,但找不到问题所在。如果有人可以提供帮助,那就太好了。我的代码:
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
desc
是MySQL中的reserved keyword(描述的缩写,用在order by语句中)。尝试将其括在反引号中,例如
$q1 = "INSERT INTO tienda (title,`desc`) VALUES ('$title', '$desc')";