打不开数据库问题

#1 turing

用的speedphp最新代码,用的speedamp,数据库设置都没有问题,不知道什么原因的。。SELECT .* FROM
Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM' at line 1
  • D:\SpeedAMP\htdocs\SpeedPHP\Core\mysql.php on line 64
59.          if( $result = mysql_query($sql, $this->conn) ){
60.              return $result;
61.          }else{
62.              //dump(debug_backtrace());
63.              //die("{$sql}
Invalid query: " . mysql_error());
64.              spError("{$sql}
Invalid query: " . mysql_error());

65.          }
66.      }
67.
68.      /**
69.       * 获取数据表结构

  • D:\SpeedAMP\htdocs\SpeedPHP\Core\mysql.php on line 36
31.       *  
32.       * @param query
33.       */
34.      public function getArray($sql)
35.      {
36.          if( ! $result = $this->exec($sql) )return FALSE;

37.          if( ! mysql_num_rows($result) )return FALSE;
38.          $rows = array();
39.          while($rows[] = mysql_fetch_array($result,MYSQL_ASSOC)){}
40.          mysql_free_result($result);
41.          $this->arrSql[] = $sql;

  • D:\SpeedAMP\htdocs\SpeedPHP\Core\spModel.php on line 101
96.              if(null != $conditions)$where = "WHERE ".$conditions;
97.          }
98.          if(null != $sort)$sort = "ORDER BY {$sort}";
99.          if(null != $limit)$limit = "LIMIT {$limit}";
100.          $sql = "SELECT {$this->tbl_name}.{$fields} FROM {$this->tbl_name} {$where} {$sort} {$limit}";
101.          return $this->_db->getArray($sql);

102.      }
103.
104.      /**
105.       * 根据SQL查询记录
106.       */

  • D:\SpeedAMP\htdocs\controller\main.php on line 8
3. {   
4.      function index()
5.      { // 这里是首页   
6.          $tpl    = $this->spArgs("tpl", "white"); // 这里接收tpl参数,使得模板变化,后面的green是tpl为空时的默认值。  
7.          $user_info = spClass("user_info");   
8.          $this->results = $user_info->findAll(); // 用$this->results可以将$guestbook->findAll()的值发送到模板上面,模板上可以用$results来使用该值。   

9.          //$sql = "select* from user_info";  
10.          //$this->results = $user_info->query($sql);
11.          dump($this->results); // 格式化输出数组$args  
12.          $this->display("{$tpl}/index.html"); // 显示模板,这里使用的模板是根目录/tpl/green/index.html。           
13.      }   

  • D:\SpeedAMP\htdocs\SpeedPHP\SpeedPHP.php on line 91
86.
87. // 对路由进行自动执行相关操作
88. spLaunch("router_prefilter");
89.
90. // 执行用户代码
91. $handle_controller->$__action();

92.
93.
94. // 控制器程序运行完毕,进行模板的自动输出
95. if(FALSE != $GLOBALS['G_SP']['view']['auto_display']){
96.      $__tplname = $GLOBALS['G_SP']['view']['config']['template_dir']."/".

  • D:\SpeedAMP\htdocs\index.php on line 23
18.               'left_delimiter' => '<{',  // smarty���޶���   
19.               'right_delimiter' => '}>', // smarty���޶���   
20.              ),   
21.      ),   
22. );
23. require(SP_PATH."/SpeedPHP.php");

2010-05-01 09:08:29

#2 jake

你看看,user_info类的变量:$tbl_name(表全名)有没有赋值?值是否正确,如果没有赋值,看看$table和数据库配置中的表前缀是否正确?应该是user_info的table没有设置。
PS:请把这类帖子发到 求助问答,谢谢合作:handshake

2010-05-01 09:21:04

#3 turing

汗,的确是这个问题。支持speedphp,很看好这套框架。。

2010-05-01 13:48:48