BrianM Posted April 19, 2008 Share Posted April 19, 2008 I'm trying to have my script create a table based upon the value that is inserted into the projectnumber input. Something along the lines of: $insert_two = "CREATE TABLE `$_POST['projectnumber']` ( PermitProcess varchar(40), Req char(3), SubmittalDate date, CommentsReceivedDate1 date, ResubmitDate1 date, CommentsReceivedDate2 date, ResubmitDate2 date, CommentsReceivedDate3 date, ResubmitDate3 date, CommentsReceivedDate4 date, ResubmitDate4 date, ApprovalDate date, PermitNumber varchar(10), CoCReqDate date, CoCSubmittalDate date )"; mysql_query($insert_two, $mysql_connect); The only thing I've found wrong is my syntax with trying to set the table name with my POST value. Is what I'm wondering is, does anyone know the correct syntax to write $insert_two = "CREATE TABLE `$_POST['projectnumber']` I'm not sure how to write out the correct format and syntax with the backticks and $_POST['projectnumber']. Quote Link to comment Share on other sites More sharing options...
haku Posted April 19, 2008 Share Posted April 19, 2008 "CREATE TABLE '{$_POST['projectnumber']}' As a side note, be careful of your single quotes - the outside single quotes you were using around the post variable were not standard quotes, and as such would have failed even if you had used the syntax I used above. Did you copy them out of a word file or something? Quote Link to comment Share on other sites More sharing options...
stuffradio Posted April 19, 2008 Share Posted April 19, 2008 This is a dangerous thing to do. Just thought you should know. Try and make it so the script is very limited in who can use it, or stick to PHPmyAdmin Quote Link to comment Share on other sites More sharing options...
BrianM Posted April 19, 2008 Author Share Posted April 19, 2008 I actually was referring to the MySQL website, which is where I found out that information. Oh, and it's because I'm using numbers for table names instead of letters, and I heard backticks are the only thing that work with MySQL when creating tables with numbers in them. Quote Link to comment Share on other sites More sharing options...
BrianM Posted April 19, 2008 Author Share Posted April 19, 2008 Ah, haku, thank you very much! It works, but like I said, I have to replace the '' with `` since I am using numbers instead of letters. And stuffradio, thank you for the suggestion, but this will only be on a LAN at my fathers work office. I'm using HTML, PHP and a MySQL database to create a project tracking system for his engineering company so that there is no need to use a filing cabinet and folders with thousands of unorganized papers any longer. No need to worry about security in this case. ) Thanks for the suggestion though. Again, thanks you two!!! Quote Link to comment Share on other sites More sharing options...
haku Posted April 19, 2008 Share Posted April 19, 2008 No worries. I learned something new too - this is the first I had learned about the backticks when using numbers for table names. Quote Link to comment 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.