QUOTE
I have the code below...
What does this mean? Did you write it yourself? Are you trying to learn how to write php programs yourself?
Anyway...
QUOTE
$ColName = "Col1,Col2,Col3";
Do you understand what the = sign means? It does _not_ mean "equals", in any normal mathematical sense. (Blame the Americans for this: every programming language designed in Europe uses a distinctive "assignment" symbol, such as := )
It means: take the value on the right hand side, and assign it to the _location_ on the left hand side. So this results in the location called $ColNama having the value which is the _string_ (because of the quotes) "Col1,Col2,Col3". I think this is what you meant.
Now do the second line yourself, and you should understand the problem.
... hmm, it's not really that simple. The problem is in the PHP string replacement stuff. When you assign a value like "'$line[0]','$line[1]','$line[2]'" what happens? First, you can't use $line[0] within a double-quoted string to get the value of $line[0]. Second, the value of $line[0], or $line is what currently? Um, empty!