Mahesh Varvatkar
Mahesh Varvatkar

Reputation: 11

having trouble with mysqli query default value

i am working with mysqli query and i want to set default value for perticular column getting that value from variable i have tried a lot i could not get any solution on internet if there is any expert with mysqli help me out of this $route_name, $from, $to value of this variable should be take as default value here is my query

CREATE TABLE $route_table_name (
route_id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
bus_id INT(11),
route_name VARCHAR(100) DEFAULT $route_name,
route_from VARCHAR(100) DEFAULT $from,
route_to VARCHAR(100) DEFAULT $to
)

Upvotes: 0

Views: 168

Answers (2)

Mahesh Varvatkar
Mahesh Varvatkar

Reputation: 11

i use this and now its working fine thanks a lot CREATE TABLE $route_table_name ( route_id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY, bus_id INT(11), route_name VARCHAR(100) DEFAULT '$route_name', route_from VARCHAR(100) DEFAULT '$from', route_to VARCHAR(100) DEFAULT '$to' )

Upvotes: 0

varman
varman

Reputation: 8894

mysql_query($connection,"CREATE TABLE `".$route_table_name."` (
route_id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
bus_id INT(11),
route_name VARCHAR(100) DEFAULT `".$route_name."`,
route_from VARCHAR(100) DEFAULT `".$from."`,
route_to VARCHAR(100) DEFAULT `".$to."`
)");

Make sure values are passing

Upvotes: 0

Related Questions