1

i'm currently in the process of creating a PHP shopping cart but keep i'm stuck with the error "Strict Standards: Only variables should be passed by reference PHP Shopping Cart". I've researched the error, found many different explanations as to why this is happening. I can't seem to resolve the issue. Any help would be much appreciated. Please see my code below.

  $img=mysql_real_escape_string(end(explode('/',$_POST['img'])));
Edward Tattsyrup
  • 245
  • 1
  • 3
  • 15
  • 2
    Possible duplicate of [Strict Standards: Only variables should be passed by reference](http://stackoverflow.com/questions/2354609/strict-standards-only-variables-should-be-passed-by-reference) – Rajdeep Paul Dec 29 '15 at 18:59

1 Answers1

0

You need to break up your code instead of doing it all at once, like so:

$imgArr = explode('/',$_POST['img']);
$img = end($imgArr);
$imgEscaped = mysql_real_escape_string($img);

The reason why is that end() expects a variable to be passed by reference, and so you need to assign your explode() to an intermediate variable first.

devlin carnate
  • 8,309
  • 7
  • 48
  • 82