ptrainer — 2012-10-06T07:18:11-04:00 — #1
I have Larry Ullmans PHP book and am just experimenting with something to see how it works.
Here is what I am trying to do within the same page
<?php $result = "This is a test" ?>
<?php echo "$result" ?>
When I run this I get an undefined variable error.....grrrr
cpradio — 2012-10-06T07:31:31-04:00 — #2
Well, not 100% that this would produce an undefined variable, but you are missing the semi-colon after each PHP statement.
<?php $result = "This is a test"; ?>
<?php echo "$result"; ?>
tpunt — 2012-10-06T07:53:12-04:00 — #3
There is nothing in the code above that would produce an undefined error. So unless some other code is triggering this error, or one of your variable names is different (remember they're case sensitive), then the above has no reason to output an error.
@cpradio, omitting the last semicolon before the closing PHP tag is optional, so it would not be the cause of this (or any) error.
cpradio — 2012-10-06T08:15:18-04:00 — #4
Partially why I prefixed it, as if that were the problem, it should have produced a syntax error.
kduv — 2012-10-06T21:15:27-04:00 — #5
The error should tell you exactly which variable is undefined. What is the entire error message?