0

I am recieving the following error

Strict Standards: Only variables should be passed by reference in C:\wamp\www\dragdrop\newhotel\reservation\ajax\tips.php on line 8

Line 8 is

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

I'm a newbie please help me..

Toby Allen
  • 10,997
  • 11
  • 73
  • 124
  • You can edit your question rather than adding a comment, but thanks for the comment – Toby Allen Mar 11 '13 at 10:55
  • 2
    I think [basename](http://php.net/basename) would suit you better – Touki Mar 11 '13 at 10:55
  • 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) – Lorenz Meyer Jun 21 '14 at 08:34

2 Answers2

1

Explode is a function so you can't pass it to end. Use an intermediate variable.

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

Should work

Toby Allen
  • 10,997
  • 11
  • 73
  • 124
  • You should give me an upvote as thanks, and when you can if it works select my answer as the accpeted answer by clicking the tick under the score. – Toby Allen Mar 11 '13 at 10:59
0

You are not passing a variable, you are passing an array directly.

http://php.net/manual/de/function.end.php

$var = explode('/',$_POST['img']);
$var = end($var);
$img = mysql_real_escape_string($var);
Zim84
  • 3,404
  • 2
  • 35
  • 40