Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Error Reporting

  1. #1
    New Coder
    Join Date
    Jul 2004
    Location
    Leamington, UK
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Error Reporting

    Hi guys.

    ok on my page i have a form which on submission inserts an entry to the db

    however .. if the username exists it displays a blank page and says ' Duplicate entry for demo'

    how would i get that to display that error on register.php as part of teh $message string ?

    im a bit confuzzled lol

    thanks in advance

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Without seeing how your script works, can't really give you any help. If you do all your form valdidation on the same page, you'll be able to echo out the errors then instead of redirecting

  • #3
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    You could do it the plain way by just including whatever code needed and ending the script after the include (die()). Without code there nothing more we can say.

  • #4
    New Coder
    Join Date
    Jul 2004
    Location
    Leamington, UK
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?php
    $currentPage 
    $_SERVER["PHP_SELF"];

    function 
    GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
    {
      
    $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

      switch (
    $theType) {
        case 
    "text":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;    
        case 
    "long":
        case 
    "int":
          
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case 
    "double":
          
    $theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
          break;
        case 
    "date":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;
        case 
    "defined":
          
    $theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
          break;
      }
      return 
    $theValue;
    }

    $editFormAction $_SERVER['PHP_SELF'];
    if (isset(
    $_SERVER['QUERY_STRING'])) {
      
    $editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset(
    $_POST["MM_insert"])) && ($_POST["MM_insert"] == "register")) {
      
    $insertSQL sprintf("INSERT INTO members (memid, username, password, realname, age, premium, joined, location, sex, country, starsign, sexuality, profession, marital_status, hair, eyes, height, body_type, race, lookingfor, seeking, likes, dislikes, emailaddress, pwdreminder, status, ppic, timeonline, views) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                           
    GetSQLValueString($_POST['memid'], "int"),
                           
    GetSQLValueString($_POST['username'], "text"),
                           
    GetSQLValueString($_POST['password'], "text"),
                           
    GetSQLValueString($_POST['realname'], "text"),
                           
    GetSQLValueString($_POST['age'], "text"),
                           
    GetSQLValueString($_POST['premium'], "text"),
                           
    GetSQLValueString($_POST['joined'], "text"),
                           
    GetSQLValueString($_POST['location'], "text"),
                           
    GetSQLValueString($_POST['sex'], "text"),
                           
    GetSQLValueString($_POST['country'], "text"),
                           
    GetSQLValueString($_POST['starsign'], "text"),
                           
    GetSQLValueString($_POST['sexuality'], "text"),
                           
    GetSQLValueString($_POST['profession'], "text"),
                           
    GetSQLValueString($_POST['marital_status'], "text"),
                           
    GetSQLValueString($_POST['hair'], "text"),
                           
    GetSQLValueString($_POST['eyes'], "text"),
                           
    GetSQLValueString($_POST['height'], "text"),
                           
    GetSQLValueString($_POST['body_type'], "text"),
                           
    GetSQLValueString($_POST['race'], "text"),
                           
    GetSQLValueString($_POST['lookingfor'], "text"),
                           
    GetSQLValueString($_POST['seeking'], "text"),
                           
    GetSQLValueString($_POST['likes'], "text"),
                           
    GetSQLValueString($_POST['dislikes'], "text"),
                           
    GetSQLValueString($_POST['emailaddress'], "text"),
                           
    GetSQLValueString($_POST['pwdreminder'], "text"),
                           
    GetSQLValueString($_POST['status'], "text"),
                           
    GetSQLValueString($_POST['ppic'], "text"),
                           
    GetSQLValueString($_POST['timeonline'], "text"),
                           
    GetSQLValueString($_POST['views'], "int"));

      
    mysql_select_db($database_OnlineFlirting$OnlineFlirting);
      
    $Result1 mysql_query($insertSQL$OnlineFlirting) or die(mysql_error());

      
    $insertGoTo "index.php?message='Registration Successful, Check your email for your password'";
      if (isset(
    $_SERVER['QUERY_STRING'])) {
        
    $insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
        
    $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      }
    ?>
    not sure what code you wanted

  • #5
    New Coder
    Join Date
    Jul 2004
    Location
    Leamington, UK
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi guys

    just added $message = mysql_error();

    then echo'd it on the page where i want it to appear.

    thanks for your help & sorry for askin stupid questions

    one moe thing though ... how do i change teh text that is displayed ?

    instead of Duplicate entry 'demo' for key 2

    i would liek User exists

    any ideas ?

    thanks
    Last edited by MatesOnline; 09-24-2004 at 06:10 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
    •