Results 1 to 6 of 6

Thread: problem with new version

  1. #1

    Thread Starter
    Lively Member Brandito's Avatar
    Join Date
    Nov 2000
    Location
    Here, There, Every Where!
    Posts
    106

    problem with new version

    My server guy updated to php 4.3.0.
    It has done some bad things...

    This is my problem...

    I am using this to request url variable data:
    $myLink = $_REQUEST[myLink];
    $myFriendly = $_REQUEST[friendly];

    Error:
    Notice: Use of undefined constant myLink - assumed 'myLink' in d:\wwwroot\brandito\website\Site.php on line 8

    Notice: Use of undefined constant friendly - assumed 'friendly' in d:\wwwroot\brandito\website\Site.php on line 9

    Notice: Undefined index: friendly in d:\wwwroot\brandito\website\Site.php on line 9

    If it 'assumes' that.. why the heck does it have to say so. The php code works.. it just adds these comments at the top! Bad design if you ask me. How does one go about fixing this?

    Thanks alot for your support,
    Brandito
    Master of Cyber Fu - A Temple of Digital Chi

  2. #2
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    print $array[foo];

    PHP looks for a constant named foo first, if it does not exist then
    it'll shout an error of level E_NOTICE and then look for the key foo
    (which is what you wanted) ...

    error_reporting can be set about anywhere, including php.ini, .htaccess
    and the error_reporting() function. And some code:

    define('a', 'b');
    $arr = array('a' => 'apple', 'b' => 'banana');
    print $arr[a]; // banana
    print $arr['a']; // apple

    Moral of the story is you should always surround your array keys with
    quotes!
    A little searching goes a long way

  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by da_silvy
    Moral of the story is you should always surround your array keys with quotes!
    I thought this was a common coding practice?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    That's the way i do it

  5. #5
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Notice: Undefined index: friendly in d:\wwwroot\brandito\website\Site.php on line 9
    That one is because "friendly" hasn't been passed into the $_REQUEST variable either. You can either get round it like $myFriendly = (isset($_REQUEST['friendly'])) $_REQUEST['friendly'] : ''; or you can turn the notice warnings off can't you with error_reporting()

  6. #6
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    The FIX and it also started in 4.1 is to uncomment the error lines that read as follows,
    error_reporting = E_ALL & ~E_NOTICE

    if you don't have access to the ini file you can do it in code as well

    you can insert this into your script at the very top

    error_reporting (E_ALL ^ E_NOTICE);
    Last edited by phpman; Feb 2nd, 2003 at 12:58 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width