ahundiak,
things are getting a little clearer - once I define $UserID earlier in the script thought I had it licked - but no
After cleaning up the code - all the changing and debugging - here is what I am down to:
//get the information from the form
$editUser = $_SERVER['PHP_SELF']; //trigger
if (isset($_POST['submit'])) { //handle the form
//define the variables
$Username = trim($_POST['Username']);
$Password = trim($_POST['Password']);
$FirstName = trim($_POST['FirstName']);
$LastName = trim($_POST['LastName']);
$Email = trim($_POST['Email']);
$AccessLevel = $_POST['AccessLevel'];
//connect to the database
mysql_select_db($database_connMI, $connMI) or die ('<p>Could not select the database because <b>' .mysql_error().'</b></p>');
//define the query
$query = "UPDATE user
SET
Username='$Username',
Password='$Password',
FirstName='$FirstName',
LastName='$LastName',
Email='$Email',
AccessLevel=$AccessLevel
WHERE UserID=$UserID";
//execute the query
if (@mysql_query ($query)) {
echo "Query was successful, it was $query"; //DEBUG CODE
//header ("Location: ./index.php"); //redirect to UserType index page
mysql_close(); //close the database
exit(); //exit the script
} else {
echo "<p>Could not update the entry because: <b><br />" .mysql_error(). "</b>.</p>";
echo "<p>The query was <br /><b>$query</b></p>";
exit();
}
echo "<p>This is the first query. The UserID is: $UserID</p>";
echo "<p>The query was:<br /><b>$query</b><br /></p>";
echo 'no valid user has been selected.';
exit;
}
resulting in errors of:
Could not update the entry because:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'.$_GET[\'UserID\'].\'' at line 9.
The query was
UPDATE user SET Username='Banner', Password='woof', FirstName='Banner', LastName='The Runt', Email='', AccessLevel=4 WHERE UserID=\'.$_GET[\'UserID\'].\'
It appears this relates to the submit part of my form which is
<input type="hidden" name="UserID" value="'.$_GET['UserID'].'"/>
<input name="submit" type="submit" value="Submit Changes to User"/>
As a result, the value= "'.$GET['UserID'].'" resulting in
'\'.$_GET[\'UserID\'].\''
FINALLY AT THE ROOT OF THE PROBLEM! The offender is the Value within the hidden input portion of the form.
Any quick ideas?