On my webhosts, PHP is set up so that if there is an undiclared variable, nothing is shown, however, i wrote the script for someone whose webhost gives an error if there is an undeclared variable - which looks a bit messy in the middle of a form lol

How can i get my script to ignore this error? without me changing the font colour to the background, or making the font small etc.

Thanks

Dave

    you can use the '@' character to ignore any errors that occur by calling something.

    ie if($this == 5)
    will cause (and display) an error if $this doesnt exist.
    but
    if(@$this == 5)
    will ignore an error if one is produced.

      This is because the host has error_reporting OFF in php.ini A good host will always turn it off to prevent hackers from seeing script details, otherwise people like me will play with your scripts.. hehe

      You can either turnit off in php.ini if you have access, or set it at the top of your script...

      This can be by keyword or bitmask..

      error_reporting(1);
      or
      error_reporting(E_ERROR); mean the same.


      Examples:

      // Reporting E_NOTICE can be good too (to report uninitialized
      // variables or catch variable name misspellings ...)
      error_reporting (E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

      // Report all errors except E_NOTICE
      // This is the default value set in php.ini
      error_reporting (E_ALL ^ E_NOTICE);

      // Report all PHP errors (bitwise 63 may be used in PHP 3)
      error_reporting (E_ALL);

      // Same as error_reporting(E_ALL);
      ini_set ('error_reporting', E_ALL ^ E_NOTICE ); <<<<< I prefer this <<<<<


      here are the values for keywords/bitmasks..

      1 E_ERROR
      2 E_WARNING
      4 E_PARSE
      8 E_NOTICE
      16 E_CORE_ERROR
      32 E_CORE_WARNING
      64 E_COMPILE_ERROR
      128 E_COMPILE_WARNING
      256 E_USER_ERROR
      512 E_USER_WARNING
      1024 E_USER_NOTICE
      2047 E_ALL

      Bitmasks are a bit freaky for newbies.. php determines the corrct levels for you though, kinda cool..
      so if you set error_reporting(34); you would get E_CORE_WARNING and E_WARNING (32 + 2 = 34)

        Write a Reply...