Concatenation Create Table

0

I'm trying to create a table from the user's email, and I'm using the code below:

 $email = $_SESSION["email"];
 echo $email;
 $create=mysql_query("CREATE TABLE userpics_'$email' (id_user VARCHAR(60), id_pic VARCHAR(200), id_tipo INT(2))");
        if (mysql_query($create))
        {
         echo "TABLE created.";
        }
        else 
        {
         echo "Error in CREATE TABLE.";
        }

If the user is [email protected], the table name must be [email protected]. With this code, I get the message "Error in CREATE TABLE." according to the else. Can anyone tell me where I might be going wrong? Maybe it's some syntax error ...

    
asked by anonymous 21.04.2015 / 21:50

1 answer

2

Rewrite create by adding English quotes' between the table name. You can do this:

$create = mysql_query("CREATE TABLE 'userpics_".$email."'(  
                            'id_user' VARCHAR(60),
                            'id_pic' VARCHAR(200),
                            'id_tipo' INT(2)
                        );"
);
    
21.04.2015 / 22:10