I keep getting this error:
Strict Standards: "Only variables should be passed by reference in
/home/mydirectory/public_html/myfolder/modules/checkout/controllers/myfile.php
on line 65"
This is the code on line 65:
$stmt->bind_param(
"iissds",
$this->auth->getInformation("id"),
$_POST["method"],
$transaction_id,
$Method->getTransactionID(),
$total_price,
serialize($_POST));
I did try editing my php.ini and inputting a code snippet to ignore these errors, to no avail, i may have goofed it up, as I'm fairly new to it..
If someone can show me how to strict proof it, that would be awesome! Thanks in advance
I'm guessing the
bind_param
function you are calling is mysqli's bind_param.If we have a look at the definition for this function we will see the variables are passed by reference:
(The
&
indicates by reference.)Now let's look at the error you are getting:
The problem is that you are passing the results of function calls directly to
bind_param
, when only variables should be passed by reference.To get around this all you need to do is assign these values to variables and pass those to the function instead, for example:
For more information on references take a look at the php.net article 'What References Do':
http://php.net/manual/en/language.references.whatdo.php
Hididng Errors
In your question you mention hiding these messages. It is always better to fix problems with your code than to suppress warnings.
To adjust what errors are displayed take a look at PHP's
error_reporting
function.If you wanted to show everything except strict you could do:
This can also be set in the php.ini configuration file: