The problem is the column name syntax you chose: square brackets are not valid inside column names. So Kol[$col]
is invalid, you can do something like Kol_$col
instead.
For reasons of coding style I would advise to use sprintf()
for this:
$sSql .= sprintf( ' kol_%s VARCHAR(25)', (int)$col );
Also note the lowercase 'k' in the column name. It has proven to prevent annoying errors not to user uppercase characters in identifier names.
You can simplify your code by using phps implode()
function, btw:
$sCol = array();
for ($col = 1; $col <= $nrColumns; ++ $col)
$sCol[] = sprintf( 'kol_%s VARCHAR(25)', (int)$col )
$sqlCreate = sprintf( 'CREATE TABLE temp_table (%s)', implode( ", ", $sCol ));