Hi,guys!I am newbie to php,what wrong with my script?The unexpected $end occur in the end of the script.Is this structure alright for me to display what I need? Thanks...
<?php
include ('dbconn.cfg');// database configuration file
$connection = @mysql_connect("localhost", "root", "") or die("Cannot connect to server!");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Edit Profile</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="80%" height="1142" border="0" align="center" bgcolor="#CCCCFF">
<tr>
<td height="58" colspan="2"> <div align="center"><font face="Arial, Helvetica, sans-serif">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="800" height="300">
<param name="movie" value="flash%20menu/menu2.swf">
<param name="quality" value="high">
<param name="LOOP" value="false">
<embed src="flash%20menu/menu2.swf" width="800" height="300" loop="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object>
</font></div></td>
</tr>
<tr>
<td width="2%"> </td>
<td width="98%" height="223" bgcolor="#CCCCFF">
<div align="left">
<table width="100%" border="0">
<tr>
<td height="44" bgcolor="#CCCCFF"> <font color="#0000FF" size="+2" face="Arial">Edit
Profile</font></td>
</tr>
<tr>
<td height="16" bgcolor="#CCCCFF">
<div align="left"><img src="images/line2.JPG" width="750" height="4"></div></td>
</tr>
<tr>
<td height="24" bgcolor="#CCCCFF"><font color="#000000" face="Arial, Helvetica, sans-serif"><em><strong>Important
Notice:</strong></em></font> </td>
</tr>
<tr>
<td bgcolor="#CCCCFF"><font color="#000000" face="Arial, Helvetica, sans-serif">1.
Email Address is not editable.Kindly <a href="register.php" target="_blank">REGISTER</a> another account with different email address if you need multiple accounts.</font></td>
</tr>
<tr>
<td bgcolor="#CCCCFF"><font color="#000000" face="Arial, Helvetica, sans-serif">2.
Kindly click to change password page if would like to change your password</font></td>
</tr>
<tr>
<td height="25" bgcolor="#CCCCFF">
<div align="left"><img src="images/line2.JPG" width="750" height="4"></div></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="2%"> </td>
<td height="556">
<form action="<? echo htmlentities($HTTP_SERVER_VARS['PHP_SELF']); ?>" method="post" name="editUser" id="editUser">
<table width="100%" height="554" border="0">
<tr>
<td width="25%"><font color="#000000" face="Arial"><strong>Login Details</strong></font></td>
<td width="4%"><font color="#000000"> </font></td>
</tr>
<tr>
<td height="29"><font color="#000000" face="Arial">Email Address</font></td>
<td width="4%"><font color="#000000"> </font></td>
<?
if (isset($_SESSION['gmemberid']))
{
$tbl_name = "member";
$result = mysql_query("SELECT name,email,telephone,address FROM $tbl_name") or
die("Cannot execute query.");
//$result = @($sql, $connection) or die("Cannot execute query.");
$numrow = mysql_num_rows($result);
if ($numrow != 0)
{
for ($counter = 0; $row = mysql_fetch_row($result); $counter++)
{
foreach ($row as $key => $value)
{
//display email address in non-editable mode
if ($key == 1)
{
?>
<td><input type ="text" size = "30" value = "<?php
echo $value; ?>" readonly ="readonly"></td>
</tr>
<tr>
<td height="27"><font color="#000000" face="Arial">Password</font></td>
<td width="4%"><font color="#000000"> </font></td>
<td><font color="#000000" face="Arial"> <a href="changePw.php" target="_blank">Change</a></font>
</td>
</tr>
<tr>
<td height="21"><font color="#000000"> </font></td>
<td width="4%"><font color="#000000"> </font></td>
<td><font color="#000000"> </font></td>
</tr>
<tr>
<td><font color="#000000" face="Arial"><strong>Member Details</strong></font></td>
<td width="4%"><font color="#000000"> </font></td>
</tr>
<?
}
//Display full name in editable mode
else
if ($key == 0)
{
?>
<tr>
<td height='30'><font color='#000000' face='Arial'>Full Name</font></td>
<td width='4%'><font color='#000000'> </font></td>
<td><input type = "text" name = "name" size = "30" value = "<?php
echo $value; ?>"></td>
</tr>
<?
}
else
if ($key == 2)
{
?>
<tr>
<td height="26"><font face="Arial">Telephone Number</font></td>
<td width="4%"> </td>
<td><input type = "text" name = "phone" size = "30" value = "<?php
echo $value; ?>"></td>
</tr>
<?
}
else
{
?>
<tr>
<td height="24"><font face="Arial">Address</font></td>
<td width="4%"> </td>
<td>
<td><textarea name = "address" rows = "3"><?php
echo $value; ?></textarea></td>
</tr>
<?
}
}
}
}
?>
<tr>
<td height="21"><font color="#000000"> </font></td>
<td width="4%"><font color="#000000"> </font></td>
<td><font color="#000000"> </font> </tr>
<tr>
<td height="26"> </td>
<td> </td>
<td><font color="#000000">
<input name="update" type="submit" id="update" value="Update">
<input name="resetEdit" type="reset" id="resetEdit" value="Reset">
</font></td>
</tr>
<tr>
<td height="37" colspan="3">
<div align="left"><font color="#000000"><img src="images/line2.JPG" width="750" height="4"></font></div>
</td>
</tr>
</table>
</form></td>
</tr>
<tr>
<td width="2%"> </td>
<td height="37"> <div align="center"></div></td>
</tr>
</table>
</body>
</html>
<?php
$tbl_name = "member";
if (isset($_POST['update']))
{
$update = mysql_query("
UPDATE
$tbl_name
SET
name = '" . mysql_real_escape_string($_POST['name']) . "',
telephone = '" . mysql_real_escape_string($_POST['phone']) . "',
address = '" . mysql_real_escape_string($_POST['address']) . "'
WHERE
name = '" . mysql_real_escape_string($_REQUEST['name']) . "',
telephone = '" . mysql_real_escape_string($_REQUEST['telephone']) .
"',
address = '" . mysql_real_escape_string($_REQUEST['address']) . "'
");
echo ($update);
exit();
$updatedResult = mysql_query($update) or die(mysql_error());
if ($update)
{
?>
<script type="text/javascript">
alert("Your profile already updated.");
history.back();
</script>
<?php
//THIS CODE IS UNCOMMENTED
//So that people without JS can still see the message.
die("Your profile already updated");
//END
}
}
?>