MySQL Forums
Forum List  »  PHP

create table error.
Posted by: deliverance1957
Date: January 06, 2006 04:28PM

$sql = "CREATE TABLE $table_name (";

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);
$sql .= ")";
------------------------------------------------------------------------
$sql has in it: CREATE TABLE info (ITEM_ID int (5),ITEM_TITLE varchar (50),ITEM_DESC text,ITEM_PRICE int (3))

but i get the error: You have an error in your SQL syntax near '(3))' at line 1

I'm kind of new to it but I've tripple checked it, so I am missing probably missing the error. Thats why I'm searching for someone elses eyes.

Options: ReplyQuote


Subject
Written By
Posted
create table error.
January 06, 2006 04:28PM
January 07, 2006 05:27AM
January 07, 2006 04:37PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.