1

I have to use the $id variable as table name but it is not working.

       $sql1="CREATE TABLE $id(
              amt_to_be_paid INT(6),
              no_of_days_req INT(2),
              proposal TEXT NOT NULL,
              channel_link VARCHAR(100) NOT NULL,
              )";

2 Answers2

1

Be sure that you have the full control on the $id variable and is not coming from user input.

You need to concatenate your $id variable to the query string, as following:

   $sql1="CREATE TABLE " . $id . "(
          amt_to_be_paid INT(6),
          no_of_days_req INT(2),
          proposal TEXT NOT NULL,
          channel_link VARCHAR(100) NOT NULL,
          )";
cdr89
  • 958
  • 9
  • 18
0

Take a look at this answer for a detailed review of how to achieve this : How to include a PHP variable inside a MySQL statement

mojo
  • 988
  • 6
  • 17