littletechie Posted May 29, 2009 Share Posted May 29, 2009 Hello everyone I'm setting up an admin interface for specified users to be able to create/delete tables as they please. To create a table, all they have to do is type in a table name then click 'Create'. Which will then run the script (which seemed pretty straightforward) to create the table in the database. Here is the code I have, but I keep err-ing out on the query and I have run out of ideas as to what could be the problem. <?php #variables $tname = $_POST['table']; #connect to mysql $conn = @mysql_connect("localhost", "root", "tracer1") or die("Err:Conn"); #select db $rs = @mysql_select_db("test", $conn) or die("Err:Db"); #create table $result="CREATE TABLE $tname ( FirstName VARCHAR(25), LastName VARCHAR(25), address VARCHAR(25), city VARCHAR(25), state VARCHAR(25), zip VARCHAR(25), phone VARCHAR(25), email VARCHAR(25) #role VARCHAR(25) )"; #execute query $rs = mysql_query($result, $conn) or die ("Err:Query"); if($rs){ echo("$table was successfully created!"); } ?> Any thoughts on this would be greatly appreciated Link to comment https://forums.phpfreaks.com/topic/160144-create-table-issues/ Share on other sites More sharing options...
waynew Posted May 29, 2009 Share Posted May 29, 2009 Try $result="CREATE TABLE $tname ( FirstName VARCHAR(25), LastName VARCHAR(25), address VARCHAR(25), city VARCHAR(25), state VARCHAR(25), zip VARCHAR(25), phone VARCHAR(25), email VARCHAR(25) )"; Also, could you show us the actual error you're getting? Link to comment https://forums.phpfreaks.com/topic/160144-create-table-issues/#findComment-844910 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.