Use double quotes.
$query = "CREATE TABLE $tablename..."
Using single quotes doesn't parse variable, doubles do.
BTW, making a table for each user doesn't sound like the best practice... You'd probably be better off having one table with a user_id column. Or a separate database for each user if you're worried about permissions.