Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > PHP

Reply
 
LinkBack Thread Tools Display Modes
Old 06-30-2005, 09:34 AM   #1 (permalink)
xevean
Recruit
 
Join Date: Jun 2005
Posts: 4
xevean is on a distinguished road
help with alternate row color php script

the code is returning the following error:
Parse error: parse error, unexpected '}', expecting ',' or ';' in /home/linblood/public_html/table.php on line 82
Code:
<?php require_once('Connections/linblood.php'); ?>
<?php
$maxRows_list = 10;
$pageNum_list = 0;
if (isset($_GET['pageNum_list'])) {
  $pageNum_list = $_GET['pageNum_list'];
}
$startRow_list = $pageNum_list * $maxRows_list;

mysql_select_db($database_linblood, $linblood);
$query_list = "SELECT clan, `character`, timezone, avail, email, msn FROM members ORDER BY clan DESC";
$query_limit_list = sprintf("%s LIMIT %d, %d", $query_list, $startRow_list, $maxRows_list);
$list = mysql_query($query_limit_list, $linblood) or die(mysql_error());
$row_list = mysql_fetch_assoc($list);

if (isset($_GET['totalRows_list'])) {
  $totalRows_list = $_GET['totalRows_list'];
} else {
  $all_list = mysql_query($query_list);
  $totalRows_list = mysql_num_rows($all_list);
}
$totalPages_list = ceil($totalRows_list/$maxRows_list)-1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?
$num=20;
// Open the HTML table before the loop
echo '<table width="667" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutDefaultTable-->
  <tr>
    <td width="667" height="19" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="118" height="19" valign="top">clan</td>
          <td width="130" valign="top">character</td>
          <td width="69" valign="top">time zone </td>
          <td width="67" valign="top">availability</td>
          <td width="142" valign="top">email</td>
          <td width="141" valign="top">msn</td>
        </tr>
    </table></td>
	</tr>';
for($i=0;$i<$num;$i++){
  if($i % 2 ==0)
  {
    $bgcolor='#f3f3f3';
  }
  else
  {
    $bgcolor='#e3e3e3';
  }
  	do {
  echo '<tr bgcolor=$bgcolor>
    <td height="19" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>' ?>
          <td width="118" height="19" valign="top" ><?php $row_list['clan']; ?></td>
          <td width="128" valign="top"><?php echo $row_list['character']; ?></td>
          <td width="71" valign="top"><?php echo $row_list['timezone']; ?></td>
          <td width="67" valign="top"><?php echo $row_list['avail']; ?></td>
          <td width="141" valign="top"><?php echo $row_list['email']; ?></td>
          <td width="142" valign="top"><?php echo $row_list['msn']; ?></td>
       <?php echo '</table></td>
  </tr>
  <tr>
    <td height="25">&nbsp;</td>
  </tr>
 
</table>'   
	 }  // line 82
	 ?>
keep in mind that i haven't done any php in about a year, so im a bit rusty...
any help would be greatly apreciated, also i would like the code to be in php, but the html stuff to be in well html (preferably).
xevean is offline   Reply With Quote
Old 06-30-2005, 10:09 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
redhead is on a distinguished road
First off... I'm not quite sure if it will work or not.. but you're using " (double quotes)within your echo string, which by the way is declared as a char, by using ' (single quotes) to enclose it.
I havn't tried to use it like that, so I have no idear if it will work or not..
PHP Code:
...
<?php echo '</table></td>
  </tr>
  <tr>
    <td height="25">&nbsp;</td>
  </tr>
 
</table>'   
     
}  // line 82
If you notice, you have a echo ending just befor the 82.nd line, which isn't rounded off by a ;, if you read the error carefully that is exactly what it describes.
So add a ; after your echo action.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 06-30-2005, 04:25 PM   #3 (permalink)
xevean
Recruit
 
Join Date: Jun 2005
Posts: 4
xevean is on a distinguished road
problem continues

i changed the code but the problem persists it still returns the error...
Code:
      <?php echo '</table></td>
  </tr>
  <tr>
    <td height="25">&nbsp;</td>
  </tr>
 
</table>';
	 }  // line 82
	 ?>
error:

Parse error: parse error, unexpected ';', expecting T_WHILE in /home/linblood/public_html/table.php on line 83
xevean is offline   Reply With Quote
Old 06-30-2005, 10:44 PM   #4 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
redhead is on a distinguished road
I just noticed:
PHP Code:
do {
  echo 
'<tr bgcolor=$bgcolor>
    <td height="19" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>' 
?> 
Shouldn't there be a trailing ; here aswell??

Else I can't seem to find what should be wrong with your code. Perhaps changing every ' to " and visa versa.. To make sure echo is having a string as it's argument.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 07-01-2005, 09:37 AM   #5 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
besides the 2 semicolons you are missing that red pointed out, you're missing an echo tag for $row['clan'].

you also have a 'do{' command for no reason. along with the other changes, just take that line out and you should be good to go.

PHP Code:
<?php require_once('Connections/linblood.php');

$maxRows_list 10;
$pageNum_list 0;
if (isset(
$_GET['pageNum_list'])) {
  
$pageNum_list $_GET['pageNum_list'];
}
$startRow_list $pageNum_list $maxRows_list;

mysql_select_db($database_linblood$linblood);
$query_list "SELECT clan, `character`, timezone, avail, email, msn FROM members ORDER BY clan DESC";
$query_limit_list sprintf("%s LIMIT %d, %d"$query_list$startRow_list$maxRows_list);
$list mysql_query($query_limit_list$linblood) or die(mysql_error());
$row_list mysql_fetch_assoc($list);

if (isset(
$_GET['totalRows_list'])) {
  
$totalRows_list $_GET['totalRows_list'];
} else {
  
$all_list mysql_query($query_list);
  
$totalRows_list mysql_num_rows($all_list);
}
$totalPages_list ceil($totalRows_list/$maxRows_list)-1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?
$num
=20;
// Open the HTML table before the loop
echo '<table width="667" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutDefaultTable-->
  <tr>
    <td width="667" height="19" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="118" height="19" valign="top">clan</td>
          <td width="130" valign="top">character</td>
          <td width="69" valign="top">time zone </td>
          <td width="67" valign="top">availability</td>
          <td width="142" valign="top">email</td>
          <td width="141" valign="top">msn</td>
        </tr>
    </table></td>
    </tr>'
;
for(
$i=0;$i<$num;$i++){
  if(
$i ==0)
  {
    
$bgcolor='#f3f3f3';
  }
  else
  {
    
$bgcolor='#e3e3e3';
  }

  echo 
'<tr bgcolor=$bgcolor>
    <td height="19" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>'
?>
          <td width="118" height="19" valign="top" ><?php echo $row_list['clan']; ?></td>
          <td width="128" valign="top"><?php echo $row_list['character']; ?></td>
          <td width="71" valign="top"><?php echo $row_list['timezone']; ?></td>
          <td width="67" valign="top"><?php echo $row_list['avail']; ?></td>
          <td width="141" valign="top"><?php echo $row_list['email']; ?></td>
          <td width="142" valign="top"><?php echo $row_list['msn']; ?></td>
       <?php echo '</table></td>
  </tr>
  <tr>
    <td height="25">&nbsp;</td>
  </tr>
 
</table>'
;
}  
// line 82
?>
__________________
Mike
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Weird Image Scrolling Script...Please Help mark4man HTML, XML, Javascript, AJAX 3 06-14-2005 07:51 AM
Row Decrement Phantek Everything SQL ( MySQL, MSSQL, DB2, Postgre, Oracle, etc...) 6 05-20-2005 10:59 AM
My first Perl script. Admin All Other Coding Languages 2 05-19-2005 11:09 AM
Executing a server script from PHP sde PHP 4 02-05-2005 11:12 AM


All times are GMT -8. The time now is 04:46 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting