well im not getting that error anymore, but heres the new one.
Heres the Error:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '123 char (41) ,)' at line 1
where 123 is first row. char is the type, and 41 is the length
and when i try to define one rows as being auto_increment i get this error;
Incorrect column specifier for column 'column name'
[php]
<?php
$host = "localhost"; //location of the mysql
$name = "michael"; //user name for logging into mysql
$pass = "engineer"; //password for logging into mysql
$TBname = "$_POST[TBname]"; //name of the table for Creation
$DBname = "$_POST[DBname]"; //name of the database for working in
$connect = mysql_connect($host, $name, $pass) or die(mysql_error());
mysql_select_db($DBname) or die(mysql_error());
$sql = "CREATE TABLE $TBname ("; //creates the table
for ($count = 0; $count < count($_POST[field]); $count++)
{
$sql .= $_POST[field][$count] . " " . $_POST[type][$count];
if ($_POST[auto_increment][$count] == "y")
{
$additional = "NOT NULL AUTO_INCREMENT";
}
else
{
$additional = "";
}
if ($_POST[primary][$count] == "y")
{
$additional .= ", primary key (" . $_POST[field][$count] . ")";
}
else
{
$additional = "";
}
if ($_POST[length][$count] != "")
{
$sql .= " (" .$_POST[length][$count] . ") $additional ,";
}
else
{
$sql .= " $additional ,";
}
}
// clean up the end of the string
$sql .= ")";
$result = mysql_query($sql, $connect) or die(mysql_error()); // execute the query
if ($result)
{
$msg = "<p>" . $TBname . "has been created</p>";
}
echo "Adding $TBname to $DBname ....Done<br />";
echo "Creating fields in $TBname ....Done<br />";
echo $msg . "<br />";
echo "<a href=\"http://localhost/dbadmin/db_management.php\">Return to Database Management</a>";
?>
[/php]