Forum Moderators: coopster
---
single quoted tell php not to parsed/substitute the variables, when you put the variable $section between single quotes PHP will look at it as a string "$section" instead of the variable $section or its contents "Test Page".
echo $section.$i; should work (Test Page1) or
echo $section.' '.$i; (Test Page 1) the space is in quotes.
of course you could also just use double quotes like others have mentioned.. I hate how that messes up code coloring in dreamweaver though.
$section1= "Test Page";
and then
echo '$section'.'$i';
Try setting error_reporting = E_ALL in your php.ini, and it would have told you
Notice: Undefined variable: section in D:\Inetpub\test\test.php on line 4
You're still using: echo $section1
What I'm trying to do is to assign variables like this:
$section1= "Test Page One";
$section2= "Test Page Two";
$section3= "Test Page Three";
and so on...
Then assign variable: $i=1;
Now echo each $sectionN using the assigned variable $i.
So the code stays the same and only the value of $i changes.
Everything I've tried has failed and what should work doesn't. The suggestions given so far don't work either.
It seems like it should be a simple code that should work out of the box, but simply doesn't.
I keep looking at the code and try to figure out what we are all missing.
[php.net...]
baze
[edited by: coopster at 11:39 pm (utc) on Dec. 4, 2004]
[edit reason] hooked up url [/edit]
Defintely use arrays if it's possible. Sometimes though, variable variables let you do things that arrays will not.
So is it all sorted now?
Tom
BTW, it doesn't matter where you are on the slope. Setting up the problem is usually the hard part. I think that's why the discussion form works so well. I think we get a lot of threads where it goes back and forth a lot until the question is defined sufficiently and then the answer pops out in a few lines. I always htink that's pretty cool.
Tom