Unknown column 'xxx' in 'where clause'

问题分析:

字段不存在,一般提示为:#1054 - Unknown column 'xxx' in 'where clause'

解决办法:


一般在升级PHPWind论坛过程中,由数据库字段丢失造成。手动添加字段,或者检查程序的查询语句.可能报错的如风格\插件\新增的表字段等, 具体看报错的SQL语句,可以根据错误提示,用sql语句收到添加字段即可解决.
   
若您不熟悉手动操作,可以尝试重升级,或者参看教程"添加字段,执行SQL教程":phpwind.net/show_help.php?help_id=170">http://faq.phpwind.net/show_help.php?help_id=170.

部分出错实例罗列:

实例一、
Unknown column 'special' in 'field list' (1054)

解决方法:

方法1:

数据表pw_attach缺少字段special,类型是tinyint(3),进phpmyadmin添加一下就可以了

方法2:

也可以在数据库运行SQL

ALTER TABLE `pw_attachs` ADD `special` tinyint(3) UNSIGNED NOT NULL AFTER `needrvrc`;

方法3:

如果您不会操作数据库,也可以把这个文件(phpwind.net//upload/techzip/special.zip" target=_self>下载)放到论坛根目录下执行(即跟index.php
global.php这些文件放在一起,域名/special.php就可以执行了)

记得注意备分数据库,运行完请手动删除该文件


实例二、
Unknown column 'aid' in 'field list' ( 1054 )


缺少字段aid

phpmyadmin执行
ALTER TABLE `pw_forumdata` ADD `aid` smallint(6) UNSIGNED NOT NULL AFTER `top2`;

或者把该文件(phpwind.net//upload/techzip/aid.zip" target=_self>下载)放到论坛根目录下运行(域名/aid.php),运行完请手动删除


实例三、
Unknown column 'time' in 'field list' ( 1054 )


phpmyadmin执行
ALTER TABLE `pw_elements` ADD `time` int(10) UNSIGNED NOT NULL;

或者把该文件(phpwind.net//upload/techzip/time.zip" target=_self>下载)放到论坛根目录下执行一下(域名/time.php),然后手动删除即可


实例四、
Unknown column 'p.multiple' in 'field list' ( 1054 )

数据库缺少字段 multiple ,可以phpmyadmin执行以下SQL语句
ALTER TABLE `pw_polls` ADD `multiple` tinyint(1) UNSIGNED NOT NULL;

也可以把该文件(phpwind.net/upload/techzip/multiple.zip" target=_self>下载)放到根目录下运行(域名/multiple.php)即可,运行完请手动删除


实例五、
Unknown column 'p.mostvotes' in 'field list' ( 1054 )


phpmyadmin中执行以下sql语句
ALTER TABLE `pw_polls` ADD `mostvotes` smallint(6) UNSIGNED NOT NULL;

或者把该文件(phpwind.net/upload/techzip/mostvotes.zip" target=_self>下载)放到根目录下运行下(域名/mostvotes.php) 运行成功后记得手动删除该文件

实例六、
Unknown column 'p.voters' in 'field list'

phpmyadmin中执行以下sql语句
ALTER TABLE `pw_polls` ADD `voters` mediumint(8) UNSIGNED NOT NULL
或者把该文件(phpwind.net/upload/techzip/voters.zip" target=_self>下载)放到根目录下运行下(域名/voters.php) 运行成功后记得手动删除该文件

阅读更多

Unknown column 'info.title' in 'where clause' 和 空指针异常

05-30

我是做搜索的功能时候出现空指针异常rn错误信息:rnrnselect info.id informationid, info.purpose, info.title, info.content, info.price, info.phone, info.QQ, info.contact, info.valid, info.keywords, info.rdate, info.categoryid , c.id categoryid, c.name cname, c.descr cdescr, c.pid, c.cno, c.grade from information info join category c on (info.categoryid = c.id) where info.title like '%3%' or info.content like '%3%' order by info.rdate desc limit 0,2rnjava.sql.SQLException: Unknown column 'info.title' in 'where clause'rn at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2975)rn at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1600)rn at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1695)rn at com.mysql.jdbc.Connection.execSQL(Connection.java:2998)rn at com.mysql.jdbc.Connection.execSQL(Connection.java:2927)rn at com.mysql.jdbc.Statement.executeQuery(Statement.java:956)rn at com.xagcdx.fleamarket.util.DB.getResultSet(DB.java:61)rn at com.xagcdx.fleamarket.information.InformationMySQLDAO.find(InformationMySQLDAO.java:268)rn at com.xagcdx.fleamarket.information.InformationMgr.find(InformationMgr.java:65)rn at org.apache.jsp.admin.SearchResult_jsp._jspService(SearchResult_jsp.java:68)rn at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)rn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)rn at com.xagcdx.fleamarket.util.filter.AuthFilter.doFilter(AuthFilter.java:34)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)rn at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)rn at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)rn at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)rn at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)rn at java.lang.Thread.run(Thread.java:619)rn2009-5-28 13:28:11 org.apache.catalina.core.StandardWrapperValve invokern严重: Servlet.service() for servlet jsp threw exceptionrnjava.lang.NullPointerExceptionrn at com.xagcdx.fleamarket.information.InformationMySQLDAO.find(InformationMySQLDAO.java:272)rn at com.xagcdx.fleamarket.information.InformationMgr.find(InformationMgr.java:65)rn at org.apache.jsp.admin.SearchResult_jsp._jspService(SearchResult_jsp.java:68)rn at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)rn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)rn at com.xagcdx.fleamarket.util.filter.AuthFilter.doFilter(AuthFilter.java:34)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)rn at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)rn at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)rn at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)rn at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)rn at java.lang.Thread.run(Thread.java:619)rnrnrn错误信息中出现错误的行:rnrnInformationMySQLDAO.java:rnrn public int find(List informations, int pageNo, int pageSize, String queryStr) rn int totalRecords = -1;rn Connection conn = DB.getConn();rn Statement stmt = DB.getStatement(conn);rn rn String sql = "";rn sql = "select info.id informationid, info.purpose, info.title, info.content, info.price, " +rn "info.phone, info.QQ, info.contact, info.valid, info.keywords, info.rdate, info.categoryid ," +rn " c.id categoryid, c.name cname, c.descr cdescr, c.pid, c.cno, c.grade " +rn " from information info join category c on (info.categoryid = c.id)" + queryStr + rn " order by info.rdate desc";rn rn sql += " limit " + (pageNo - 1) * pageSize + "," + pageSize;rn System.out.println(sql); rn rn ResultSet rs = DB.getResultSet(stmt, sql);rn rn Statement stmtCount = DB.getStatement(conn);rn [color=#FF0000]ResultSet rsCount = DB.getResultSet(stmtCount, //268行[/color] "select count(*) from information " + queryStr.replaceAll("p\\.", ""));rn rn try rn [color=#FF0000]rsCount.next(); //272行[/color]rn totalRecords = rsCount.getInt(1);rn rn ...... rn catch (SQLException e) rn e.printStackTrace();rn finally rn DB.close(rsCount);rn DB.close(stmtCount);rn DB.close(stmt);rn DB.close(rs);rn DB.close(conn);rn rnrn return totalRecords;rn rn rnrnrnInformationMgr.java:65:rnrn public int find(List informations, int pageNo, int pageSize, String keyword) rn String queryStr = " where info.keywords like '%" + keyword + "%' or info.content like '%" + keyword + "%'"; rn [color=#FF0000]return dao.find(informations, pageNo, pageSize, queryStr);//65行[/color]

没有更多推荐了,返回首页