BrianM Posted June 7, 2008 Share Posted June 7, 2008 Why wont this work, it worked just fine when I used just one field and without underscores. It creates the database, but now it wont create the table. :| <?php if (isset($_POST['finish'])) { // basic setup variables $site_name = $_POST['site_name']; $site_url = $_POST['site_url']; $administration_username = $_POST['administration_username']; $administration_password = $_POST['administration_password']; // mysql setup variables $mysql_server_name = $_POST['mysql_server_name']; $mysql_username = $_POST['mysql_username']; $mysql_password = $_POST['mysql_password']; $mysql_database_name = $_POST['mysql_database_name']; $mysql_table_prefix = $_POST['mysql_table_prefix']; $mysql_connect = mysql_connect("$mysql_server_name", "$mysql_username", "$mysql_password") or die(mysql_error()); mysql_query("CREATE DATABASE $mysql_database_name", $mysql_connect) or die(mysql_error()); mysql_select_db("$mysql_database_name", $mysql_connect); $create_setup = "CREATE TABLE ".$mysql_table_prefix."setup ( site_name tinytext not null, site_url tinytext not null, mysql_server_name tinytext not null, mysql_username tinytext not null, mysql_password tinytext not null, mysql_database_name tinytext not null, mysql_table_prefix tinytext not null, PRIMARY KEY(site_name) )"; mysql_query($create_setup, $mysql_connect); mysql_close($mysql_connect); } ?> Quote Link to comment Share on other sites More sharing options...
BrianM Posted June 7, 2008 Author Share Posted June 7, 2008 Well I've managed to narrow it down through trial and error, it's the PRIMARY KEY which is throwing it off resulting in no table being created. Does anyone see anything wrong with my table structure, especially the PRIMARY KEY? Quote Link to comment Share on other sites More sharing options...
BrianM Posted June 7, 2008 Author Share Posted June 7, 2008 When I set mysql_error() I get -- BLOB column 'site_name' used in key specification without a key length What does that mean and how is this fixed? :| Quote Link to comment Share on other sites More sharing options...
Barand Posted June 8, 2008 Share Posted June 8, 2008 If you want an index on site name and it's a TEXT field then you must specify the number of characters of the field to index on (otherwise the key length is 32000 chars) PRIMARY KEY (sitename(50)) or just make the sitename a varchar field. In fact, text fields look like overkill for all your data (who will remember a passwords thousands of chars long?) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.