(I was trying to create a new table with 4 fields to store userids and passwords. I used the same script successfully to create a different table and am confused why it is not working this time.)
Error message:
"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 '(20),username text (10),password varchar (10))' at line 1"
A separate question:
What is the meaning of the "." on each end of the ".$_POST[field_length][$i]." ?
Here's the relevant part of the script:
<?php
$sql = "create table $_POST[table_name] (";
//to create the fields you specified in Step 2
//create loop to populate the remainer of the sql statement
for ($i =0;$i < count($_POST[field_name]); $i++) {
$sql .= $_POST[field_name][$i]." ".$_POST[field_type][$i];
if ($_POST[field_length][$i] != "") {
$sql .= " (".$_POST[field_length][$i]."),";
} else {
$sql .= ",";
}
}
$sql = substr($sql, 0, -1);
//close the SQL statement
$sql .= ")";
$conn = mysql_connect("localhost", "userid", "password") or die(mysql_error());
$db = mysql_select_db ("aroDB", $conn) or die(mysql_error());
$sql_result = mysql_query($sql, $conn) or die(mysql_error());
if ($sql_result) {
echo "<p>$_POST[table_name] has been created.</p>";
}
?>
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php