1
What is the error of this code?
( ! ) Parse error: syntax error, Unexpected '$obj' (T_VARIABLE), expecting Function (T_FUNCTION) in C: wamp www php index.php on line 53
<?php
class Aluga {
public $nome;
public $snome;
public $cpf;
public $rg;
public $tel;
public $email;
public $status;
public $datainicio;
public $datafim;
public $qntpessoas;
function __construct($nome,$snome,$cpf,$rg,$tel,$email,$datainicio,$datafim,$qntpessoas){
$this->nome = $nome;
$this->snome = $snome;
$this->cpf = $cpf;
$this->rg = $rg;
$this->tel = $tel;
$this->email = $email;
$this->status = 0;
$this->datainicio = $datainicio;
$this->datafim = $datafim;
$this->qntpessoas = $qntpessoas;
}
function enviarDados(){
$sql = 'INSERT INTO `alugueis`(`nome`, `snome`, `cpf`, `rg`, `tel`, `email`, `status`, `datainicio`, `datafim`, `qntpessoas`) VALUES (?,?,?,?,?,?,?,?,?,?)';
$pdo = new PDO("mysql:host=localhost;dbname=test;","root", "");
$stmt = $pdo->prepare($sql);
$stmt->bindValue(1, $this->nome);
$stmt->bindValue(2, $this->snome);
$stmt->bindValue(3, $this->cpf);
$stmt->bindValue(4, $this->rg);
$stmt->bindValue(5, $this->tel);
$stmt->bindValue(6, $this->email);
$stmt->bindValue(7, $this->status);
$stmt->bindValue(8, $this->datainicio);
$stmt->bindValue(9, $this->datafim);
$stmt->bindValue(10, $this->qntpessoas);
$stmt->execute();
}
$obj = new Aluga("1","2","3","4","5","7","8","9","10");
$obj->enviarDados();
?>
vlw msm xDD am well Noob that kk' I was so focused on the "$obj" that I ended up n looking if something was missing
– mrlucasrib
@Lucas Acontece . If possible mark the answer as accepted. =)
– stderr
Marked :) But Aki, can you tell me have any risk of sql Injection in this code? : P
– mrlucasrib
@Lucas The risk will always have, but using PDO already greatly decreases the possibilities. Take a look too in this question =)
– stderr