... $tablename = $output2;
if($a==-1){
$query = "CREATE TABLE `" . $tablename . "` (
`id` mediumint(9) NOT NULL AUTO_INCREMENT,
`Name` varchar(60) NOT NULL,
`Number` varchar(12) NOT NULL,
PRIMARY KEY (`id`)
);";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($query);
}
else{
$wpdb->insert(
$tablename,
array(
'Name' => $output,
'Number' => $output2,
),
array(
'%s',
'%s',
)
);
}
$output and $output2 are getting initialized fine. A table is being created with name $output2, but the values are not being inserted when ‘a’ holds any non-negative value. What am I doing wrong?
If
ais a variable and not a defined constant, then there is an error in your code.It should then be: