...

View Full Version : Parse Error on T_Variable.



WeBFreaKZ
01-03-2004, 08:25 PM
There is a problem on line twelve but i cannot find out what is wrong with it

<html>

<head>
<title>Edit Members</title>

</head>

<body>

<?
if(!isset($a)
mysql_connect(localhost,clanxssx,mysql);
@mysql_select_db($members) or die( "Unable to select database");

}
$query="SELECT username, ranking, name FROM members ORDER BY joined DESC";
$result=@mysql_query($query);
if(!$result){
echo('Error selecting member:'.$mysql_error());
exit();
}
if(mysql_num_rows($result)>0){
while($row=mysql_fetch_object($result))
{
?>
<b><? echo $row->hadling; ?></b><i><? echo "formatDate(row->timestamp"; ?></i>
<br>
<a href="edit.php?a=edit&id=<? echo "$row->id"; ?>">Delete</a>
<?
}else{
?>
<b> No Members found in Database</b>
<?
}
mysql_close($link);
}elseif($a=='edit'){
if(!isset($update)){
$link=@mysql_connect(localhost, clanxssx, mysql);
if (!$link){
echo "Error connecting to the database:'.$mysql_error()";
exit();
}
$query="SELECT username, ranking, name FROM members WHERE id='$id'";
$result=@mysql_query($query);
if(!$result){
echo " Error selecting member: '.$mysql_error());
exit();
}
mysql_fetch object($result);
?>
<form name="edit" method="post" action="edit.php?a=edit&id=<? echo '$id' ?>&update=1"> <table width="395" border="0" align="center">
<tr>
<td width="389" bgcolor="#333333"><div align="center" class="style1">Add New Member </div></td>
</tr>
<tr>
<td height="220" bgcolor="#666666"><table width="410" border="0">
<tr>
<td width="127"><span class="style1">Username</span></td>
<td width="273"><span class="style1">
<input name="username" type="text" id="username" value="<? echo($row->username) ?>">
</span></td>
</tr>
<tr>
<td><span class="style1">Password</span></td>
<td><span class="style1">
<input name="password" type="password" id="password" value="<? echo($row->password) ?>">
</span></td>
</tr>
<tr>
<td><span class="style1">Ranking</span></td>
<td><span class="style1">Admin
<input name="ranking" type="radio" value="<? echo($row->ranking) ?>" >
Moderator
<input name="ranking" type="radio" value="<? echo($row->ranking) ?>">
Senior Member
<input name="ranking" type="radio" value="<? echo($row->ranking) ?>">
</span></td>
</tr>
<tr>
<td><span class="style1">Email</span></td>
<td><span class="style1">
<input name="email" type="text" id="email" value="<? echo($row->email) ?>">
</span></td>
</tr>
<tr>
<td height="17"><p class="style1">AIM</p></td>
<td><span class="style1">
<input name="aim" type="text" id="aim" value="<? echo($row->aim) ?>">
</span></td>
</tr>
<tr>
<td><span class="style1">Name</span></td>
<td><input name="name" type="text" id="name" value="<? echo($row->name) ?>"></td>
</tr>
<tr>
<td height="43"><span class="style1">Specialties</span></td>
<td><span class="style1">
Xanga

<input name="specs" type="checkbox" id="specs" value="<? echo($row->specs) ?>">
Websites
<input name="specs" type="checkbox" id="specs" value="<? echo($row->specs) ?>">
Graphics
<input name="specs" type="checkbox" id="specs" value="<? echo($row->specs) ?>">
Flash
<input name="specs" type="checkbox" id="specs" value="<? echo($row->specs) ?>">
<input name="specs" type="text" id="specs" value="<? echo($row->specs) ?>" ONFOCUS="clearDefaultandCSS">
</span></td>
</tr>
</table>
<input name="hiddenfield" type="hidden" value="update">
<input type="submit" name="add" value="Update"></td>
</tr>
</table>
</form>
<?
}else{
$query="UPDATE members SET username='$username', password='$password', ranking='$ranking', name='$name', email='$email', aim='$aim', specs='$specs' WHERE id ='$id'";
$result=@mysql_query($query);
if(!$result){
echo('Error updating member:'.$mysql_error());
exit();
}else{
mysql_close($link);
echo "Update Successful";
}
}elseif($a=='delete'){
$link =@mysql_connect(localhost, clanxssx, mysql);
if(!$link){
echo('Error Connecting to the database:'.$mysql_error());
exit();
}
$query="DELETE FROM members WHERE id='$id'";
$result=@mysql_query($query);
if(!$result){
echo('Error deleting member:'.$mysql_error());
exit();
}
mysql_close($link);
echo('Member Deleted.');
}
?>

Nightfire
01-03-2004, 08:28 PM
if(!isset($a)){

WeBFreaKZ
01-03-2004, 08:30 PM
Parse Error on line 11. Unexpected {

WeBFreaKZ
01-03-2004, 08:33 PM
Never mind i got it.. Now error on line 36 Else If

Nightfire
01-03-2004, 08:39 PM
Indenting your php would be alot easier for you, it's hard to follow what belongs to what. What error is it?

You also got an error here

echo " Error selecting member: '.$mysql_error());

Delete the last ) and change your ' to "

WeBFreaKZ
01-03-2004, 08:48 PM
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in C:\Program Files\Abyss Web Server\htdocs\uncoordinated\scripts\logins\edit.php on line 52

Nightfire
01-03-2004, 08:52 PM
Dunno which line that is, maybe this one?

mysql_fetch_object($result);

Try reading through your code again and read the errors, they do tell you what's wrong

WeBFreaKZ
01-03-2004, 08:57 PM
i still get the same error
NightFire.. Do you have AIM or MSN.. Maybe i can talk to you through there

Nightfire
01-03-2004, 09:36 PM
I only have email. I've attempted to clean your code up, but your checkboxes are all gonna have the same values, incase you didn't know ;)



<html>
<head>
<title>Edit Members</title>
</head>
<body>
<?php
// Saw no point in having the check here, if a connection is open anyway later in the script
$link = mysql_connect("localhost","clanxssx","mysql");
@mysql_select_db($members,$link) or die( "Unable to select database");

if(!isset($a)){

$query="SELECT username, ranking, name FROM members ORDER BY joined DESC";
$result=@mysql_query($query);

if(!$result){
echo('Error selecting member:'.$mysql_error());
exit();
}

if(mysql_num_rows($result)>0){
while($row=mysql_fetch_object($result)){
?>

<b><?php echo $row->hadling; ?></b><i><?php echo formatDate(row->timestamp); ?></i><br>
<a href="edit.php?a=edit&id=<? echo "$row->id"; ?>">Delete</a>

<?php
}

}else{

?>

<b> No Members found in Database</b>

<?php

}

mysql_close($link);
}

elseif($a=='edit'){

if(!isset($update)){
/*
$link=@mysql_connect(localhost, clanxssx, mysql);

if (!$link){

echo "Error connecting to the database:'.$mysql_error()";

exit();

}

Not needed, connection already at the start of script.
*/


$query="SELECT username, ranking, name FROM members WHERE id='$id'";
$result=@mysql_query($query);

if(!$result){
echo " Error selecting member: ".$mysql_error();
exit();

}

mysql_fetch_object($result);

?>

<form name="edit" method="post" action="edit.php?a=edit&id=<?php echo $id ?>&update=1">
<table width="395" border="0" align="center">
<tr>
<td width="389" bgcolor="#333333">
<div align="center" class="style1">Add New Member </div>
</td>
</tr>
<tr>
<td height="220" bgcolor="#666666">
<table width="410" border="0">
<tr>
<td width="127"><span class="style1">Username</span></td>
<td width="273"><span class="style1"><input name="username" type="text" id="username" value="<?php echo $row->username; ?>"></span></td>
</tr>
<tr>
<td><span class="style1">Password</span></td>
<td><span class="style1"><input name="password" type="password" id="password" value="<?php echo $row->password; ?>"></span></td>
</tr>
<tr>
<td><span class="style1">Ranking</span></td>
<td><span class="style1">Admin <input name="ranking" type="radio" value="<?php echo $row->ranking; ?>" >
Moderator <input name="ranking" type="radio" value="<?php echo $row->ranking; ?>">
Senior Member <input name="ranking" type="radio" value="<?php echo $row->ranking; ?>">
</span>
</td>
</tr>
<tr>
<td><span class="style1">Email</span></td>
<td><span class="style1"><input name="email" type="text" id="email" value="<?php echo $row->email; ?>"></span></td>
</tr>
<tr>
<td height="17"><p class="style1">AIM</p></td>
<td><span class="style1"><input name="aim" type="text" id="aim" value="<?php echo $row->aim; ?>"></span></td>
</tr>
<tr>
<td><span class="style1">Name</span></td>
<td><input name="name" type="text" id="name" value="<?php echo $row->name; ?>"></td>
</tr>
<tr>
<td height="43"><span class="style1">Specialties</span></td>
<td><span class="style1">Xanga <input name="specs" type="checkbox" id="specs" value="<?php echo $row->specs; ?>">
Websites <input name="specs" type="checkbox" id="specs" value="<?php echo $row->specs; ?>">
Graphics <input name="specs" type="checkbox" id="specs" value="<?php echo $row->specs; ?>">
Flash <input name="specs" type="checkbox" id="specs" value="<?php echo $row->specs; ?>">
<input name="specs" type="text" id="specs" value="<?php echo $row->specs; ?>" ONFOCUS="clearDefaultandCSS">
</span>
</td>
</tr>
</table>
<input name="hiddenfield" type="hidden" value="update">
<input type="submit" name="add" value="Update">
</td>
</tr>
</table>
</form>

<?php

}else{

$query="UPDATE members SET username='$username', password='$password', ranking='$ranking', name='$name', email='$email', aim='$aim', specs='$specs' WHERE id ='$id'";
$result=@mysql_query($query);

if(!$result){
echo 'Error updating member:'.$mysql_error();
exit();

}else{

mysql_close($link);

echo "Update Successful";

}
}

}elseif($a=='delete'){
/* Not needed
$link =@mysql_connect(localhost, clanxssx, mysql);

if(!$link){

echo('Error Connecting to the database:'.$mysql_error());

exit();

}
*/
$query="DELETE FROM members WHERE id='$id'";
$result=@mysql_query($query);

if(!$result){

echo 'Error deleting member:'.$mysql_error();
exit();

}

mysql_close($link);

echo 'Member Deleted.';
}

?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum