Tris wrote:
Hi all...
I'm on site this week and working on a project that the server has
Global Variables turned off(I know I know, I SHOULD be doing that by
default..!)
Anyhoo, When I needed something dynamic, I simply did:
if (isset($_SESSION["userId"])) {
$showMessage = "welcome";
}
However on this server, I was getting error messages stating that the
variable was not set.
Try it this way:
if (isset($_SESSION["userId"])) {
$showMessage = "welcome";
} else {
$showMessage = '';
}
The short-hand would be
isset($_SESSION["userId"]) ? $showMessage="welcome" : $showMessage='';
If I added a blank variable at the top of the code ' $showMessage = ""; '
that 'fixed' the big.
However, now I have a list of about 30 variables at the top of my code
and it looks untidy.
(I'm guessing you never had to write code in C :) )
There must be a better way to say to the server:
if I asign a value to a variable, presume it exists.
Yes, but sometimes you don't assign anything to $showMessage and it's
complaining when you then use it somewhere.
You could change the settings for error reporting.
http://www.php.net/manual/en/function.error-reporting.php
Specifically ERROR_NOTICE is the culprit.
In general, you want ERROR_NOTICE on during development then can turn if
off for production. Error message can be directed to a log file to keep
from messing up the page.
This only occurs when the main page requests a variable (eg
$showMessage ) and it's not ben asigned..
on other servers, it has just simply shown nothing, cause nothing was found...
Am I being a tool?
Hmmm "being a tool", is that British slang? What's it mean?
--
Sheila
http://www.shefen.com/
____ � The WDVL Discussion List from WDVL.COM � ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] or
use the web interface http://e-newsletters.internet.com/discussionlists.html/
Send Your Posts To: [email protected]
To change subscription settings, add a password or view the web interface:
http://intm-dl.sparklist.com/read/?forum=wdvltalk
________________ http://www.wdvl.com _______________________
You are currently subscribed to wdvltalk as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
To unsubscribe via postal mail, please contact us at:
Jupitermedia Corp.
Attn: Discussion List Management
475 Park Avenue South
New York, NY 10016
Please include the email address which you have been contacted with.