Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have to insert a table in my databasse and the table name is pbb_prefix and he contains 3 columns: id,prefix,forum
when i run this command
$info_query = $PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['info'] . " WHERE var_name='prefix_installed'");
$info_row = $PowerBB->DB->sql_fetch_array($info_query);
if (!$info_row)
{
 $PowerBB->DB->sql_query("CREATE TABLE `".$PowerBB->prefix."prefix` (
`id` int(9) NOT NULL AUTO_INCREMENT,
`prefix` varchar(100) NOT NULL,
`forum` INT( 9 ) NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
$PowerBB->DB->sql_query("ALTER TABLE " . $PowerBB->table['subject'] . " ADD `prefix` VARCHAR( 100 ) NULL");
$PowerBB->DB->sql_query('INSERT INTO ' . $PowerBB->table['info'] . " SET var_name='prefix_installed',value='1' ");
}

i have this error
Error Number:0
Error Query: CREATE TABLE `pbb_prefix` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`prefix` varchar(100) NOT NULL,
`forum` INT(11) NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


how can i resolve this problem
thanks

What I have tried:

error sql when inserting table
Posted
Comments
Richard Deeming 20-Feb-24 3:35am    
You forgot to include the actual error message.

But aside from that, dynamically creating tables at run-time is almost always the wrong thing to do. Perhaps you'd be better off asking for guidance towards a better database design that doesn't require you to do this. :)
Member 15627495 22-Feb-24 15:35pm    
INSERT query is badly written.
'INSERT INTO 'table' VALUES ('','','',''...) ;

SET is for 'UPDATE' query only

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900