CREATE TABLE $phpVariable_for_tableName <--- help please!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



i cant get this to work right, im building a comments for my blog. im pretty knowledgeable about php code and i am willing to listen, even though im still learning. my code in the php doc is as follows:

1 //select the db
2 $db = mysql_select_db($mydb) or die("db connect error");
3 $newTable = $entryNum + "_comms";
4
5 //if posting a comment do this:
6 if ($comms==true) {
7
8 //define a table name based on main Post number
9
10
11 //create a table
12 $sql = 'CREATE TABLE $newTable ( `daUser` VARCHAR( 255 ) NOT NULL ,'
13 . ' `entryNumb` INT NOT NULL ,'
14 . ' `priv` VARCHAR( 1 ) NOT NULL ,'
15 . ' `comm` BLOB NOT NULL ,'
16 . ' PRIMARY KEY ( `entryNumb` ) )';
17
18
19 $resulter = mysql_query($sql) or die("There has been an error creating table: $newTable");
20
21


---end

on line 12 is where ive narrowed the error to. i know that the table name is what is supposed to be there but im trying to create this based on a post entry number and then adding "_comms" to the name..

so the comments table for post number 1 would be named: 1_comms
im also having an issue with line 3, creating that name

please help me :)

thanks
-AJ seelund

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux