winmastergames Posted February 6, 2008 Share Posted February 6, 2008 Well Look at the script first <?php include 'config.php'; include 'opendb.php'; $dbtoadd = $_GET["user"]; $query = 'CREATE DATABASE phpcake'; $result = mysql_query($query); mysql_select_db('swd-dbweb') or die('Cannot select database'); $query = 'CREATE TABLE $dbtoadd( '. 'cid INT NOT NULL AUTO_INCREMENT, '. 'cname VARCHAR(20) NOT NULL, '. 'cemail VARCHAR(50) NOT NULL, '. 'csubject VARCHAR(30) NOT NULL, '. 'cmessage TEXT NOT NULL, '. 'PRIMARY KEY(cid))'; $result = mysql_query($query); include 'closedb.php'; ?> You wont need Config.php or opendb.php cause thats just connection but as you can see to make the Table you will have to type script.php?user=tablename but when it makes it it just makes a database with $dbtoadd there must be a trick to making this work Please and thanks Quote Link to comment https://forums.phpfreaks.com/topic/89667-solved-creating-mysql-tables-problem/ Share on other sites More sharing options...
Stooney Posted February 6, 2008 Share Posted February 6, 2008 In the following code, you need to use double quotes for php to parse the variables inside the quotes. $query = 'CREATE TABLE $dbtoadd( '. 'cid INT NOT NULL AUTO_INCREMENT, '. 'cname VARCHAR(20) NOT NULL, '. 'cemail VARCHAR(50) NOT NULL, '. 'csubject VARCHAR(30) NOT NULL, '. 'cmessage TEXT NOT NULL, '. 'PRIMARY KEY(cid))'; edit: technically you could just do $query= 'CREATE TABLE '.$dbtoadd.'('. the rest is fine Quote Link to comment https://forums.phpfreaks.com/topic/89667-solved-creating-mysql-tables-problem/#findComment-459461 Share on other sites More sharing options...
winmastergames Posted February 6, 2008 Author Share Posted February 6, 2008 So use " instead of ' Change all of them?? Quote Link to comment https://forums.phpfreaks.com/topic/89667-solved-creating-mysql-tables-problem/#findComment-459464 Share on other sites More sharing options...
winmastergames Posted February 6, 2008 Author Share Posted February 6, 2008 Ok that worked thanks very much thanks for fast replie Quote Link to comment https://forums.phpfreaks.com/topic/89667-solved-creating-mysql-tables-problem/#findComment-459466 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.