Jump to content

Table wont create


BrianM

Recommended Posts

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);
}
?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?)

Link to comment
Share on other sites

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.