Inicio
Buscar
Ingresar
Registrarse
Starfield: el juego que revolucionará el espacio y la tecnología
Hack x Crack - Comunidad de Seguridad informática
»
Programación
»
Programación Web
»
Invalid parameter number: number of bound variables does not match number of tok
Imprimir
Páginas: [
1
]
Ir Abajo
Autor
Tema: Invalid parameter number: number of bound variables does not match number of tok (Leído 5994 veces)
caronte
{ L0 } Ñuub
Mensajes: 33
Invalid parameter number: number of bound variables does not match number of tok
«
en:
Diciembre 26, 2015, 11:48:40 pm »
Hola a todos!
DEspues de dejarme la neurona no me queda mas remedio que acudir al foro.
Esta es una funcion perteneciente a una clase:
Código: PHP
public
function
inserta
(
)
{
$sql
=
"insert into "
.
$this
->
tabla
.
"("
.
$this
->
columnas
.
") values ("
.
$this
->
parametrosValues
.
")"
;
if
(
$this
->
stmt
=
$this
->
pdo
->
prepare
(
$sql
)
)
{
foreach
(
$this
->
valores
as
$v
)
{
$this
->
stmt
->
bindParam
(
$this
->
indexBindParam
,
$v
)
;
if
(
$this
->
stmt
->
execute
(
)
)
{
echo
'Datos insertados correctamente'
;
$this
->
indexBindParam
++;
}
else
{
echo
"ERROR: No fue posible ejecutar
$sql
. "
.
print_r
(
$this
->
pdo
->
errorInfo
(
)
)
;
}
}
}
else
{
echo
"ERROR: No fué posible preparar la consulta:
$sql
"
.
print_r
(
$pdo
->
errorInfo
(
)
)
;
}
}
..y aqui esta la forma de declarar las propiedades:
Código: PHP
$db
=
new
operacionesDB
;
$db
->
base_de_datos
=
'uploader'
;
$db
->
host
=
'localhost'
;
$db
->
usuario
=
'-----'
;
$db
->
clave
=
'------'
;
$db
->
tabla
=
'archivos'
;
$db
->
columnas
=
'nombre, ruta, extension, fecha, hora'
;
$db
->
parametrosValues
=
'?, ?, ?, ?, ?'
;
$db
->
valores
=
array
(
$archivo
,
$ruta_destino
,
$extension
,
$fecha
,
$hora
)
;
$db
->
conecta
(
)
;
$db
->
inserta
(
)
;
y este es el error:
PHP Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens.
Alguien me puede dar una mano¿?
En línea
mrobles
Aburrido por naturaleza
{ L4 } Geek
Mensajes: 509
me caes mal ¬¬
Re:Invalid parameter number: number of bound variables does not match number of tok
«
Respuesta #1 en:
Diciembre 27, 2015, 12:57:55 am »
Comprueba lo que mandas a ala consulta, porque lo que falla es algún parámetro de mas
En línea
caronte
{ L0 } Ñuub
Mensajes: 33
Re:Invalid parameter number: number of bound variables does not match number of tok
«
Respuesta #2 en:
Diciembre 27, 2015, 09:49:10 pm »
Los parametros estaban bien.
Ya esta solucionado. Y aunque haya recontruido la clase por otro motivo, el error era no entrecomillar los VALUES en la consulta.
Si, de novato, lo se. Pero es que lo soy.
Gracias igualmente.
En línea
Imprimir
Páginas: [
1
]
Ir Arriba
Hack x Crack - Comunidad de Seguridad informática
»
Programación
»
Programación Web
»
Invalid parameter number: number of bound variables does not match number of tok
Va un mudo y le dice a un sordo: Hack x Crack usa cookies. Pues eso...
OK
Learn more