question regarding using error reporting and feasability

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Filth

    question regarding using error reporting and feasability

    Hi

    I have the partial section of a script below

    as you will see its not exactly great but im learning slowly but surely.

    When I have error_reporting (E_ALL); set I get the following error (script
    works fine without this):-

    Notice: Undefined variable: error in
    /home/httpd/vhosts/promotingmusic. co.uk/httpdocs/mailing_list/subscribe.php
    on line 12

    line 12 is:-

    $error .= "The e-mail address you have provided does not seem to be
    valid.<br>";

    I know what is causing it, it's the . after $error. Should I be concerned
    about the error or should I be concerned about the error or should I ignore
    it.

    Secondly if I should fix it I take it the best method (in the way it is
    currently coded) would be in creating an if within the if to check if
    already set and if so to use the . and if not to not use it.

    Also should I code with the veiw of it working perfectly using
    error_reporting (E_ALL); or error_reporting (E_ALL ^ E_NOTICE); the first of
    course being the more strict.

    CODE BELOW

    if (!isset($_GET['name']) && !isset ($_GET['email']))
    {
    include ("subscribe_for m.php");
    }
    else
    {
    if (!eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$",
    $_GET['email']))
    {
    $error .= "The e-mail address you have provided does not seem to be
    valid.<br>";
    }
    // check length of email and make sure it is between the lengths specified
    if (strlen($_GET['email']) < 6 || strlen($_GET['email']) > 50)
    {
    $error .= "The e-mail address is either too long or too short please
    re-enter and try again.<br>";
    }
    // Check and ensure the name only contains the correct characters
    if (!eregi("^[a-zA-Z\-]+$", $_GET['name']))
    {
    $error .= "Sorry we only accept letters and - in a names.<br>";
    }
    // check length of name and make sure it is not too long
    if (strlen($_GET['name']) > 100)
    {
    $error .= "The name is too long please shorten and try again.<br>";
    }
    // Output if there are errors
    if (isset ($error))
    {
    include ("subscribe_for m.php");
    }


  • Cameron

    #2
    Re: question regarding using error reporting and feasability

    Filth wrote:[color=blue]
    > Hi
    >
    > I have the partial section of a script below
    >
    > as you will see its not exactly great but im learning slowly but surely.
    >
    > When I have error_reporting (E_ALL); set I get the following error (script
    > works fine without this):-
    >
    > Notice: Undefined variable: error in
    > /home/httpd/vhosts/promotingmusic. co.uk/httpdocs/mailing_list/subscribe.php
    > on line 12
    >
    > line 12 is:-
    >
    > $error .= "The e-mail address you have provided does not seem to be
    > valid.<br>";
    >
    > I know what is causing it, it's the . after $error. Should I be concerned
    > about the error or should I be concerned about the error or should I ignore
    > it.
    >
    > Secondly if I should fix it I take it the best method (in the way it is
    > currently coded) would be in creating an if within the if to check if
    > already set and if so to use the . and if not to not use it.
    >
    > Also should I code with the veiw of it working perfectly using
    > error_reporting (E_ALL); or error_reporting (E_ALL ^ E_NOTICE); the first of
    > course being the more strict.
    >[/color]
    <code snip>

    you can just do $error = ""; at the top of your script to initialize it.


    ~Cameron

    Comment

    Working...