+ -
当前位置:首页 → 问答吧 → PHP+MYSQL数据库插入问题

PHP+MYSQL数据库插入问题

时间:2010-08-11

来源:互联网

我数据库中有一个表test但是我每次用插入类的时候 都插入不了 提示错误
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 'vlaues ('','456','')' at line 1
附上源码
class mysql{
         private $host;
         private $name;
         private $pass;
         private $table;
         private $ut;

         function __construct($host,$name,$pass,$table,$ut){
             $this->host=$host;
             $this->name=$name;
             $this->pass=$pass;
            $this->table=$table;
            $this->ut=$ut;
             $this->connect();
         }

         function connect(){
             $link=mysql_connect($this->host,$this->name,$this->pass) or die ($this->error());
            mysql_select_db($this->table,$link)or die("没有数据库".$this->table);
            mysql_query("SET NAMES '$this->ut'");
         }

         function query($v){
             return mysql_query($v);
         }

        function error(){
            return mysql_error();
        }
        function close(){
            return mysql_close();
        }
//====================================

        function fn_insert($table,$name,$val){
            $this->query("insert into $table ($name) vlaues ($val) ")or die ($this->error());


        }
     }
$db = new mysql('localhost','root','','by',"GBK");
$db->fn_insert('test','id,title,dates',"'','456',''");

作者: qinhan001   发布时间: 2010-08-11

哦,多谢楼主分享,支持一下!!!






阴阳冕网游之纵横天下 凡人修仙传异世邪君 很纯很暧昧 九鼎记 阳神 斗破苍穹 重生之官道 步步生莲 神墓 间客 大魔王星辰变 御医 长生界 快眼看书列表 陈二狗的妖孽人生猎国阴阳冕 凌天传说 七界传说 斗罗大陆 玄幻魔法 武侠修真  重生之官路商途  卡徒  近身保镖  寂灭天骄 三国之宅行天下 冠军传奇 超级成长 疯狂的硬盘 邪龙道 重生之衙内 混世小农民冒牌大英雄 英雄无敌之十二翼天使 从零开始 傲剑凌云 异界之最强老爸

作者: 面屋   发布时间: 2010-08-12

  

作者: zx68555   发布时间: 2010-08-12

$this->query("insert into $table ($name) vlaues ($val) ")or die ($this->error()); //有个单词写错了~~
$this->query("insert into $table ($name) values ($val) ")or die ($this->error());

作者: figo0505   发布时间: 2010-08-12