Jump to content

Recommended Posts

Hey, this is a simple question. I searched the forum and the manuals and whatnot, and I'm sure its a simple answer, but I didn't find it anywhere. So if anyone had a free moment, I'd really appreciate it.

 

Essentially, my science fair project is making a web based personal password generator/manager. I want to be able to store passwords in a table.

 

I created a user with all privileges to a database called BetterPass. I successfully connected with that user to the BetterPass db.

 

Know I would like to create a table, which should be named whatever my username is.

 

Let $username = the desired username of the table.

 

$query = 'CREATE TABLE $username (
...
);

 

creates a database name "$username", not the actual username. The question then, how can I get that table to be named whatever $username points to, and not actually "$username"?

 

Thanks so much for your time!

Link to comment
https://forums.phpfreaks.com/topic/142275-solved-naming-table-with-user-input/
Share on other sites

single quotes do not parse variables.  Double quotes will.

 

$name = 'blah';
echo '$name'; // output: $name
echo "$name"; // output: blah

 

alternatively, you can jump in and out of the quotes to have php parse the var outside of the quote:

 

$name = 'mud';
echo 'my name is ' . $name . ' i am blue'; // output: my name is mud i am blue

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.