Trying to update existing records in phpMyAdmin, but the following code doesn't seem to be working.
<?php
$id = stripslashes($_POST['id']);
$title = stripslashes($_POST['title']);
$first = stripslashes($_POST['first']);
$surname = stripslashes($_POST['surname']);
$email = stripslashes($_POST['email']);
$promotion = stripslashes($_POST['promotion']);
$maths11 = stripslashes($_POST['maths11']);
$english11 = stripsl开发者_开发百科ashes($_POST['english11']);
$english13 = stripslashes($_POST['english13']);
$science13 = stripslashes($_POST['science13']);
$maths133 = stripslashes($_POST['maths133']);
$maths132 = stripslashes($_POST['maths132']);
$address = stripslashes($_POST['address']);
$address2 = stripslashes($_POST['address2']);
$town = stripslashes($_POST['town']);
$county = stripslashes($_POST['county']);
$code = stripslashes($_POST['code']);
$tel = stripslashes($_POST['tel']);
//database connection
$query="UPDATE Promotions SET address='$address', address2='$address2', town='$town', county='$county', postcode='$code', tel='$tel' WHERE id = '$id'";
mysql_query($query) or die(mysql_error());
include 'confirm.php';
include 'registerEmail.php';
?>
Any help? Thanks
Instead of rather useless die ('Error updating database');
handle your errors in more informative way
mysql_query($query) or trigger_error(mysql_error().' in '.$query);
and read what it says
Use mysql_error()
like Col. Shrapnel showed.
But what troubles me ... Is that all the code for that page? Because you have //database connection
but I don't see any database connection. Are you sure you are connecting to your database and included that connection in your file?
EDIT:
what does your query look like when you echo it? maybe the id is empty ... that way you can see what exactly is going to be send to the db
echo $query;
精彩评论