Creating a table from a variable... possible?

Is this coding actually possible? Obviously this is a registration form, and I want to create 1 table per user in a single database. Why? In the future I plan to implement mini-profiles, essentially a single user can have multiple profiles, but only one account.

[php]
$con = mysql_connect(“localhost”,“user”,“pass”);
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}

mysql_select_db(“reg_users”, $con);
$sql = “CREATE TABLE $_REQUEST[“username”];
(
playerID int NOT NULL AUTO_INCREMENT,
PRIMARY KEY(personID),
FirstName varchar(15),
)”;
[/php]

Yes you can create a table the way you want but you will need to check your syntax.

However, what you are proposing is not a good way of achieving what you want, it is very wasteful of database resources and could lead to some serious performance issues.

You would be better off with a users master table with one entry per user. You then have a profiles table which is linked on a one to may relationship with the users table. The user could then have many entries in the profiles table that are ‘joined’ to the users record in the master table in your sql syntax.

Sponsor our Newsletter | Privacy Policy | Terms of Service