Doubt about the error "Strict standards: Only variables should be passed by reference in"

3

To write some dates in the database in the desired format I'm doing this:

 mysqli_stmt_bind_param
    (
        $stmt,
        's',
        date("Y-m-d", strtotime($data))
    );

Or, to get the current day simply:

 mysqli_stmt_bind_param
    (
        $stmt,
        's',
        date("Y-m-d")
    );

However, although I write normally, I get this error ( notice )?:

  

Strict standards: Only variables should be passed by reference in line "5" // is in the date line ...

Is this wrong way to pass the value to the field? Which one is correct? What does this error mean?

    
asked by anonymous 22.10.2015 / 19:38

1 answer

3

Yes it is wrong, mysqli_stmt_bind_param expects the second (OO) or third (procedural) argument to be always a reference that means that it must be a variable and not the return of a function / method or value passed right.

The correct thing is to create a variable before calling mysqli_stmt_bind_param or searching by date for the database using the now() function or equivalent.

$data = date("Y-m-d");
mysqli_stmt_bind_param($stmt, 's', $data);
    
22.10.2015 / 19:40