Jump to content

Recommended Posts

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  :)

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  :)

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 ;?>"/>

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']; ?>!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.