Okay im working with a mysql database here. In my php file i have this code with the $compname having some text value that has been posted from another page: Code: $sql = 'CREATE TABLE `$compname` (' . ' `Name` VARCHAR(25) NOT NULL, ' . ' `Sail Number` VARCHAR(7) NOT NULL, ' . ' `Class` VARCHAR(20) NOT NULL, ' . ' `Position` VARCHAR(3) NOT NULL' . ' )' . ' TYPE = myisam'; it just creates a table with the name "$compname" and i want it to have the name of what is assigned to "$compname". Any ideas? Thanx Will
Put the value in doule quotes - " " not ' '. Anything in double quotes is evaluted so your varialbe $copname will come out to be the name of the table. Using single quotes treats it literally so you're just using $copname instead of evaluating the variable. Solution: Code: $sql = "CREATE TABLE `$compname` ( `Name` VARCHAR(25) NOT NULL, `Sail Number` VARCHAR(7) NOT NULL, `Class` VARCHAR(20) NOT NULL, `Position` VARCHAR(3) NOT NULL ) TYPE = myisam";