1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

MySql/PHP query error

Discussion in 'HTML, Graphics & Programming' started by Mysteria, 17 May 2006.

  1. Mysteria

    Gangster

    Joined: 10 Dec 2003

    Posts: 122

    Location: Im here, where are you?

    Im getting the following error:

    Fatal error: Call to undefined function showerror() in updatedetails.php on line 200

    From previous experience I know this does not mean that the error is on line 200, just a problem since the previous showerror() function. Ive have stared at the code for ages now and cannot find the problem-help please!

    //Now see if this is an update of an insert
    $custID = $_SESSION["authenticatedUser"];
    $passform = $_POST["passForm"];
    strip_tags($passform);

    //Create a query to update the data
    $query = "UPDATE Customer SET Firstnames = '$firstname', Surname = '$surname', UserName = '$userform', email = '$email', Password = '$passform', WHERE CustomerID = '$custID'";

    // Run the query on the customer table
    if (!(@ mysql_query ($query, $connection)))
    showerror();

    Im stumped :(
     
    Last edited: 17 May 2006
  2. Augmented

    Soldato

    Joined: 18 Oct 2002

    Posts: 5,464

    Location: London Town

    showerror() is not a PHP function, it's a user-defined one. So you must ensure the function definition is being included when you run that code. Track down which file function showerror() {.. is being defined in, and make sure it's included in that script you're running :).

    Note that strip_tags isn't particularly useful for sanitising external data before inserting it into a DB, use a proper DB-sanitising function like mysql_real_escape_string() on your POST data.
     
  3. Mysteria

    Gangster

    Joined: 10 Dec 2003

    Posts: 122

    Location: Im here, where are you?

    Finally found the problem:

    Password = '$passform', WHERE

    A comma before the WHERE. Yes Im a numpty. :rolleyes: Thanks though!
     
  4. robmiller

    Capodecina

    Joined: 26 Dec 2003

    Posts: 16,522

    Location: London

    You'll still have the problem if the mySQL query every throws another error. Change all instances of showerror() to trigger_error() (which is a core PHP function) and you should be fine.
     
  5. Dfhaii

    Hitman

    Joined: 19 Oct 2002

    Posts: 550

    Location: Penryn

    If you're wanting errors shown then why bother supressing them when you run the query?