[thelist] Setting PHP variables...

Barry Woolgar barry at burnthebook.co.uk
Wed Apr 23 10:58:11 CDT 2008


> Am I being a tool?

Some would say we are all tools...

> However on this server, I was getting error messages stating that the
variable was not set.

If the error you are getting is something like:
PHP Notice: Undefined variable: showMessage on line 100 script x.php

Have a look at this (http://uk2.php.net/error_reporting) for info on how to
change the error reporting level at runtime (or more permanently) to
something less strict than the default. However its supposed to be good
practice to define all your variables... not that I could be accused of
doing it all the time!

Hope that helps

Barry

-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Tris
Sent: 23 April 2008 09:29
To: thelist at lists.evolt.org; wdvltalk at lists.wdvl.com
Subject: [thelist] Setting PHP variables...

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.

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.
There must be a better way to say to the server:
if I asign a value to a variable, presume it exists.

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?

Tris...



--
"The only people who don't make mistakes are those who don't do anything"

Give a man a fish and he'll feed himself for a day.
Give a man a religion and he'll starve to death praying for a fish.
Anon

`We are what we pretend to be, so we must be careful what we pretend to be.`
Kurt Vonnegut

`When a person can no longer laugh at himself, it is time for others to
laugh at him.` Thomas Szasz
-- 

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester and archives
of thelist go to: http://lists.evolt.org Workers of the Web, evolt ! 

No virus found in this incoming message.
Checked by AVG. 
Version: 7.5.524 / Virus Database: 269.23.3/1392 - Release Date: 22/04/2008
15:51
 

No virus found in this outgoing message.
Checked by AVG. 
Version: 7.5.524 / Virus Database: 269.23.3/1392 - Release Date: 22/04/2008
15:51
 




More information about the thelist mailing list