Forum Moderators: coopster

Message Too Old, No Replies

Parse error: parse error, unexpected $end

I get an error in the following code

         

nil111

5:07 am on Jul 15, 2008 (gmt 0)

10+ Year Member



saying:
Parse error: parse error, unexpected $end in in line 63(I have shown in code this line)

this is the code:

<!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>Update Users</title>
</head>

<body>
</body>

<?php
global $gid;
$gname = $_GET['x'] ;
$db_host = 'localhost';
$db_user = 'root';
$db_pwd = 'dba';

$database = 'saberplex';
$table = 'user_groups';

if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");

if (!mysql_select_db($database))
die("Can't select database");

$result = mysql_query("SELECT * FROM {$table} WHERE ug_name like '".$gname."'");

if (!$result) { die("Query to show fields from table failed");
}
else
{
while ($row = mysql_fetch_array($result) )
{
$groupcode = $row['ug_code'];
$groupname = $row['ug_name'];
$gid = $row['ug_id'];
}
?>

<form name="updateform" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<tr>Group Code:<INPUT TYPE=text NAME="txtgcode" SIZE=20 class=textbox value="<?php echo $groupcode; ?>"></tr>
<tr>Group Name:<INPUT TYPE=select NAME="cmbgname" SIZE=20 class=combobox value="<?php echo $groupname; ?>"></tr>
<tr><input type=submit name=btnupdate value="Update" /></tr>
<tr><a href="usergroups.php"><input type=submit name=btncancel value="Cancel" /></a></tr>
</form>

<?php
if(isset($_POST['btnupdate']))
{
$groupcode = $_POST['txtgcode'];
$groupname = $_POST['cmbgname'];

if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");
if (!mysql_select_db($database))
die("Can't select database");
$result=mysql_query("UPDATE user_groups SET ug_code='$groupcode', ug_name='$groupname' WHERE ug_id='$gid'")
or die("MYSQL Returned: " . mysql_error());

echo "The User Details have been updated. Thank you!";
}
?>

</html> ///////////////////////this is the line where I get the error

nil111

5:10 am on Jul 15, 2008 (gmt 0)

10+ Year Member



by the way wat is $end? pls help

nil111

5:34 am on Jul 15, 2008 (gmt 0)

10+ Year Member



ok there was a { missing
else
{
while ($row = mysql_fetch_array($result) )
{
$groupcode = $row['ug_code'];
$groupname = $row['ug_name'];
$gid = $row['ug_id'];
}

cameraman

5:38 am on Jul 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yep, you got it.