how to run a previous with parameter in php

Asked

Viewed 335 times

0

I need to run a precedent by sending a parameter by php no longer returning follows the code below:

//código em PHP
$figura =  mysqli_query($conexao,"CALL `spare_change`.`boxlabel`('".$template."')") or die("erro no update");

//A Procedure Criada
CREATE DEFINER=`root`@`%` PROCEDURE `boxlabel`(template varchar(20))
BEGIN

-- update prom.label_template set label_tpl_content = replace(label_tpl_content, ' eJz', 'eJz') where label_tpl_name = @template;
select * from prom.label_template where label_tpl_name = @template;

END

where is the error in the code?

1 answer

0

You can run a query before to set a variable for the past, and then use that variable in the call.

mysqli_query($conexao, "SET @template = '" . $template . "'");
$figura =  mysqli_query($conexao,"CALL `spare_change`.`boxlabel`(@template)") or die("erro no update");

But beyond that, in the process itself, the -- is causing the update be just a comment line.

Try removing the -- from the beginning of this line, otherwise this code will not be executed.

-- update prom.label_template set label_tpl_content = replace(label_tpl_content, ' eJz', 'eJz') where label_tpl_name = @template;
  • this precedent executes an update with a Where of this parameter plus the update returns without affecting the lines and outside the precedent works

  • The update in the past is commented, -- at the beginning of a command is a comment.

  • yes in the code is commented more what I am running does not run the Precedent more does not change the lines

  • Have you tried removing the --?

  • yes I have removed yes

Browser other questions tagged

You are not signed in. Login or sign up in order to post.