Jump to content


Photo

Syntax Error


  • Please log in to reply
6 replies to this topic

#1 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 26 March 2006 - 12:21 PM


<?php
if($color==1){
echo "<tr bgcolor='#eeeeee'>
<td>".$rows['status']."</td><td>".$rows['imagename']."</td><td>".$rows['date']."</td><td>".$rows['description']."</td>[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]<td>"<A href='/memberseditimages.php?editid='.$id.>Edit</A>"</td>[!--colorc--][/span][!--/colorc--]
</tr>";
// Set $color==2, for switching to other color
$color="2";
}

// When $color not equal 1, use this table row color
else {
echo "<tr bgcolor='#c0c0c0'>
<td>".$rows['status']."</td><td>".$rows['imagename']."</td><td>".$rows['date']."</td><td>".$rows['description']."</td>[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]<td>"<A href='/memberseditimages.php?editid='.$id.>Edit</A>"</td>[!--colorc--][/span][!--/colorc--]?>

I want the edit link to be memberseditimages.php?editid=*editit*, but I keep on getting syntax errors. I played around with double and single quotes, but no luck. Can anyone spot the problem?

#2 annihilate

annihilate
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts
  • LocationUK

Posted 26 March 2006 - 01:01 PM

Try this.
<?php
if ($color == 1)
{
echo '<tr bgcolor="#eeeeee">
<td>'.$rows['status'].'</td><td>'.$rows['imagename'].'</td><td>'.$rows['date'].'</td><td>'.$rows['description'].'</td><td><a href="/memberseditimages.php?editid='.$id.'">Edit</a></td>
</tr>';
// Set $color==2, for switching to other color
$color = 2;
}
// When $color not equal 1, use this table row color
else 
{
echo '<tr bgcolor="#c0c0c0">
<td>'.$rows['status'].'</td><td>'.$rows['imagename'].'</td><td>'.$rows['date'].'</td><td>'.$rows['description'].'</td><td><a href="/memberseditimages.php?editid='.$id.'">Edit</a></td></tr>
?>

Personal site: NewEnigma  |  Java and JSF Discussion

#3 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 26 March 2006 - 02:01 PM

Did what you said, but I get "Parse error: syntax error, unexpected '=' in /home/lpxxfain/public_html/memberseditimages.php on line 23"

#4 annihilate

annihilate
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts
  • LocationUK

Posted 26 March 2006 - 02:06 PM

My fault, didn't close of the last echo statement! Add '; to the end after the last tr.
Personal site: NewEnigma  |  Java and JSF Discussion

#5 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 27 March 2006 - 12:26 PM

Nope, same problem.
Parse error: syntax error, unexpected '=' in /home/lpxxfain/public_html/memberseditimages.php on line 23


code:

<?php
require_once "maincore.php";
require_once "subheader.php";
require_once "side_left.php";

$username = $userdata['user_name'];


$sql="SELECT * FROM registered_files WHERE owner = '$username'";
$result=mysql_query($sql);

// Define $color=1
$color="1";
$rows=mysql_fetch_array($result);
$rows['id'] = $id;
echo '<table width="1000" border="1" align="center" cellpadding="2" cellspacing="0">';
while($rows=mysql_fetch_array($result)){


// If $color==1 table row color = #FFC600
if($color==1){
echo "<tr bgcolor='#eeeeee'>
<td>".$rows['status']."</td><td>".$rows['imagename']."</td><td>".$rows['date']."</td><td>".$rows['description']."</td><td><a href="/memberseditimages.php?editid='.$id.'">Edit</a></td>
</tr>";
// Set $color==2, for switching to other color
$color="2";
}

// When $color not equal 1, use this table row color
else {
echo "<tr bgcolor='#c0c0c0'>
<td>".$rows['status']."</td><td>".$rows['imagename']."</td><td>".$rows['date']."</td><td>".$rows['description']."</td><td><a href="/memberseditimages.php?editid='.$id.'">Edit</a></td>
</tr>";
// Set $color back to 1
$color="1";
}

}
echo '</table>';




require_once "side_right.php";
require_once "footer.php";
?>


#6 annihilate

annihilate
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts
  • LocationUK

Posted 27 March 2006 - 12:36 PM

That is because you have changed my code.
echo "<tr bgcolor='#eeeeee'>
<td>".$rows['status']."</td><td>".$rows['imagename']."</td><td>".$rows['date']."</td><td>".$rows['description']."</td><td><a href="/memberseditimages.php?editid='.$id.'">Edit</a></td>
</tr>";
In the above, that is not what I posted.

Use this:
echo '<tr bgcolor="#eeeeee">
<td>'.$rows['status'].'</td><td>'.$rows['imagename'].'</td><td>'.$rows['date'].'</td><td>'.$rows['description'].'</td>
<td><a href="/memberseditimages.php?editid='.$id.'">Edit</a></td>
</tr>';
And the other echo statement should be this:
echo '<tr bgcolor="#c0c0c0">
<td>'.$rows['status'].'</td><td>'.$rows['imagename'].'</td><td>'.$rows['date'].'</td><td>'.$rows['description'].'</td>
<td><a href="/memberseditimages.php?editid='.$id.'">Edit</a></td>
</tr>';
And I would change lines like $color = "2"; to $color = 2;
Personal site: NewEnigma  |  Java and JSF Discussion

#7 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 27 March 2006 - 11:03 PM

Oooh! Thanks, you are awesome ;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users