Connecting Tech Pros Worldwide Forums | Help | Site Map

Parse errors after intalling JBook

Newbie
 
Join Date: Jun 2007
Posts: 3
#1: Jun 27 '07
I downloaded Jbook component and created link named " Extended Search" on my top menu, link type "component- Jbook" but when I click " Extended Search" button I am getting following error:

Parse error: syntax error, unexpected ';', expecting T_FUNCTION in C:\wamp\www\Joomla_1.0.12-Stable-Full_Package\components\com_jbook\jbook.html.php on line 188

What does it mean ?

jbook.html.php File:
Expand|Select|Wrap|Line Numbers
  1.  </td>
  2.       </tr>
  3.       <tr><td colspan=3>
  4.     <!-- Hack by ICS : delete HR
  5.     <HR> -->
  6.     </td></tr>
  7.           <?php    $k = 1 - $k; }} ?>                         <----- line 188
  8.         </table>
  9.  
  10. <!-- Hack by ICS : add return button for search task -->        
  11.  
[Please use CODE tags when posting source code. Thanks! --pbmods]

Also, after installing jbook component shouldn't the search by book title and authors name component appear on my site automatically without having it linked to my menu ?

I am using WAMP 5 and I have Joomla 1.0.12 site.
Pls help !!!
Thanks

pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#2: Jun 27 '07

re: Parse errors after intalling JBook


Changed thread title to better describe the problem (did you know that threads whose titles contain phrases such as 'need help' actually get FEWER responses?).
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,751
#3: Jun 28 '07

re: Parse errors after intalling JBook


Well, judging by that single line of PHP you gave us, Id try to remove the two '}' and see what happens.
Newbie
 
Join Date: Jun 2007
Posts: 3
#4: Jun 28 '07

re: Parse errors after intalling JBook


[CODE TAGS REMOVED DUE TO FORUM DISPLAY BUG]
MODERATOR

Quote:

Originally Posted by Atli

Well, judging by that single line of PHP you gave us, Id try to remove the two '}' and see what happens.

I removed two '}' as u suggested. Now, I am getting following error:

Parse error: syntax error, unexpected $end in C:\wamp\www\Joomla_1.0.12-Stable-Full_Package\components\com_jbook\jbook.html.php on line 494

<?php
/**
* Course HTML
*
* @ Copyright (C) 2005 Jan Schulz-Hofen
* @ All rights reserved
* @ Released under GNU/GPL License: http://www.gnu.org/copyleft/gpl.html
* @ This component is derived from the com_booklist component by Yann Bouan which is derived from the mambo com_weblinks component
**/

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

//require_once( "includes/HTML_toolbar.php" );

class HTML_Book {

function displaylist( &$categories, &$rows, $catid, &$currentcat ) {
global $Itemid, $mosConfig_live_site,$mosConfig_absolute_path,$dat abase,$mainframe;

?>

<table width="100%" cellpadding="4" cellspacing="0" border="0" align="center" class="contentpane">
<tr>
<td colspan="2">
<table border=0><tr><td width=40%>
<span class="componentheading">
<?php
if (($currentcat->title)<>''){
echo $currentcat->title;
} else {
echo _GENERIC_NAME;
}
?>
</span>
<?
echo "<p />"._CATEGORY.": ".categoryParentLI($catid,"index.php?option=com_jb ook","catid");
?>
</td>
<td width=40% valign=top><div align=right>
<form action=index.php>
<input type=hidden name=option value=com_jbook>
<input type=hidden name=Itemid value=<?=$Itemid?>>
<!-- Hack by ICS : was present twice (+reorder)
<input type=hidden name=option value=com_jbook>
-->
<input type=hidden name=task value=search>

<table><tr><td>
<input type=text name=phrase>
</td><td align=right>
<span align=right>
<input type=submit value='<? echo _SEARCH;?>'>
</span>
</td></tr>
<tr><td colspan=2>
<input type=radio name=mode value='0' checked><? echo _ONLY_TITLE;?>
<input type=radio name=mode value='1'><? echo _TITLE_AND_HTML;?>

</td></tr></table>

</form>
</span>
</td>
</tr>
</table>

</td>
<tr>
<td width="60%" valign="top" class="contentdescription" colspan="2">
<?php if (($currentcat->image)<>'') {
$img='stories/'.$currentcat->image;
$align=$currentcat->image_position;
} else {
$img='stories/courses.jpg';
$align='right';
}

?>

<?php if (($currentcat->description)<>'') {
echo $currentcat->description;
}
?>
</td>
</tr>
<?php

if (count( $categories )) {
foreach ($categories as $cat) {
?>
<tr>
<td valign="top" width="5"><img src="<?php echo $mosConfig_live_site;?>/images/M_images/arrow.png" alt="" />&nbsp;</td><td>
<a href="<?php echo sefRelToAbs("index.php?option=com_jbook&amp;Itemid =$Itemid&amp;catid=$cat->catid"); ?>" class="category">
<?php echo $cat->title;?></a>&nbsp;<span class="small">(<?php
if ($cat->numlinks==0) echo _BOOK_ZERO;
if ($cat->numlinks==1) echo _BOOK_ONE;
if ($cat->numlinks>1) echo $cat->numlinks._BOOK_MORE;

?>)</span><br /><? echo $cat->catdesc;?></td>
</tr>
<?php
}
?>
</table>
<?php
}

// Hack by ICS : add test on catid
if ($catid<>0){
HTML_Book::displaylistraw($rows );}

?>

<?php
// Hack by ICS : add test on catid
if ($catid=0){
echo "<br>";
echo "<b><a href='javascript:history.go(-1)'>"._BACK."</a></b>";
echo "<br>";
}
?>

<?php

}


function displaylistraw( &$rows , $showcat=0) {
global $Itemid, $mosConfig_live_site,$mosConfig_absolute_path,$dat abase,$mainframe;
?>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?php
$tabclass = array("sectiontableentry1", "sectiontableentry2");
$k = 0;
$j=1;

if (sizeof($rows)==0) {
echo _NO_BOOK;
} else {
foreach ($rows as $row) {
if ($row->published==0) continue;
?>
<tr class="<?php echo $tabclass[$k]; ?>">

<td align="left" valign=top>
<?php echo $j++; ?>.
</td>
<td valign=top>
<a class="category" href="<?php echo sefRelToAbs("index.php?option=com_jbook&amp;task=v iew&amp;Itemid=$Itemid&amp;catid=$row->catid&amp;id=$row->id"); ?>">
<?
$cover_s=$mosConfig_live_site."/images/jbook_cover/".$row->id."_s.jpg";
$Abscover_s=$mosConfig_absolute_path."/images/jbook_cover/".$row->id."_s.jpg";
if (!file_exists($Abscover_s)) $cover_s=$mosConfig_live_site."/components/com_jbook/images/nocover.jpg";
echo "<img id=\"covers\" src=\"$cover_s\" border=0>";
?>
</a>
</td>
<td valign=top>
<a href="<?php echo sefRelToAbs("index.php?option=com_jbook&amp;task=v iew&amp;Itemid=$Itemid&amp;catid=$row->catid&amp;id=$row->id"); ?>"><?php echo $row->title; ?></a>
<?
$database->setQuery( "SELECT a.*"
. "\nFROM #__jbauthor AS a"
. "\nLEFT JOIN #__jbbookauth AS ba ON ba.idauth = a.id"
. "\nWHERE ba.idbook=$row->id"
. "\nORDER BY a.name"
);

$authorList = $database->loadObjectList();
if ($authorList) echo _BY_AUTH." ";
foreach ($authorList as $c=>$auth) {
?>
<a href="<?php echo sefRelToAbs("index.php?option=com_jbook&amp;task=v iewAuth&amp;Itemid=$Itemid&amp;catid=$row->catid&amp;id=$auth->id"); ?>"><?php echo $auth->name; ?></a><?php if ($c!=(sizeof($authorList)-1)) echo ", ";
}
?>
<br />
<?php echo substr($row->html,0,100);
if (strlen($row->html)>100) echo _OTHER_DETAIL;

if ($showcat) echo "<br>"._CATEGORY.": ".categoryParentLI($row->catid,"index.php?option=com_jbook","catid");
?>
</td>
</tr>
<tr><td colspan=3>
<!-- Hack by ICS : delete HR
<HR> -->
</td></tr>
<?php $k = 1 - $k; ?>
</table>

<!-- Hack by ICS : add return button for search task -->
<br>
<b><a href='javascript:history.go(-1)'><?php echo _BACK?></a></b>
<br>

<?php

}



function showItem( &$currItem ,&$currentcat ) {
global $Itemid, $mosConfig_live_site,$mosConfig_absolute_path,$dat abase,$my,
$conf_link_url,$conf_link_alt;
?>



<!-- Hack by ICS : New table structure -->
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center" class="contentpaneopen">
<tr>
<td valign="top" colspan="2">
<span class="componentheading">
<?php echo $currItem->title; ?>
</span>
<?php
$database->setQuery( "SELECT a.*"
. "\nFROM #__jbauthor AS a"
. "\nLEFT JOIN #__jbbookauth AS ba ON ba.idauth = a.id"
. "\nWHERE ba.idbook=$currItem->id"
. "\nORDER BY a.name" );

$authorList = $database->loadObjectList();
if ($authorList) echo _BY_AUTH." ";
foreach ($authorList as $c=>$auth) {
?>
<a href="<?php echo sefRelToAbs("index.php?option=com_jbook&amp;task=v iewAuth&amp;Itemid=$Itemid&amp;catid=$row->catid&amp;id=$auth->id"); ?>"><?php echo $auth->name; ?></a><?php if ($c!=(sizeof($authorList)-1)) echo ", ";
}

echo "<br>"._CATEGORY.": ".categoryParentLI($currItem->catid,"index.php?option=com_jbook","catid");
echo "<br>&nbsp;<br>";
?>

</td>
</tr>
<tr>
<td valign="top" width="180px">
<?
$cover_l=$mosConfig_live_site."/images/jbook_cover/".$currItem->id."_l.jpg";
$Abscover_l=$mosConfig_absolute_path."/images/jbook_cover/".$currItem->id."_l.jpg";
if (!file_exists($Abscover_l)) $cover_l=$mosConfig_live_site."/components/com_jbook/images/nocover.jpg";
echo "<img id=\"coverl\" src=\"$cover_l\" border=0>";
?>
</td>
<td valign="top" class="contentdescription">
<?php $database->setQuery( "SELECT * FROM #__jbeditor WHERE id=$currItem->ideditor");
$editor = $database->loadObjectList();
// hack by ICS : added strong
if ($editor) echo "<p /><strong>".strtoupper(substr(_EDITOR,0,1)).substr( _EDITOR,1)." : ".$editor[0]->name."</strong>";
if ($currItem->pag) echo "<br /><strong>"._PAGES." : ".$currItem->pag."</strong>";
if ($currItem->price) echo "<br /><strong>"._PRICE." : ".$currItem->price."</strong>" ;
if ($currItem->isbn) echo "<br /><strong>ISBN : <a href='$conf_link_url".$currItem->isbn."' alt='$conf_link_alt'>".$currItem->isbn."</a></strong>";
echo "<br>";
echo $currItem->html;
?>
</td>
</tr>

</table>
<hr>


<!-- Hack by ICS : correct table structure / new table structure -->
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td nowrap="nowrap" valign="top">
<? if ($currItem->vote) {echo _VOTE."&nbsp;:&nbsp;";}?>
</td>
<td>
<?php
// display voting
for ($i=0;$i<$currItem->vote;$i++)
echo "<img src=\"components/com_jbook/images/star.gif\">";
for ($i=$currItem->vote;$i<5;$i++)
echo "<img src=\"components/com_jbook/images/greystar.gif\">";
// Hack by ICS - lang for votes and hits
echo " - ";
if ($currItem->numvote==0) echo _VOTE_ZERO;
if ($currItem->numvote==1) echo _VOTE_ONE;
if ($currItem->numvote>1) echo $currItem->numvote._VOTE_MORE;
echo " (";
if ($currItem->hits==0) echo _HITS_ZERO;
if ($currItem->hits==1) echo _HITS_ONE;
if ($currItem->hits>1) echo $currItem->hits._HITS_MORE;
echo ")";
?>
</td>
</tr>
<tr>
<td colspan="2">
<?php

if ($my->gid>0) {
// a faire : voir si l'appel à voting est correct ?
echo voting($currItem->id,$Itemid);
?>
<div id="newoption"></div>
<script language=javascript>
function hideShow (toShow) {
elem=document.getElementById('newoption');
if (toShow == 'newComment') {
elem.innerHTML="<div id='newcomment'><form><input type='hidden' name='option' value='com_jbook' /><input type='hidden' name='Itemid' value='<? echo $Itemid; ?>' /><input type='hidden' name='id' value='<? echo $currItem->id; ?>' /><input type='hidden' name='task' value='saveComment' /><textarea name='comment' rows='5' cols='50'></textarea><br><input class='button' type='submit' value='<?php echo _SEND_COMMENT; ?>'><input type='hidden' name='pop' value='0' /><input type='hidden' name='section' value='book' /></form></div>";
}
if (toShow == 'newEmailMessage') {
elem.innerHTML="<div id='newemailmessage'><form><?php echo _YOUR_QUESTION_HERE; ?><br><textarea name='comment' rows='5' cols='50'></textarea><br><input type='checkbox' name='sendcopy' value='1'> <?php echo _SEND_COPY; ?><br><input type='hidden' name='task' value='sendMessage' /><input type='hidden' name='pop' value='0' /><input type='hidden' name='option' value='com_jbook' /><input type='hidden' name='Itemid' value='<? echo $Itemid; ?>' /><input type='hidden' name='id' value='<? echo $currItem->id; ?>' /><input type='hidden' name='section' value='book' /><input type='hidden' name='catid' value='<?php echo $_GET['catid']; ?>'><input class='button' type='submit' value='<?php echo _SEND_MESSAGE; ?>'></form></div>";
}
}
</script>
<?
}
else {
echo _NO_RATE_USER;
}
?>
</td>
</tr>
</table>




<!-- Hack by ICS : correct table structure / new table structure -->
<table width="100%">
<tr>
<td>
<?
$sql="SELECT #__jbcomment.*,#__users.name,#__users.username FROM #__jbcomment "
. "\nLEFT JOIN #__users ON #__jbcomment.userid=#__users.id"
. "\nWHERE bookid=".$currItem->id;
$database->setQuery($sql);
$database->query();
$rows = $database->loadObjectList();
HTML_Book::showComment($rows);
?>
</td>
</tr>
</table>

<br>
<b><a href='javascript:history.go(-1)'><?php echo _BACK?></a></b>
<br>

<?php




}



function showAuth( &$currItem ) {
global $Itemid, $mosConfig_live_site,$mosConfig_absolute_path,$dat abase;

?>
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center" class="contentpaneopen">
<tr>
<td valign="top">
<span class="componentheading">
<?php
echo $currItem->name;
?>
</span>
<p />
<?
if ($currItem->html) echo $currItem->html;
?>
<!-- Hack by ICS : add br -->
<br /> <br />
</td>
</tr>
<tr>
<td valign="top" class="contentdescription">
<?
$sql="SELECT * FROM #__jbbook LEFT JOIN #__jbbookauth ON #__jbbookauth.idbook=#__jbbook.id WHERE #__jbbookauth.idauth=".$currItem->id;
$database->setQuery($sql);
$rows = $database->loadObjectList();
if ($rows) {
// hack by ICS : add class
echo "<div class=\"contentheading\">"._OTHER_BOOKS_SAME_AUTH. "</div><p />";
HTML_Book::displaylistraw( $rows ,1);
}
else {
echo "<hr>"._NO_OTHER_BOOKS_SAME_AUTH."<p />";
}
?>
</td>
</tr>
</table>
<br />
<!-- Hack by ICS : duplicate
<b>
<a href='javascript:history.go(-1)'><?php echo _BACK?></a></b>
<br /> -->

<?php
}


// Hack by ICS : add table header, correct table structure
function showComment( $rows) {
global $Itemid, $mosConfig_live_site,$mosConfig_absolute_path,$dat abase,$mainframe,$my;
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">

<?php
$tabclass = array("sectiontableentry1", "sectiontableentry2");
$k = 0;
$j=1;

if (sizeof($rows)==0) {
echo _NO_COMMENT;
}
else {
?>
<tr>
<td class="sectiontableheader">
<?php echo _COMMENT_BY ?>
</td>
<td class="sectiontableheader">
<?php echo _COMMENTS ?>
</td>
</tr>

<?php
foreach ($rows as $row) {
if (($row->published==0) AND ($my->gid!=2))continue;
?>
<tr class="<?php echo $tabclass[$k]; ?>">
<td valign=top>
<?
if ($my->gid>=2) {
$img = $row->published ? 'tick.png' : 'publish_x.png';
$status=$row->published? 0:1;
$url = "index.php?Itemid=$Itemid&id=$row->id&task=modifyComment&option=com_jbook&section=bo ok&status=$status";
?>
<a href="<?php echo $url; ?>">&nbsp;
<img src="images/<?php echo $img; ?>" border="0"></a>&nbsp;
<?
}
echo $row->name;
?>
</td>
<td valign=top>
<?php echo $row->text; ?>
</td>
</tr>
<?php $k = 1 - $k; }} ?>
</table>

<?php
}
}




function voting($id,$Itemid) {
$html .= '<form method="post" action="' . sefRelToAbs( 'index.php' ) . '">';
$img = '';
$url = @$_SERVER['REQUEST_URI'];
$url = ampReplace( $url );

$html .= '<span class="content_vote">';
$html .= '<input class="button" type="submit" name="submit_vote" value="'. _RATE_BOOK .'" />&nbsp;';
$html .= _VOTE_POOR;
$html .= '<input type="radio" alt="vote 1 star" name="user_rating" value="1" />';
$html .= '<input type="radio" alt="vote 2 star" name="user_rating" value="2" />';
$html .= '<input type="radio" alt="vote 3 star" name="user_rating" value="3" />';
$html .= '<input type="radio" alt="vote 4 star" name="user_rating" value="4" />';
$html .= '<input type="radio" alt="vote 5 star" name="user_rating" value="5" checked="checked" />';
$html .= _VOTE_BEST;
$html .= '<p>';
$html .= '<input class="button" type="button" name="show" value="'. _COMMENT_BOOK .'" onClick="javascript:hideShow (\'newComment\')">';
$html .= '<input class="button" type="button" name="show" value="'. _ASK_MORE_INFO .'" onClick="javascript:hideShow (\'newEmailMessage\')">';
$html .= '<input type="hidden" name="task" value="vote" />';
$html .= '<input type="hidden" name="pop" value="0" />';
$html .= '<input type="hidden" name="option" value="com_jbook" />';
$html .= '<input type="hidden" name="Itemid" value="'. $Itemid .'" />';
$html .= '<input type="hidden" name="id" value="'. $id .'" />';
$html .= '<input type="hidden" name="section" value="book" />';

$html .= '</span>';
$html .= '</form>';
return $html;
}


?>

hope you can help.
Newbie
 
Join Date: Jun 2007
Posts: 3
#5: Jun 28 '07

re: Parse errors after intalling JBook


Quote:

Originally Posted by Atli

Well, judging by that single line of PHP you gave us, Id try to remove the two '}' and see what happens.

I removed two '}' as u suggested. Now, I am getting following error:

Parse error: syntax error, unexpected $end in C:\wamp\www\Joomla_1.0.12-Stable-Full_Package\components\com_jbook\jbook.html.php on line 489

line 489 is end of scripts

Expand|Select|Wrap|Line Numbers
  1. $html .= '</span>';
  2.         $html .= '</form>';
  3.         return $html;
  4.     }
  5. ?>
<---- line 489

hope you can help
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#6: Jun 28 '07

re: Parse errors after intalling JBook


Heya, lolamk.

You're getting this error because there's a conditional somewhere that isn't closing out properly.

My recommendation is to put those '}'s back in, and then look at the line directly before the '}' that's causing the error.
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,751
#7: Jun 28 '07

re: Parse errors after intalling JBook


It is extremely hard to debug this code because of the way it was inlined into the HTML markup, a method that I think should be avoided at all cost.

It seems that the author of this code sometimes uses '<?php' and other times '<?' when using PHP code. I would change the '<?' into '<?php', as this can sometimes cause random errors, and it will by Default on recent PHP builds.

You need to find ever function, conditional and loop in the code and mark their opening and closing brackets '{..}', as this is most likely a case of either an extra bracket or a missing bracket.

If this is not the case the error you last posted would indicate that a function is being referenced but the () is missing.
Reply