...

View Full Version : Table name from Post Variable.



GSimpson
09-18-2006, 05:17 AM
Why doesn't this work - I can't figure it out.


$txt1 = $_POST[Title];

$sql2 = "CREATE TABLE $txt1 (
ThreadTitle varchar(9999),
Date varchar(12),
Username varchar(12)
)";
mysql_query($sql2,$con);

echo "Your Forum Was Successfully Created. Please Return <a href='index.php'>Here</a>.";
mysql_close($con);
?>

Brandoe85
09-18-2006, 05:48 AM
Add mysql_error() onto your code:
mysql_query($sql2,$con) or die(mysql_error());

Side note, varchar's max size is 255 and maybe you'd be interested in using the data type of date for your date column.
Ref:
http://dev.mysql.com/doc/refman/5.0/en/char.html

vinyl-junkie
09-18-2006, 06:12 AM
Also, make sure $txt1 isn't a reserve word. You don't always get a meaningful error message when you do something like that.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum