If you define a function within a closure you have to define the function first. Just move the function declaration one line above the function call. Example:
function calcular_termino_electricidad($cups,$fecha_inicio,$fecha_fin)
{
// ...
}
$electricidad=calcular_termino_electricidad($cups,$fecha1,$fecha2);
Now Im getting error of PHP Fatal error: Using $this when not in object context and im think it is because above my function i have $sth->execute() and inside my function I have this
I’m not 100% sure I understand but if you’re function is defined before or outside of your closure, you can probably pass “$this” as an argument, right? Just a guess on my part. YMMV.
I suggest you to dump $this so you can really understand what $this is inside closure,
than take your direction.
you don’t need to move your function inside closure
best practice
use the container
use “use()” statement on closure to pass function.
hth
So I changed to this. $rfechas=mysqli_query($sqlfechas); and I am getting a response from my code, but getting this errors PHP Warning: mysqli_query() expects at least 2 parameters, 1 given and
PHP Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, null given
and i am getting error 1, question is now (I know nothing about PHP haha) i am getting echo error 1 because my query doesnt find any data, or because i am not given the mysqli_connect params to mysqli_query and mysqli_fetch_rows?