0

Hi all im currently updating a script and repairing it after a page full or errors most ive done through searching but im stuck on this on if anyone can help be much appreciated jan

PHP Notice: Only variables should be passed by reference on line 16

the piece of code for this is

if(isset($_POST['sub1']))
{
    //$fn   = date('U').$_FILES['userimage']['name'];
    $ext    = end(explode('.',$_FILES['userimage']['name'])); //THIS IS THE ERROR LINE//
    $fn     = date('U').".".$ext;
    $ft     = $_FILES['userimage']['type'];
    $fs     = $_FILES['userimage']['size'];
    $ftmp   = $_FILES['userimage']['tmp_name'];
    move_uploaded_file($ftmp, "images/user_images/$fn");
    $thumb  = new Thumbnail('images/user_images/'.$fn);
    $thumb->resize(100,100);
    $thumb->save('images/user_images/smallthumb/'.$fn);
    $thumb1 = new Thumbnail('images/user_images/'.$fn);
    $thumb1->resize(405,540);
    $thumb1->save('images/user_images/bigthumb/'.$fn);

    mysqli_query($conn,"update  user set user_image = '".$fn."' where user_id = '".$_SESSION['last_id']."'") or die(mysqli_error());
    $insert1 = mysqli_query($conn,"insert into user_images set user_id = '".$_SESSION['last_id']."', user_image = '".$fn."', main_image = '1' ") or die(mysqli_error());

    if($insert1)
    {

Edited by janicemurby

3
Contributors
2
Replies
25
Views
9 Months
Discussion Span
Last Post by ryantroop
0

My guess is that line 16 is fine and line 17 is the issue. Why not take the error/warning prima facie and use variables instead of strings in quotes?

2

The explode function does not return a value by reference.

Set the output of the explode to a variable, then pass the variable into the end() function.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.