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
https://forums.phpfreaks.com/topic/109173-table-wont-create/
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
https://forums.phpfreaks.com/topic/109173-table-wont-create/#findComment-560563
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.