Results 1 to 2 of 2

Thread: How to echo error if there is wrong URL? Need help

  1. #1
    Join Date
    Jan 2006
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How to echo error if there is wrong URL? Need help

    I have code and it reads from URL number ID. How to report error message if $_GET['number'] is not the same as in db?

    PHP Code:
    reactivationnum=$_GET['number'];


    $query "SELECT * FROM membership WHERE reactivationnum = '$reactivationnum'";
    $result1 mysql_query($query);

     while (
    $row mysql_fetch_array($result1))
    {       
    $reactivation $row["reactivation"];      
             if (
    $reactivation==)

          {      
                    echo 
    "<script language='javascript'>
                        document.location='activated.php';</script>"
    ;  }

           else
            {
                     echo 
    "<script language='javascript'>
                        document.location='notactivated.php';</script>"
    ;     
             }
     } 

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    If you're trying to do what I think you're doing, try the following:

    PHP Code:
    <?php

    $reactivationnum
    =$_GET['number'];


    $query "SELECT * FROM membership WHERE reactivationnum = '$reactivationnum'";
    $result1 mysql_query($query);

    if (!
    mysql_num_rows($result1)) {

            echo 
    "<script language='javascript'>
                        document.location='notactivated.php';</script>"

    }

    else {

            echo 
    "<script language='javascript'>
                        document.location='activated.php';</script>"

    }

    ?>
    That will check the database for any matching rows for $reactivationnum. If it does not have any matching rows, it redirects to notactivated.php. If it does have a matching row, it redirects to activated.php. Let me know if this is what you're talking about.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

Bookmarks

Posting Permissions

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