hi all,,,
I am trying to make a table in php Mu SQL database.. and i want to name it by using user input. means user has given some input and i have stored it in a variable flight. now i am using this query
'CREATE TABLE $flight (`name` VARCHAR(30) NOT NULL, `num_pass` INT(2) NOT NULL, `address` VARCHAR(30) NOT NULL, `contact` VARCHAR(21) NOT NULL,`flight_no` VARCHAR(30) NOT NULL,`pass_id` INT( 9 ) NOT NULL AUTO_INCREMENT PRIMARY KEY)'
but it is not working...... please someone help me urgently........
$query=mysql_query('CREATE TABLE \''.$flight.'\' (`name` VARCHAR(30) NOT NULL, `num_pass` INT(2) NOT NULL, `address` VARCHAR(30) NOT NULL, `contact` VARCHAR(21) NOT NULL,`flight_no` VARCHAR(30) NOT NULL,`pass_id` INT( 9 ) NOT NULL AUTO_INCREMENT PRIMARY KEY)');
if(!$query)
{
$insert=mysql_query('INSERT INTO \''.$flight.'\' VALUES ("$name","$pass","$address","$contact","$flight","")');
}
else
{
$insert=mysql_query('INSERT INTO \''.$flight.'\' VALUES ("$name","$pass","$address","$contact","$flight","1")');
}
but it also is not working... it is creating a table with name "$flight".. kindly do it right if possible.........
I will wait for your answer
the code you have mentioned earlier is giving following error
Quote:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-345 (`name` VARCHAR(30) NOT NULL, `num_pass` INT(2) NOT NULL, `address` VARCHAR' at line 1