Having a small issue and I am not very good at this yet but I am getting a message to check my syntax again:
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 'intNOT NULL auto_increment, primary key (id) ,f_name varchar ,l_name varchar ,ad' at line 1
I know it is from something in the Auto_Incrementing field but I don't know what.
here is the php
<?php
$db_name = "markbad_markbadsql";
$connection=mysql_connect ("localhost", "markbad_drpl1", "deletedforsecurity")
or die ('I cannot connect to the database because: ' . mysql_error());
$db = mysql_select_db ($db_name, $connection)
or die ('I cannot connect to the database because: ' . mysql_error());
//start creating SQL statment
$sql = "CREATE TABLE $_POST[table_name] (";
//continue SQL statement for each field
for ($i = 0; $i < count($_POST[field_name]); $i++) {
$sql .= $_POST[field_name][$i]." ".$_POST[field_type][$i];
if ($_POST[auto_increment][$i] == "Y") {
$additional = "NOT NULL auto_increment";
} else {
$additional = "";
}
if ($_POST[primary][$i] == "Y") {
$additional .= ", primary key (".$_POST[field_name][$i].")";
} else {
$additional = "";
}
if ($_POST[field_length][$i] != "") {
$sql .= " (".$_POST[field_length][$i].") $additional ,";
} else {
$sql .= "$additional ,";
}
}
// Clean up the end of the string.
$sql = substr($sql, 0, -1);
$sql .= ")";
// Execute Query
$result = mysql_query($sql,$connection)
or die (mysql_error());
// Get a good result if sucessful
if ($result) {
$msg = "<p>".$_POST[table_name]." has been created!</p>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>adding to table <? echo "$result"; ?>...</h1>
<? echo "$msg"; ?>
</body>
</html>
thanks for everything PHPBUILDER!
btw: this script comes right after a form defining all the fields. this script creates the table.