0

我得到错误Unknown column 'first.' in 'field list'。我有一个名为“try”的数据库,一个名为“first”的表,其中包含字段“id(int)”和“name(char)”。它只是我用来在网格中显示其数据的示例表,但出现此错误。我已经编辑了这些默认的 html 和 ajax 文件,如下所示:

索引.php

<!DOCTYPE html>


<link rel="stylesheet" href="bootstrap/css/bootstrap.css"/>

<link rel="stylesheet" href="grid.css" title="openJsGrid"/>
<!--<link rel="stylesheet" href="jquery-ui/css/smoothness/jquery-ui-                          1.8.22.custom.css"/>-->
<script src="jquery.js" type="text/javascript"></script>
<!--<script src="jquery-ui/js/jquery-ui-1.8.22.custom.min.js" type="text/javascript">   </script>-->
<script src="root.js"></script>
<script src="grid.js"></script>

<script >
$(function() {
$(".users").grid();
});

</script>

</head>
<body>
<h2>Users</h2>
<table class="grid users" action="ajax.php">
    <tr>
                        <th col="id" type="text">ID</th>
        <th col="name" type="text">Name</th>
    </tr>
</table>

</body>

ajax.php

<?php
// connect to db
mysql_connect("localhost","root","");
mysql_select_db("try");

// require our class
require_once("grid.php");
$grid = new Grid("first", array(
"save"=>true,
"delete"=>true
 ));

 ?>
4

1 回答 1

0

我最近通过调用辅助 php 变量遇到了这个问题,我忘记了一个单引号。我的一个脚本指向我的数据库中名为 - 字面意思 -> .field 的字段

检查主要和辅助脚本中“第一”一词周围的引号。寻找类似的东西

<textarea> ' . $first. (MISSING A ' HERE) </textarea>

它应该是

<textarea>  ' . $first . '  </textarea>
于 2013-07-03T04:56:47.007 回答