Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Błąd "unexpected $end"
Forum PHP.pl > Forum > PHP
markkoo99
Witam,
Na samym końcu kodu czyli w 117 lini wyskakuje mi błąd:
syntax error, unexpected $end in C:\WebSerwer\Apache2\Apache2\htdocs\drzewo_kat_alss\class\Tree_class.php on line 117
Przepatrzyłem kod i nie znalazłem żadnego błędu związaego ze złym zamknięciem.
Z góry dziękuje za pomoc

  1.  
  2. <?
  3. /**
  4. * @package class
  5. * @author abstract : Laurent Moutard, Arnaud Beauvain, Aurore Moutte, Stéphane Bernhardt
  6. * @version 1.0
  7. */
  8.  
  9. require("Category_class.php");
  10.  
  11. class Tree{
  12.  
  13. /** @var integer root's id in db*/
  14. var $idRoot = 1;
  15.  
  16. /** @var string product's table*/
  17. var $productTable = "product";
  18.  
  19. /** @var string category's table*/
  20. var $categoryTable = "category";
  21.  
  22. /** @var integer category's id choosen*/
  23. var $idCategoryChoosen = "";
  24.  
  25. /** @var string for Listing displayable categories (all those having associated articles and their fathers)*/
  26. var $categoryList = "";
  27.  
  28. /** @var int[] for Listing fathers of the clicked category*/
  29. var $parentsList = array();
  30.  
  31. /** @var integer Size of the fathers list of the selected category*/
  32. var $parentsListSize = 0;
  33.  
  34. /** @var mixed[] containing the tree structure with the requested branch*/
  35. var $tabResult = array();
  36.  
  37. /** @var Builder which creates a character string containing all of the displayable categories,
  38. separated by commas
  39. example : "1,2,15,4,11"
  40. */
  41. function Tree($idCategoryChoosen=null){
  42. if($idCategoryChoosen == null){
  43. $idCategoryChoosen = $this->idRoot;
  44. }
  45. $this->idCategoryChoosen = $idCategoryChoosen;
  46. $categoryChoosen = new category($idCategoryChoosen);
  47. $this->parentsList = explode (",",$categoryChoosen->getParentsList());
  48. $this->parentsListSize = sizeof($this->parentsList);
  49. /** We select categories associated with suitable articles*/
  50. $query1 = "SELECT ".$this->productTable.".id_category,".$this->categoryTable.".parents_list FROM ".$this->productTable.",".$this->categoryTable." WHERE ".$this->productTable.".id_category=".$this->categoryTable.".id GROUP BY ".$this->productTable.".id_category";
  51. if(($result1 = mysql_query($query1))&&mysql_num_rows($result1)) {
  52. $tabListCategory = array();
  53. while($row1=mysql_fetch_array($result1)) {
  54. $tabListCategory = array_merge($tabListCategory,explode(",",$row1['parents_list']));
  55. $tabListCategory = array_unique($tabListCategory);
  56. }
  57. $this->categoryList = implode(", ", $tabListCategory);
  58. }
  59. $this->createTree();
  60. }
  61. /** Recursive method which creates the array which will contain the tree
  62. It doesn't need any parameter when it's called. Those are only used for the recursivity
  63. @param $index integer index used in the recursivity
  64. @param $deep integer contain the node's deep
  65. */
  66. function createTree($index=0,$deep=0){
  67. if($index<$this->parentsListSize){
  68. $idCategory = $this->parentsList[$index];
  69. $query2 = "SELECT id,name FROM ".$this->categoryTable." WHERE id_father='".$idCategory."' AND id In (".$this->categoryList.") ORDER BY name";
  70. if(($result2=mysql_query($query2))&&mysql_num_rows($result2)) {
  71. while($row2 = mysql_fetch_array($result2)) {
  72. $this->tabResult[$row2['id']] = array("name"=>$row2['name'],"deep"=>$deep);
  73. if(in_array($row2['id'],$this->parentsList)){
  74. $index++;
  75. $this->createTree($index,$deep+1);
  76. }
  77. }
  78. }
  79. }
  80. }
  81.  
  82. /** return the tree in an array
  83. @return mixed[] $tabResult
  84. */
  85. function &getTree(){
  86. $this->createArbre();
  87. return($this->tabResult);
  88. }
  89.  
  90. /** show the tree in html*/
  91. function show(){
  92. if(sizeof($this->tabResult)){
  93. ?>
  94. <TABLE border="0" cellspacing="0" cellpadding="2" style="font-size:12px;FONT-FAMILY: Verdana;background-color:#0000BB;">
  95. <TR>
  96. <TD bgcolor="#8888BB">
  97. <a href="<?=$_SERVER['SCRIPT_NAME']?>?idcat=<?=$this->idRoot?>"><font color="#FFFFFF">ROOT</font></a>
  98. </TD>
  99. </TR> <?
  100. while(list($id,$values)=each($this->tabResult)){
  101. ?>
  102. <TR>
  103. <TD>
  104. <?
  105. for($i=0;$i<$values['deep'];$i++){
  106. ?>&nbsp;&nbsp;<?
  107. }
  108. ?>
  109. <a href="<?=$_SERVER['SCRIPT_NAME']?>?idcat=<?=$id?>"><font color="#FFFFFF"><?=$values['name']?></font></a>
  110. </TD>
  111. </TR>
  112. <?
  113. }
  114. ?></TABLE><?
  115. }
  116. }
  117. }
  118. ?>
yevaud
jesli mieszasz html z php, to nie uzywaj nawiasow tylko
<? if(warunek): ?>
<? endif; ?>

<? foreach(warunek): ?>
<? endforeach; ?>

bo inaczej nie sposob sie polapac ktory nawias jest do czego
Crozin
Nie możesz zamknąć bloku PHP przy deklaracji klasy - użyj echo jak już, jednak taki obiekt, nie powinien zajmować się wyświetlaniem HTMLa.
markkoo99
Tylko dalej nie wiem jak to zmienić.
yevaud
zamiast
  1. function show(){
  2. if(sizeof($this->tabResult)){
  3. ?>
  4. <TABLE border="0" cellspacing="0" cellpadding="2" style="font-size:12px;FONT-FAMILY: Verdana;background-color:#0000BB;">
  5. <TR>
  6. <TD bgcolor="#8888BB">
  7. <a href="<?=$_SERVER['SCRIPT_NAME']?>?idcat=<?=$this->idRoot?>"><font color="#FFFFFF">ROOT</font></a>
  8. </TD>
  9. </TR> <?


zrob
  1. function show(){
  2. if(sizeof($this->tabResult)){
  3. echo 'TABLE border="0" cellspacing="0" cellpadding="2" style="font-size:12px;FONT-FAMILY: Verdana;background-color:#0000BB;">
  4. <TR>
  5. <TD bgcolor="#8888BB">
  6. <a href="'. $_SERVER['SCRIPT_NAME'] .'?idcat=.'$this->idRoot?.'"><font color="#FFFFFF">ROOT</font></a>
  7. </TD>
  8. </TR>';

itp
markkoo99
Zmieniłem tak jak pisłeś:
  1. <?php
  2. /**
  3. * @package class
  4. * @author abstract : Laurent Moutard, Arnaud Beauvain, Aurore Moutte, Stéphane Bernhardt
  5. * @version 1.0
  6. */
  7.  
  8. require("Category_class.php");
  9.  
  10. class Tree{
  11.  
  12. /** @var integer root's id in db*/
  13. var $idRoot = 1;
  14.  
  15. /** @var string product's table*/
  16. var $productTable = "product";
  17.  
  18. /** @var string category's table*/
  19. var $categoryTable = "category";
  20.  
  21. /** @var integer category's id choosen*/
  22. var $idCategoryChoosen = "";
  23.  
  24. /** @var string for Listing displayable categories (all those having associated articles and their fathers)*/
  25. var $categoryList = "";
  26.  
  27. /** @var int[] for Listing fathers of the clicked category*/
  28. var $parentsList = array();
  29.  
  30. /** @var integer Size of the fathers list of the selected category*/
  31. var $parentsListSize = 0;
  32.  
  33. /** @var mixed[] containing the tree structure with the requested branch*/
  34. var $tabResult = array();
  35.  
  36. /** @var Builder which creates a character string containing all of the displayable categories,
  37. separated by commas
  38. example : "1,2,15,4,11"
  39. */
  40. function Tree($idCategoryChoosen=null){
  41. if($idCategoryChoosen == null){
  42. $idCategoryChoosen = $this->idRoot;
  43. }
  44. $this->idCategoryChoosen = $idCategoryChoosen;
  45. $categoryChoosen = new category($idCategoryChoosen);
  46. $this->parentsList = explode (",",$categoryChoosen->getParentsList());
  47. $this->parentsListSize = sizeof($this->parentsList);
  48. /** We select categories associated with suitable articles*/
  49. $query1 = "SELECT ".$this->productTable.".id_category,".$this->categoryTable.".parents_list FROM ".$this->productTable.",".$this->categoryTable." WHERE ".$this->productTable.".id_category=".$this->categoryTable.".id GROUP BY ".$this->productTable.".id_category";
  50. if(($result1 = mysql_query($query1))&&mysql_num_rows($result1)) {
  51. $tabListCategory = array();
  52. while($row1=mysql_fetch_array($result1)) {
  53. $tabListCategory = array_merge($tabListCategory,explode(",",$row1['parents_list']));
  54. $tabListCategory = array_unique($tabListCategory);
  55. }
  56. $this->categoryList = implode(", ", $tabListCategory);
  57. }
  58. $this->createTree();
  59. }
  60. /** Recursive method which creates the array which will contain the tree
  61. It doesn't need any parameter when it's called. Those are only used for the recursivity
  62. @param $index integer index used in the recursivity
  63. @param $deep integer contain the node's deep
  64. */
  65. function createTree($index=0,$deep=0){
  66. if($index<$this->parentsListSize){
  67. $idCategory = $this->parentsList[$index];
  68. $query2 = "SELECT id,name FROM ".$this->categoryTable." WHERE id_father='".$idCategory."' AND id In (".$this->categoryList.") ORDER BY name";
  69. if(($result2=mysql_query($query2))&&mysql_num_rows($result2)) {
  70. while($row2 = mysql_fetch_array($result2)) {
  71. $this->tabResult[$row2['id']] = array("name"=>$row2['name'],"deep"=>$deep);
  72. if(in_array($row2['id'],$this->parentsList)){
  73. $index++;
  74. $this->createTree($index,$deep+1);
  75. }
  76. }
  77. }
  78. }
  79. }
  80.  
  81. /** return the tree in an array
  82. @return mixed[] $tabResult
  83. */
  84. function &getTree(){
  85. $this->createArbre();
  86. return($this->tabResult);
  87. }
  88.  
  89. /** show the tree in html*/
  90.  
  91. function show(){
  92.  
  93. if(sizeof($this->tabResult)){
  94.  
  95. echo 'TABLE border="0" cellspacing="0" cellpadding="2" style="font-size:12px;FONT-FAMILY: Verdana;background-color:#0000BB;">
  96.  
  97. <TR>
  98. <TD bgcolor="#8888BB">
  99.  
  100. <a href="'. $_SERVER['SCRIPT_NAME'] .'?idcat=.'$this->idRoot?.'"><font color="#FFFFFF">ROOT</font></a>
  101.  
  102. </TD>
  103.  
  104. </TR>
  105. </TABLE>';
  106.  
  107. }
  108. }
  109. }
  110. ?>


i na 100 wierszu wywala mi taki błąd:
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in C:\WebSerwer\Apache2\Apache2\htdocs\drzewo_kat_alss\class\Tree_class.php on line 100

yevaud
  1. <?php
  2. /**
  3. * @package class
  4. * @author abstract : Laurent Moutard, Arnaud Beauvain, Aurore Moutte, Stéphane Bernhardt
  5. * @version 1.0
  6. */
  7.  
  8. require("Category_class.php");
  9.  
  10. class Tree{
  11.  
  12. /** @var integer root's id in db*/
  13. var $idRoot = 1;
  14.  
  15. /** @var string product's table*/
  16. var $productTable = "product";
  17.  
  18. /** @var string category's table*/
  19. var $categoryTable = "category";
  20.  
  21. /** @var integer category's id choosen*/
  22. var $idCategoryChoosen = "";
  23.  
  24. /** @var string for Listing displayable categories (all those having associated articles and their fathers)*/
  25. var $categoryList = "";
  26.  
  27. /** @var int[] for Listing fathers of the clicked category*/
  28. var $parentsList = array();
  29.  
  30. /** @var integer Size of the fathers list of the selected category*/
  31. var $parentsListSize = 0;
  32.  
  33. /** @var mixed[] containing the tree structure with the requested branch*/
  34. var $tabResult = array();
  35.  
  36. /** @var Builder which creates a character string containing all of the displayable categories,
  37. separated by commas
  38. example : "1,2,15,4,11"
  39. */
  40. function Tree($idCategoryChoosen=null){
  41. if($idCategoryChoosen == null){
  42. $idCategoryChoosen = $this->idRoot;
  43. }
  44. $this->idCategoryChoosen = $idCategoryChoosen;
  45. $categoryChoosen = new category($idCategoryChoosen);
  46. $this->parentsList = explode (",",$categoryChoosen->getParentsList());
  47. $this->parentsListSize = sizeof($this->parentsList);
  48. /** We select categories associated with suitable articles*/
  49. $query1 = "SELECT ".$this->productTable.".id_category,".$this->categoryTable.".parents_list FROM ".$this->productTable.",".$this->categoryTable." WHERE ".$this->productTable.".id_category=".$this->categoryTable.".id GROUP BY ".$this->productTable.".id_category";
  50. if(($result1 = mysql_query($query1))&&mysql_num_rows($result1)) {
  51. $tabListCategory = array();
  52. while($row1=mysql_fetch_array($result1)) {
  53. $tabListCategory = array_merge($tabListCategory,explode(",",$row1['parents_list']));
  54. $tabListCategory = array_unique($tabListCategory);
  55. }
  56. $this->categoryList = implode(", ", $tabListCategory);
  57. }
  58. $this->createTree();
  59. }
  60. /** Recursive method which creates the array which will contain the tree
  61. It doesn't need any parameter when it's called. Those are only used for the recursivity
  62. @param $index integer index used in the recursivity
  63. @param $deep integer contain the node's deep
  64. */
  65. function createTree($index=0,$deep=0){
  66. if($index<$this->parentsListSize){
  67. $idCategory = $this->parentsList[$index];
  68. $query2 = "SELECT id,name FROM ".$this->categoryTable." WHERE id_father='".$idCategory."' AND id In (".$this->categoryList.") ORDER BY name";
  69. if(($result2=mysql_query($query2))&&mysql_num_rows($result2)) {
  70. while($row2 = mysql_fetch_array($result2)) {
  71. $this->tabResult[$row2['id']] = array("name"=>$row2['name'],"deep"=>$deep);
  72. if(in_array($row2['id'],$this->parentsList)){
  73. $index++;
  74. $this->createTree($index,$deep+1);
  75. }
  76. }
  77. }
  78. }
  79. }
  80.  
  81. /** return the tree in an array
  82. @return mixed[] $tabResult
  83. */
  84. function &getTree(){
  85. $this->createArbre();
  86. return($this->tabResult);
  87. }
  88.  
  89. /** show the tree in html*/
  90.  
  91. function show(){
  92.  
  93. if(sizeof($this->tabResult)){
  94.  
  95. echo 'TABLE border="0" cellspacing="0" cellpadding="2" style="font-size:12px;FONT-FAMILY: Verdana;background-color:#0000BB;">
  96.  
  97. <TR>
  98. <TD bgcolor="#8888BB">
  99.  
  100. <a href="'. $_SERVER['SCRIPT_NAME'] .'?idcat='.$this->idRoot.'"><font color="#FFFFFF">ROOT</font></a>
  101.  
  102. </TD>
  103.  
  104. </TR>
  105. </TABLE>';
  106.  
  107. }
  108. }
  109. }
  110. ?>


edit: wywal jeszcze ten znak zapytania ktory zostal po idRoot
markkoo99
Teraz z kolei taki błąd wywala:

Parse error: syntax error, unexpected '.' in C:\WebSerwer\Apache2\Apache2\htdocs\drzewo_kat_alss\class\Tree_class.php on line 100
Crozin
Forum to nie parser... masz prosty błąd w składni - masz jak byk napisane w której linii - se popraw!
markkoo99
Wiem Kolego ze forum to nie parser smile.gif

Zmieniłem linie z tej :
  1. <a href="'. $_SERVER['SCRIPT_NAME'] .'?idcat='.$this->idRoot.'"><font color="#FFFFFF">ROOT</font></a>


na:
  1. <a href="'. $_SERVER['SCRIPT_NAME'] .'?idcat='.$this->idRoot'."><font color="#FFFFFF">ROOT</font></a>


Tylko nie wiem czy dobrze zmieniłem. Teraz zaczeło mi wywalać błąd odnosnie lini 105:
  1. </TABLE>';


syntax error, unexpected ';' in C:\WebSerwer\Apache2\Apache2\htdocs\drzewo_kat_alss\class\Tree_class.php on line 105

Tylko teraz nie wiem czy nie robi błedów po tym jak to zmieniłem.
wookieb
Znowu 9 postów o kupie. ZAINWESTUJ W IDE!!! I TAK, FORUM TO NIE PARSER
Spawnm
Forum nie parser, zamykam.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.