0

For some reason, I can only select data from a table but I can't insert.

I.e. function nee() works fine, but wee() doesn't... It was working earlier today... anyone know the reason?

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();
3
  • Why are you using prepared statements without parameters? What the point? Also the $this->db = new Store_Connection(); smells like bad code. Commented Jun 30, 2012 at 18:00
  • why are you doing this $this->db = new Store_Connection(); $this->db = $this->db->dbStore(); Commented Jun 30, 2012 at 18:00
  • i just wrote this to check if it worked so I didn't use parameters. I followed a youtube video, and they did $this->db this way. Commented Jun 30, 2012 at 18:29

2 Answers 2

2

try like this

$st = $this->db->prepare("insert into sales(paid) values ('sdf')");
Sign up to request clarification or add additional context in comments.

Comments

1

whats sdf? is it a text/string, then use ' around it

Comments