Thursday, 22 August 2013

Invalid parameter number error

Invalid parameter number error

<?php
require_once 'database.php';
class Authorization extends Database {
public $vk_id;
public $eu_name;
public $eu_society;
public $eu_notes;
public $eu_want_team;
public function __construct() {
parent::__construct('144.76.6.45','5432','eu','eu','eu123');
$this->vk_id = $_POST['vk_id'];
$this->eu_name = $_POST['eu_name'];
$this->eu_society = $_POST['eu_society'];
$this->eu_notes = $_POST['eu_notes'];
$this->eu_want_team = $_POST['eu_want_team'];
}
function querySelect($query) {
$this->query = $query;
$this->STH = $this->DBH->prepare($this->query);
$this->STH->execute();
$this->STH->setFetchMode(PDO::FETCH_ASSOC);
}
function queryInsert($query) {
$this->query = $query;
$this->STH = $this->DBH->prepare($this->query);
$this->STH->bindParam(':vk_id', $this->vk_id);
$this->STH->bindParam(':eu_name', $this->eu_name);
$this->STH->bindParam(':eu_data', $this->eu_data);
$this->STH->bindParam(':eu_society', $this->eu_society);
$this->STH->bindParam(':eu_notes', $this->eu_notes);
$this->STH->bindParam(':eu_want_team', $this->eu_want_team);
$this->STH->execute();
}
}
try {
$auth = new Authorization();
$auth->queryInsert("INSERT INTO users (vk_id, eu_name, eu_data,
eu_society, eu_notes, eu_want_team) VALUES
(':vk_id',':eu_name',':eu_data',':eu_society',':eu_notes',':eu_want_team')");
echo "Ñîõðàíåíî";
} catch (PDOException $e) {
echo 'Ïîäêëþ÷åíèå íå óäàëîñü: ' . $e->getMessage();
}
Hey, I'm trying to do prepared statements query. but it tells:
Warning: PDOStatement::bindParam(): SQLSTATE[HY093]: Invalid parameter
number: :vk_id in /home/marker/entropia/components/authorization.php on
line 31
Warning: PDOStatement::bindParam(): SQLSTATE[HY093]: Invalid parameter
number: :eu_name in /home/marker/entropia/components/authorization.php on
line 32
Warning: PDOStatement::bindParam(): SQLSTATE[HY093]: Invalid parameter
number: :eu_society in /home/marker/entropia/components/authorization.php
on line 33
Warning: PDOStatement::bindParam(): SQLSTATE[HY093]: Invalid parameter
number: :eu_notes in /home/marker/entropia/components/authorization.php on
line 34
Warning: PDOStatement::bindParam(): SQLSTATE[HY093]: Invalid parameter
number: :eu_want_team in
/home/marker/entropia/components/authorization.php on line 35
Whats the problem?

No comments:

Post a Comment