1
When adding bindParam() after preparing the query, you are giving an error in execute, which says the following:
Fatal error: Uncaught Error: Cannot pass Parameter 2 by Reference in C: xampp htdocs ffpedidos.com.br system admin queries ff_pedidos_confirmed queries.php:5 Stack trace: #0 C: xampp htdocs ffpedidos.com.br admin system ff_admin.php(324): include() #1 {main} thrown in C: xampp htdocs ffpedidos.com.br system admin queries ff_pedidos_confirmations_queries.php on line 5
select code is what follows below:
$sql_sel_pedidos = "SELECT pedidos.*, pedidos.valor_recebido AS valorRecebido, clientes.nome AS cliente, entregadores.nome AS entregador, administradores.nome AS administrador, funcionarios.nome AS funcionario, administradores_terceirizados.nome AS admTerceirizada FROM pedidos LEFT JOIN clientes ON clientes.id=pedidos.clientes_id_remetente LEFT JOIN funcionarios ON funcionarios.usuarios_id=pedidos.usuarios_id LEFT JOIN entregadores ON entregadores.id=pedidos.entregadores_id LEFT JOIN administradores ON administradores.usuarios_id=pedidos.usuarios_id LEFT JOIN administradores_terceirizados ON administradores_terceirizados.id = pedidos.administradores_terceirizados_id WHERE pedidos.status = :pedidos.status";
$sql_sel_pedidos_preparado = $conexaobd->prepare($sql_sel_pedidos);
$pedidoStatus = "2";
$sql_sel_pedidos_preparado -> bindParam(':pedidos.status', '2');
$sql_sel_pedidos_preparado ->execute();
remove the spaces in the bindParam instantiation and run
– Felipe Duarte
bindParam()
does not accept only variable values, the simple way to solve this is to exchange forbindValue()
. More details on: What is the difference between bindParam and bindValue?– rray
Are you using PDO or Mysqli?
– rray
right fixed the bindValue problem, but the following error appears now: Warning: Pdostatement::execute(): SQLSTATE[HY093]: Invalid Parameter number: Parameter was not defined in C:xampp htdocs ffpedidos.com.br system admin queries ff_pedidos_confirmed queries.php on line 6
– Gabriel Filippi
Your bind should only have letters or numbers in the change query:
:pedidos.status
for:status
do the same inbindvalue()
– rray
rray, thank you very much, it worked!
– Gabriel Filippi