Jump to content

[SOLVED] annoying error


rallokkcaz

Recommended Posts

im currently working on this update form

(it hasn't been working for 3 days now)

and now im getting this error in the code

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/pokebash/public_html/getmetola/edit_profile/default.html on line 76

here is the code

<?php
ob_start();
session_start();
//include config.php file
include('../config.php');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<style>
.words
{
background-color:#16333B;
color:#A9D033;
}
</style>
<?php
$p=$_GET['p'];
//see my ?id= browsing tutorial
switch($p){
default:
//if user isn't logged in lets show him the log in form
if(!isset($_SESSION['username'])){
echo <<< HTMLFORM
<form action='../login.php' method='POST'>
You Must Be logged in to View this page!<br>
Login here:<br>
Username: <input type='text' name='username' class='words'><br>
Password: <input type='password' name='password' class='words'><br>
<input name='login' type='submit' value='Submit' class='words'><br>
Not <a href="../register.php">registered</a>?
</form> //line 30
HTMLFORM;
}else{

//$_SESSION['username'] = the current users 
//username. It will be echoed like "Hi, user!"
echo <<< HTMLFORM
<form name="update" method="post">
<table  cellpadding="2" cellspacing="1" width="400">
  <tr>
    <td wdith="35%">Username:</td>
    <td>{$_SESSION['username']}</td>
  </tr>  
  <tr>
    <td>Full Name:</td>
    <td><input type="text" name="fullname" value="{$_SESSION['fullname']}" /></td>
  </tr><tr>
    <td>Password:</td>
    <td>
<input type="password" name="password" value="" /></td>
  </tr>
<tr>
    <td>About Me:</td>
    <td><textarea height="200px" width="300px" input type="text/html"  name="aboutme" value="" />{$_SESSION['aboutme']}</textarea></td>
  </tr><tr
  <tr>
    <td>Email Address:</td>
    <td><input type="text" name="email" value="{$_SESSION['email']}" /></td>
//line 60  </tr>
  <tr>
    <td colspan="2">
      <input type="submit" name="update" value="Update Profile" >
    </td>
  </tr>
</table>
</form>
HTMLFORM;
///variables...
$update = $_POST['update'];
$fullname = $_POST['fullname'];
$password = md5($_POST['password']);
$aboutme = $_POST['aboutme'];
$email = $_POST['email'];
//if button is pressed
if ($_POST['update']){

$sql= "update users set fullname='$fullname', aboutme='$aboutme' where id='$_SESSION['id']'";
mysql_query($sql) or die(mysql_error());
header(Refresh: 2);
echo "Congratulations! Yout Profile is Updated<br>
} else {
header(Refresh: 2);
echo "Your Profile didn't Update";
?>

does any one know how to fix that?

Link to comment
https://forums.phpfreaks.com/topic/48834-solved-annoying-error/
Share on other sites

theirs a ton of errors

 

here the last part fixed ( well kinda)

if ($_POST['update']){

$sql= "update users set fullname='$fullname', aboutme='$aboutme' where id='{$_SESSION['id']}'";
mysql_query($sql) or die(mysql_error());
header(Refresh: 2); //<<--you have already send data to the page
echo "Congratulations! Yout Profile is Updated<br>";
} else {
header(Refresh: 2);//<<--you have already send data to the page
echo "Your Profile didn't Update";
}
?>

 

 

recommend a re-write

Link to comment
https://forums.phpfreaks.com/topic/48834-solved-annoying-error/#findComment-239344
Share on other sites

ok here is the form without errors

i have no idea what im doing wrong but its not updating

 

<?php
ob_start();
session_start();
//include config.php file
include('../config.php');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<style>
.words
{
background-color:#16333B;
color:#A9D033;
}
</style>
<?php
$p=$_GET['p'];
//see my ?id= browsing tutorial
switch($p){
default:
//if user isn't logged in lets show him the log in form
if(!isset($_SESSION['username'])){
echo <<< HTMLFORM
<form action='../login.php' method='POST'>
You Must Be logged in to View this page!<br>
Login here:<br>
Username: <input type='text' name='username' class='words'><br>
Password: <input type='password' name='password' class='words'><br>
<input name='login' type='submit' value='Submit' class='words'><br>
Not <a href="../register.php">registered</a>?
</form> 
HTMLFORM;
}else{

///variables...
$update = $_POST['update'];
$fullname = $_POST['fullname'];
$password = md5($_POST['password']);
$aboutme = $_POST['aboutme'];
$email = $_POST['email'];
$id = $_SESSION['id'];
//if button is pressed
if ($update)
{
// Get Sandy's record from the "example" table
$result = mysql_query("UPDATE users SET fullname='$fullname', password='$password', aboutme='$aboutme', email='$email'  WHERE id='$id'") 
or die(mysql_error());  

header("Refresh:2");
echo "Profile Updated";
} else {
//$_SESSION['username'] = the current users 
//username. It will be echoed like "Hi, user!"
echo <<< HTMLFORM
<form name="update" action="{$_SERVER['PHP_SELF']}" method="POST">
<table  cellpadding="2" cellspacing="1" width="400">
  <tr>
    <td wdith="35%">Username:</td>
    <td>{$_SESSION['username']}</td>
  </tr>  
  <tr>
    <td>Full Name:</td>
    <td><input type="text" name="fullname" value="{$_SESSION['fullname']}" /></td>
  </tr><tr>
    <td>Password:</td>
    <td>
<input type="password" name="password" value="" /></td>
  </tr>
<tr>
    <td>About Me:</td>
    <td><textarea height="200px" width="300px" input type="text/html"  name="aboutme" value="" />{$_SESSION['aboutme']}</textarea></td>
  </tr><tr
  <tr>
    <td>Email Address:</td>
    <td><input type="text" name="email" value="{$_SESSION['email']}" /></td>
  </tr>
  <tr>
    <td colspan="2">
      <input type="submit" name="update" value="Update Profile" >
    </td>
  </tr>
</table>
</form>
HTMLFORM;

}
}
}
?>

pleeze can someone tell me what im doing wrong!!

 

ive been trying this for 3 days  :( :( :(

Link to comment
https://forums.phpfreaks.com/topic/48834-solved-annoying-error/#findComment-239500
Share on other sites

This is more or less how I would do it, keeping as much to your old script as possible.

 

Regarding your old script, I couldnt work out why you were using the switch in there?  Anyway....

 

Please note I have left a space where you need to update the session values after the insert

 

<?php
ob_start();
session_start();
//include config.php file
include('../config.php');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<style>
.words
{
background-color:#16333B;
color:#A9D033;
}
</style>
<?php
$p = $_GET['p'];
//see my ?id= browsing tutorial
if(!isset($_SESSION['username'])){ ?>
<form action='../login.php' method='POST'>
	You Must Be logged in to View this page!<br>
	Login here:<br>
	Username: <input type='text' name='username' class='words'><br>
	Password: <input type='password' name='password' class='words'><br>
	<input name='login' type='submit' value='Submit' class='words'><br>
	Not <a href="../register.php">registered</a>?
</form> 
<?php
exit();
}
else{

if($_POST['update']){
	// Get Posted Variables...
	$fullname = $_POST['fullname'];
	$password = md5($_POST['password']);
	$aboutme = $_POST['aboutme'];
	$email = $_POST['email'];
	$id = $_SESSION['id'];

	// Get Sandy's record from the "example" table
	$result = mysql_query("UPDATE users SET fullname = '$fullname', password = '$password', aboutme = '$aboutme', email = '$email' WHERE id = '$id'") or die(mysql_error());  

	// wILL NEED TO UPDATE THE SESSION VALUES HERE



echo "<B>Profile Updated</B><br><br>";

?>
<form name="update" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<table  cellpadding="2" cellspacing="1" width="400">
<tr>
    	<td wdith="35%">Username:</td>
    		<td><?php echo $_SESSION['username']; ?></td>
  	</tr>  
  	<tr>
    	<td>Full Name:</td>
    		<td><input type="text" name="fullname" value="<?php echo $_SESSION['fullname']; ?>" /></td>
  	</tr>
  	<tr>
    	<td>Password:</td>
    		<td><input type="password" name="password" value="" /></td>
  	</tr>
	<tr>
    	<td>About Me:</td>
    	<td><textarea height="200px" width="300px" input type="text/html"  name="aboutme" value="" /><?php echo $_SESSION['aboutme']; ?></textarea></td>
  	</tr>
  	<tr>
    	<td>Email Address:</td>
    	<td><input type="text" name="email" value="<?php echo $_SESSION['email']; ?>" /></td>
  	</tr>
  	<tr>
    	<td colspan="2"><input type="submit" name="update" value="Update Profile" ></td>
  	</tr>
</table>
</form>
<?
} ?>

Link to comment
https://forums.phpfreaks.com/topic/48834-solved-annoying-error/#findComment-239524
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.