Author Topic: [SOLVED] Interpreting ‘$user_’ as a variable rather than ‘$user’.  (Read 259 times)

0 Members and 1 Guest are viewing this topic.

Offline cs.punkTopic starter

  • Enthusiast
  • Posts: 406
  • Gender: Male
  • Uhm er well...
    • View Profile
Ok guys, a naming problem.
Code: [Select]
$file_dir = "photos/originals/$user_$user_id_$file_count.jpg";
move_uploaded_file ($file_tmp, $file_dir);
 

I want a file like : ‘user_23_1.jpg’…? But it seems to be interpreting  ‘$user_’ as a variable rather than ‘$user’.

Thanks. :)
Life isn't just simply being alive... Or is it?

Offline papaface

  • Devotee
  • Posts: 1,435
  • I'll try to help :)
    • View Profile
Re: Interpreting ‘$user_’ as a variable rather than ‘$user’.
« Reply #1 on: July 04, 2009, 09:01:12 AM »
Code: [Select]
$file_dir = "photos/originals/".$user."_".$user_id."_".$file_count.".jpg";
The best web hosting at http://www.5ite.com!

Offline .josh

  • Administrator
  • 'Insane!'
  • *
  • Posts: 13,159
  • Grumpy Old Man
    • View Profile
Re: Interpreting ‘$user_’ as a variable rather than ‘$user’.
« Reply #2 on: July 04, 2009, 09:02:20 AM »
That's because _ is a valid char for a variable name.  Wrap your variable in braces

{$user}_...

Did I help you? Feeling generous? Donate to me! | Donate to phpfreaks!

Offline cs.punkTopic starter

  • Enthusiast
  • Posts: 406
  • Gender: Male
  • Uhm er well...
    • View Profile
Re: Interpreting ‘$user_’ as a variable rather than ‘$user’.
« Reply #3 on: July 05, 2009, 05:51:45 AM »
Thanks papaface and Crayon Violent! ;)
Life isn't just simply being alive... Or is it?