Welcome Guest, Not a member yet? Register   Sign In
query binding is not working correctly
#1

[eluser]jstuardo[/eluser]
Hello,

I have problems with query bindings. First of all, I have this code to insert data:

Code:
$sql = 'insert into inscrito (fecha_inscripcion, eve_id, rut, dv, nombres, apellidos, edad, email, telefono)
        values (now(), ?, ?, ?, ?, ?, ?, ?, ?)';
$this->db->query($sql, array($evento, $rut, $dv, $nombres, $apellidos, $edad, $telefono));

When I run the code, this is the query which was actually executed:

Code:
insert into inscrito (fecha_inscripcion, eve_id, rut, dv, nombres, apellidos, edad, email, telefono) values (now(), '1', '11727935', '9', 'Jaime', 'Stuardo', '38', '2493766',

Why the "comma" is appended to the end instead of the "parenthesis"?

Is there another way to insert a datetime into a database field? I think the problem occurs because of now() and $this->db->insert does not seem to work when I have to pass NOW() as the parameter.

Thanks
Jaime
#2

[eluser]TheFuzzy0ne[/eluser]
Because you're query is expecting another parameter (You have 8 ?s and only 7 bindings).




Theme © iAndrew 2016 - Forum software by © MyBB