Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-03-2004, 07:25 PM   PM User | #1
WeBFreaKZ
New Coder

 
Join Date: Mar 2003
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
WeBFreaKZ is an unknown quantity at this point
Parse Error on T_Variable.

There is a problem on line twelve but i cannot find out what is wrong with it
PHP Code:
<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(localhostclanxssxmysql);
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(localhostclanxssxmysql);
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.');
}
?>
WeBFreaKZ is offline   Reply With Quote
Old 01-03-2004, 07:28 PM   PM User | #2
Nightfire
Senior Coder

 
Nightfire's Avatar
 
Join Date: Jun 2002
Posts: 4,266
Thanks: 6
Thanked 48 Times in 48 Posts
Nightfire is on a distinguished road
if(!isset($a)){
__________________
Blue Panda
Website Design | 1 Pound Ads | 'ow much? | Coding Geeks
Nightfire is offline   Reply With Quote
Old 01-03-2004, 07:30 PM   PM User | #3
WeBFreaKZ
New Coder

 
Join Date: Mar 2003
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
WeBFreaKZ is an unknown quantity at this point
Parse Error on line 11. Unexpected {
WeBFreaKZ is offline   Reply With Quote
Old 01-03-2004, 07:33 PM   PM User | #4
WeBFreaKZ
New Coder

 
Join Date: Mar 2003
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
WeBFreaKZ is an unknown quantity at this point
Never mind i got it.. Now error on line 36 Else If
WeBFreaKZ is offline   Reply With Quote
Old 01-03-2004, 07:39 PM   PM User | #5
Nightfire
Senior Coder

 
Nightfire's Avatar
 
Join Date: Jun 2002
Posts: 4,266
Thanks: 6
Thanked 48 Times in 48 Posts
Nightfire is on a distinguished road
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 "
__________________
Blue Panda
Website Design | 1 Pound Ads | 'ow much? | Coding Geeks
Nightfire is offline   Reply With Quote
Old 01-03-2004, 07:48 PM   PM User | #6
WeBFreaKZ
New Coder

 
Join Date: Mar 2003
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
WeBFreaKZ is an unknown quantity at this point
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
WeBFreaKZ is offline   Reply With Quote
Old 01-03-2004, 07:52 PM   PM User | #7
Nightfire
Senior Coder

 
Nightfire's Avatar
 
Join Date: Jun 2002
Posts: 4,266
Thanks: 6
Thanked 48 Times in 48 Posts
Nightfire is on a distinguished road
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
__________________
Blue Panda
Website Design | 1 Pound Ads | 'ow much? | Coding Geeks
Nightfire is offline   Reply With Quote
Old 01-03-2004, 07:57 PM   PM User | #8
WeBFreaKZ
New Coder

 
Join Date: Mar 2003
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
WeBFreaKZ is an unknown quantity at this point
i still get the same error
NightFire.. Do you have AIM or MSN.. Maybe i can talk to you through there

Last edited by WeBFreaKZ; 01-03-2004 at 08:03 PM..
WeBFreaKZ is offline   Reply With Quote
Old 01-03-2004, 08:36 PM   PM User | #9
Nightfire
Senior Coder

 
Nightfire's Avatar
 
Join Date: Jun 2002
Posts: 4,266
Thanks: 6
Thanked 48 Times in 48 Posts
Nightfire is on a distinguished road
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

PHP Code:
<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.';
}

?>
__________________
Blue Panda
Website Design | 1 Pound Ads | 'ow much? | Coding Geeks
Nightfire is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:02 PM.


Advertisement
Log in to turn off these ads.