MySql/PHP query error

Associate
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:
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.
 
Finally found the problem:

Password = '$passform', WHERE

A comma before the WHERE. Yes Im a numpty. :rolleyes: Thanks though!
 
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.
 
Back
Top Bottom