Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我的Insert语句有什么问题?_Php_Mysql - Fatal编程技术网

Php 我的Insert语句有什么问题?

Php 我的Insert语句有什么问题?,php,mysql,Php,Mysql,由于某些原因,我只能从表中选择数据,但无法插入 也就是说,函数nee()可以正常工作,但wee()不能。。。今天早些时候它还在工作。。。有人知道原因吗 Class wtf{ private $db; public function __construct(){ $this->db = new Store_Connection(); $this->db = $this->db->dbStore(); } pu

由于某些原因,我只能从表中选择数据,但无法插入

也就是说,函数
nee()
可以正常工作,但
wee()
不能。。。今天早些时候它还在工作。。。有人知道原因吗

Class wtf{
    private $db;
    public function __construct(){
        $this->db = new Store_Connection();
        $this->db = $this->db->dbStore();
    }

    public function nee(){
        $st = $this->db->prepare("select paid from sales where id=14");
        $st->execute();
        $product = $st->fetch(PDO::FETCH_OBJ);
        print_r($product);
    }

    public function wee(){
        $st = $this->db->prepare("insert into sales(paid) values (sdf)");
        $st->execute();

    }

}

$work = new wtf();
$work->wee();

什么是自卫队?它是一个文本/字符串,然后在它周围使用'sdf'?如果是文本/字符串,请在其周围使用'

$st = $this->db->prepare("insert into sales(paid) values ('sdf')");
像这样试试

$st = $this->db->prepare("insert into sales(paid) values ('sdf')");

为什么要使用没有参数的准备语句?什么意思?还有
$this->db=newstore_Connection()闻起来像是坏代码。你为什么要这样做$this->db=$this->db->dbStore()我写这个只是为了检查它是否有效,所以我没有使用参数。我跟踪了一段youtube视频,他们这样做了$this->db。为什么要使用没有参数的预处理语句?什么意思?还有
$this->db=newstore_Connection()闻起来像是坏代码。你为什么要这样做$this->db=$this->db->dbStore()我写这个只是为了检查它是否有效,所以我没有使用参数。我跟踪了一段youtube视频,他们这样做了$this->db。