0

I am trying to call the $_SESSION username variable so that It will show in a URL like

/users/USERNAME/

I know there's a way to do this, but I must be doing it wrong because here's the error I get: Parse error: syntax error,

unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or 
T_VARIABLE or T_NUM_STRING

What am I doing wrong to get this, and how can I fix it?

Here's the code I'm using:

move_uploaded_file( $_FILES['md']['tmp_name'], 
"users/'.$_SESSION['username'].".$_FILES['md']['name'] );
4

4 回答 4

6

错误的混合"'一个"缺失

    move_uploaded_file( $_FILES['md']['tmp_name'], "users/".$_SESSION['username']."/".$_FILES['md']['name'] );
于 2012-08-01T14:41:02.427 回答
1

你有一个解析错误。

"users/"

不是

"users/'
于 2012-08-01T14:41:26.590 回答
0

你没有在连接之前关闭你的字符串。

 move_uploaded_file( $_FILES['md']['tmp_name'], "users/" . $_SESSION['username'] . $_FILES['md']['name'] );
于 2012-08-01T14:41:58.663 回答
0

你的代码有错误,试试这个

 move_uploaded_file( $_FILES['md']['tmp_name'],"users/".$_SESSION['username'].$_FILES['md']['name'] );

或者

move_uploaded_file( $_FILES['md']['tmp_name'],"users/".$_SESSION['username']."/".$_FILES['md']['name'] );
于 2012-08-01T14:42:33.860 回答