#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    Hong Kong
    Posts
    73
    Rep Power
    15
    $link = mysql_pconnect ($DB_SERVER, $DB_LOGIN, $DB_PASSWORD);
    $selectStmt = "SELECT * FROM user_profile WHERE userid = 'david'";
    if (!($result = mysql_db_query($DB, $selectStmt, $link))){
    header("Location:http://$HTTP_HOST/$DOCROOT/error.html");
    exit();
    }

    here is the case, the userid 'David' is NOT
    in the table 'user_profile', the program should launch the error.html, and exit().
    But it is not.
    AHHH....what is wrong in my codes here.
    pls help
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 1999
    Location
    Netherlands
    Posts
    77
    Rep Power
    16
    Hi,

    I think that there is a resultset created (even though the userid is not found), but it consists of zero rows.

    You can try it with a count of the returned rows:
    $link = mysql_pconnect ($DB_SERVER, $DB_LOGIN, $DB_PASSWORD);
    $selectStmt = "SELECT * FROM user_profile WHERE userid = 'david'";
    $result = mysql_db_query($DB, $selectStmt, $link);
    $numRows = mysql_num_rows($result); // counts the number of rows in the resultset
    if ($numRows < 1){
    header("Location:http://$HTTP_HOST/$DOCROOT/error.html");
    exit();
    }

    Peter

Similar Threads

  1. Tell me what's wrong..PHP CODE SIMPLE
    By steral in forum PHP Development
    Replies: 8
    Last Post: February 11th, 2004, 04:48 PM
  2. functions slowing code
    By dave2k in forum PHP Development
    Replies: 5
    Last Post: February 7th, 2004, 07:40 PM
  3. Ensuring a file's code doesn't cause error in another.
    By Jason Doucette in forum C Programming
    Replies: 0
    Last Post: February 6th, 2004, 01:51 PM
  4. What's wrong w/this code?
    By bubblingangel in forum Visual Basic Programming
    Replies: 2
    Last Post: February 3rd, 2004, 02:24 PM
  5. could you tell what is wrong with this code?
    By skyrtz in forum Visual Basic Programming
    Replies: 3
    Last Post: February 3rd, 2004, 08:32 AM

IMN logo majestic logo threadwatch logo seochat tools logo