Ancoats Posted March 2, 2009 Share Posted March 2, 2009 Hey all, I am trying to work on a form that will allow a user to edit/update the information that is contained within thier individual member profile via the use of a form. However, I have run into an error of which I cannot seem to find the variable that may be causing this problem... any help? error is Parse error: parse error, unexpected $ in xxx/editprofile.php on line 188 code is: <?php //start the session session_start(); if(!isset($_SESSION['isloggedin'])){ header("Location:index.php"); } //connect to database include ('includes/db.php'); ?> <?php //reference the ismember session $memberID = $_SESSION['ismember']; // form validation if (isset($_POST['psubmit'])){ $firstname = trim($_POST['firstname']); if (strlen($firstname) < 3 || strlen($firstname) > 20) { $error[] = 'name must be between 3 and 20 characters.'; } $lastname = trim($_POST['lastname']); if (strlen($lastname) < 3 || strlen($lastname) > 20) { $error[] = 'last name must be between 3 and 20 chars'; } $userDOB = trim($_POST['userDOB']); if (strlen($userDOB) < 3 || strlen($userDOB) > 20) { $error[] = 'date of birth must be between 3 and 20 chars'; } $userGend = trim($_POST['userGend']); if (strlen($userGend) < 3 || strlen($userGend) > 20) { $error[] = 'Gender must be between 3 and 20 chars'; } $userLoc = trim($_POST['userLoc']); if (strlen($userLoc) < 3 || strlen($userLoc) > 255) { $error[] = 'Location must be between 3 and 255 chars'; } $userInt = trim($_POST['userInt']); if (strlen($userInt) < 3) { $error[] = 'Interests must be more than 3 characters'; } $userDesc = trim($_POST['userDesc']); if (strlen($userDesc) < 3) { $error[] = 'Description must be more than 3 characters'; } // if validation is ok, carry on if(!isset($error)) { //post form data $firstname = trim($_POST['firstname']); $lastname = trim($_POST['lastname']); $userDOB = trim($_POST['userDOB']); $userGend = trim($_POST['userGend']); $userLoc = trim($_POST['userLoc']); $userInt = trim($_POST['userInt']); $userDesc = trim($_POST['userDesc']); //escapes data is magic quotes are disabled on the server if(!get_magic_quotes_gpc()) { $firstname = addslashes($firstname); $lastname = addslashes($lastname); $userDOB = addslashes($userDOB); $userGend = addslashes($userGend); $userLoc = addslashes($userLoc); $userInt = addslashes($userInt); $userDesc = addslashes($userDesc); } //update the member profile already contained in the database $query = "UPDATE memberprofile SET firstname = '$firstname', lastname = '$lastname', userDOB = '$userDOB', userGend = '$userGend', userLoc = '$userLoc', userInt = '$userInt', userDesc = '$userDesc' WHERE memberID = '$memberID' "; mysql_query($query) or die('Error : ' . mysql_error()); echo "<p>member profile updated</p>"; } //close errors } //close if form has been sent //display any errors errors($error); $result = mysql_query("SELECT firstname, lastname, userDOB, userGend, userLoc, userInt, userDesc FROM memberprofile WHERE memberID = '$memberID' ")or die(mysql_error()); $Rows = mysql_num_rows($result); while ($row = mysql_fetch_object($result)) { ?> <form action="<?php echo $dir;?>editprofile=<?php echo $row->memberID;?>" method="post"> <input type="hidden" name="memberID" value="<?php echo $row->memberID;?>" /> <legend>Edit Member Profile</legend> <p><label>First Name:</label> <br /> <input name="firstname" type="text" maxlength="20" VALUE="<?php echo $row->firstname;?>"/> </p> <p> <label>Last Name:</label> <br /> <input name="lastname" type="text" maxlength="20" VALUE="<?php echo $row->lastname;?>"/> </p> <p> <label>Date of Birth:</label> <br /> <input name="userDOB" type="text" maxlength="20" VALUE="<?php echo $row->userDOB;?>"/> </p> <p> <label>Male / Female:</label> <label> <br /> <select name="userGend" id="userGend" VALUE="<?php echo $row->userGend;?>"> <option>Male</option> <option>Female</option> </select> </label> </p> <p> <label>Location:</label> <br /> <label> <input name="userLoc" type="text" maxlength="20" VALUE="<?php echo $row->userLoc;?>"/> </label> </p> <p><label>Interests:<br /> </label> <label> <textarea name="userInt" id="userInt" cols="45" rows="5" VALUE="<?php echo $row->userInt;?>"></textarea> </label> <br /> </p> <p><label>Short Description:</label> <br /> <label> <textarea name="userDesc" id="userDesc" cols="45" rows="5" VALUE="<?php echo $row->userDesc;?>"></textarea> </label> </p> <p><label></label> <br /> <label></label> <br /> </p> <p> <input type="submit" name="psubmit" value="Edit Profile"> </p> </form> Any ideas whats generating the error? im sure its something really simple ive missed but ive been stuck for the past few hours on it cheers for the help in advance Quote Link to comment https://forums.phpfreaks.com/topic/147549-editing-updating-user-profile-information-from-a-database/ Share on other sites More sharing options...
phant0m Posted March 2, 2009 Share Posted March 2, 2009 I'm sorry, but when I paste that into a text editor, I only get 163 lines, not >=188 perhaps you could post only line 188? Quote Link to comment https://forums.phpfreaks.com/topic/147549-editing-updating-user-profile-information-from-a-database/#findComment-774556 Share on other sites More sharing options...
Ancoats Posted March 2, 2009 Author Share Posted March 2, 2009 I'm sorry, but when I paste that into a text editor, I only get 163 lines, not >=188 perhaps you could post only line 188? the rest of the lines are html code... however the full page code is: <?php //start the session session_start(); if(!isset($_SESSION['isloggedin'])){ header("Location:index.php"); } //connect to database include ('includes/db.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <a href="loggedin.php">Back to Main Page</a><br /> <a href="profile.php">View Profile</a><br /> <a href="logout.php">Logout</a><p> This is where you can edit your profile <?php echo $_SESSION['isloggedin']; ?>! </head> <body> <?php //reference the ismember session $memberID = $_SESSION['ismember']; // form validation if (isset($_POST['psubmit'])){ $firstname = trim($_POST['firstname']); if (strlen($firstname) < 3 || strlen($firstname) > 20) { $error[] = 'name must be between 3 and 20 characters.'; } $lastname = trim($_POST['lastname']); if (strlen($lastname) < 3 || strlen($lastname) > 20) { $error[] = 'last name must be between 3 and 20 chars'; } $userDOB = trim($_POST['userDOB']); if (strlen($userDOB) < 3 || strlen($userDOB) > 20) { $error[] = 'date of birth must be between 3 and 20 chars'; } $userGend = trim($_POST['userGend']); if (strlen($userGend) < 3 || strlen($userGend) > 20) { $error[] = 'Gender must be between 3 and 20 chars'; } $userLoc = trim($_POST['userLoc']); if (strlen($userLoc) < 3 || strlen($userLoc) > 255) { $error[] = 'Location must be between 3 and 255 chars'; } $userInt = trim($_POST['userInt']); if (strlen($userInt) < 3) { $error[] = 'Interests must be more than 3 characters'; } $userDesc = trim($_POST['userDesc']); if (strlen($userDesc) < 3) { $error[] = 'Description must be more than 3 characters'; } // if validation is ok, carry on if(!isset($error)) { //post form data $firstname = trim($_POST['firstname']); $lastname = trim($_POST['lastname']); $userDOB = trim($_POST['userDOB']); $userGend = trim($_POST['userGend']); $userLoc = trim($_POST['userLoc']); $userInt = trim($_POST['userInt']); $userDesc = trim($_POST['userDesc']); //escapes data is magic quotes are disabled on the server if(!get_magic_quotes_gpc()) { $firstname = addslashes($firstname); $lastname = addslashes($lastname); $userDOB = addslashes($userDOB); $userGend = addslashes($userGend); $userLoc = addslashes($userLoc); $userInt = addslashes($userInt); $userDesc = addslashes($userDesc); } //update the member profile already contained in the database $query = "UPDATE memberprofile SET firstname = '$firstname', lastname = '$lastname', userDOB = '$userDOB', userGend = '$userGend', userLoc = '$userLoc', userInt = '$userInt', userDesc = '$userDesc' WHERE memberID = '$memberID' "; mysql_query($query) or die('Error : ' . mysql_error()); echo "<p>member profile updated</p>"; } //close errors } //close if form has been sent //display any errors errors($error); $result = mysql_query("SELECT firstname, lastname, userDOB, userGend, userLoc, userInt, userDesc FROM memberprofile WHERE memberID = '$memberID' ")or die(mysql_error()); $Rows = mysql_num_rows($result); while ($row = mysql_fetch_object($result)) { ?> <form action="<?php echo $dir;?>editprofile.php<?php echo $row->memberID;?>" method="post"> <input type="hidden" name="memberID" value="<?php echo $row->memberID;?>" /> <legend>Edit Member Profile</legend> <p><label>First Name:</label> <br /> <input name="firstname" type="text" maxlength="20" VALUE="<?php echo $row->firstname;?>"/> </p> <p> <label>Last Name:</label> <br /> <input name="lastname" type="text" maxlength="20" VALUE="<?php echo $row->lastname;?>"/> </p> <p> <label>Date of Birth:</label> <br /> <input name="userDOB" type="text" maxlength="20" VALUE="<?php echo $row->userDOB;?>"/> </p> <p> <label>Male / Female:</label> <label> <br /> <select name="userGend" id="userGend" VALUE="<?php echo $row->userGend;?>"> <option>Male</option> <option>Female</option> </select> </label> </p> <p> <label>Location:</label> <br /> <label> <input name="userLoc" type="text" maxlength="20" VALUE="<?php echo $row->userLoc;?>"/> </label> </p> <p><label>Interests:<br /> </label> <label> <textarea name="userInt" id="userInt" cols="45" rows="5" VALUE="<?php echo $row->userInt;?>"></textarea> </label> <br /> </p> <p><label>Short Description:</label> <br /> <label> <textarea name="userDesc" id="userDesc" cols="45" rows="5" VALUE="<?php echo $row->userDesc;?>"></textarea> </label> </p> <p><label></label> <br /> <label></label> <br /> </p> <p> <input type="submit" name="psubmit" value="Edit Profile"> </p> </form> </body> </html> line 188 refers to the line after </html> hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/147549-editing-updating-user-profile-information-from-a-database/#findComment-774558 Share on other sites More sharing options...
eagle1771 Posted March 2, 2009 Share Posted March 2, 2009 Hello Ancoats, I am fairly new to Php programming, but the only two things I noticed are: 1) Your form action structure looks unusual (at least to me). What exactly does it do? <form action="<?php echo $dir;?>editprofile.php<?php echo $row->memberID;?>" method="post"> 2) I don't think Php should care, but I noticed in some of your form fields you are leaving off the slash and doing ;?>"> instead of ;?>"/> Quote Link to comment https://forums.phpfreaks.com/topic/147549-editing-updating-user-profile-information-from-a-database/#findComment-774625 Share on other sites More sharing options...
Yesideez Posted March 2, 2009 Share Posted March 2, 2009 That line quoted by eagle1771 does look a little malformed, try this: <form action="<?=$_SERVER['PHP_SELF'].'?id='.$row->memberID;?>" method="post"> Quote Link to comment https://forums.phpfreaks.com/topic/147549-editing-updating-user-profile-information-from-a-database/#findComment-774629 Share on other sites More sharing options...
HuggieBear Posted March 2, 2009 Share Posted March 2, 2009 This content shouldn't be in the <head> </head> tags... <a href="loggedin.php">Back to Main Page</a><br /> <a href="profile.php">View Profile</a><br /> <a href="logout.php">Logout</a><p> This is where you can edit your profile <?php echo $_SESSION['isloggedin']; ?>! Quote Link to comment https://forums.phpfreaks.com/topic/147549-editing-updating-user-profile-information-from-a-database/#findComment-774633 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.