Table creation problems...

From: Date: Sun, 09 Sep 2001 09:37:11 +0000
Subject: Table creation problems...
Groups: php.db php.general 
Request: Send a blank email to php-general+get-66592@lists.php.net to get a copy of this message
Hello, I have been trying to create a table by the name of an ID field in another table. My code looks something like this... $result = mysql_db_query($db,"insert into $board_rooms set parentid='$catid', title='$title', description='$description'"); $groupid = mysql_insert_id(); settype($groupid, "string") $result = mysql_db_query($db, "CREATE TABLE $groupid (topicid INT NOT NULL, parentid INT NOT NULL, topic TINYINT NOT NULL, text TEXT NOT NULL, user VARCHAR(20) NOT NULL, lastactive DATETIME NOT NULL, created DATETIME NOT NULL, posts INT NOT NULL , PRIMARY KEY (topicid), UNIQUE (topicid))"); The problem comes in the last statement, where I am trying to create a table by the name of the $groupid variable which was pulled another table's ID field via mysql_insert_id(). I then attempted to convert the $groupid to a string, just to make sure it would be ok to use as a table name, but that doesn't do anything. I know that using the $groupid is my only problem with the table creation, becuase if I manually replace $groupid in the table creation query to something like '100', it works fine. Could someone please tell me how I can use a long type, such as a table ID as the name of another table? Thanks a lot, Jonathan

« previous php.general (#66592) next »