Se connecter avec
S'enregistrer | Connectez-vous

Parser error

Dernière réponse : dans Programmation

Bonjour à tous,
Je tourne en rond depuis plusieurs jours pour trouver d'où vient mon erreur. Voilà ce que me retourne le scripts :
Parse error: parse error in C:\xampp\***\***\***\***\script.php on line 196

Et voilà ma partie de code où ce trouve l'erreur :

  1. function parsechecks( &$html, $name, $sql, $mask, $num_columns = 1, $add = 0 )
  2. {
  3. if ( ( $sql ) )
  4. {
  5. $i = 0;
  6. $total_checks = (); // ICI CE TROUVE LA LIGNE 196
  7. $in_column = ceil( ( $total_checks + $add ) / $num_columns );
  8. do
  9. {
  10. if ( !( $row = ( ) ) )
  11. {
  12. break;
  13. }
  14. else
  15. {
  16. ++$i;
  17. $html->setvar( "id", $row[0] );
  18. $html->setvar( "title", $row[1] );
  19. }
  20. if ( $mask & 1 << $row[0] - 1 )
  21. {
  22. $html->setvar( "checked", " checked" );
  23. }
  24. else
  25. {
  26. $html->setvar( "checked", "" );
  27. }
  28. if ( $i % $in_column == 0 && $i != 0 && ( $i != $total_checks || 0 < $add ) && $num_columns != 1 )
  29. {
  30. $html->parse( $name."_column", true );
  31. }
  32. else
  33. {
  34. $html->setblockvar( $name."_column", "" );
  35. }
  36. $html->parse( $name, true );
  37. } while ( 1 );
  38. ();
  39. }
  40. }
  41.  
  42. }


Merci de m'aider !
Amicalement

Autres pages sur : parser error

Lassé par la pub ? Créez un compte

OmaR a dit :
Salut,

Parce que ça te parait normal à toi de déclarer une variable en lui mettant () ?
Tu veux peut être l'initialiser à 0 par exemple ?


Salut,
Cette portion de script doit faire afficher les options de menu si on est un client enregistré ou non (avec un option payante et client libre)
J'ai bien tenté d'initialiser la variable à "0", mais çà m'indique la même erreur ligne 38 dans l'exemple du post. Et même en initialisant cette variable ligne 38 à "0" également, je me retrouve avec une page qui ne charge que la moitié des modules et aucune images (templates)

Merci de ta réponse
Expert Programmation

Mais il doit te manquer des noms de fonctions ou je sais pas quoi... Ou sinon y'a des choses que je ne connais pas...
Mais je n'ai jamais vu de choses de ce genre:
  1. $total_checks = ();
  2. if ( !( $row = ( ) ) )
  3. ();


C'est comme si ça voulait appeler des fonctions, mais que le nom des fonctions n'étaient pas indiquées, et il resterait que les parenthèses...
D'où est-ce que ça vient ton code ?


C'est un code de class qui doit débloquer des options. Je te file l'intégralité du script, peut être que tu y verra plus clair :

  1. <?php
  2. class cheader extends chtmlblock
  3. {
  4.  
  5. var $message_template = "";
  6.  
  7. function cheader( $name, $html_path )
  8. {
  9. $this->chtmlblock( $name, $html_path );
  10. }
  11.  
  12. function parseblock( &$html )
  13. {
  14. global $g;
  15. global $g_user;
  16. global $g_info;
  17. global $area;
  18. global $p;
  19. if ( 0 < $g_user['gold_days'] )
  20. {
  21. $baner = get_banner( "top_gold" );
  22. }
  23. else
  24. {
  25. $baner = get_banner( "top" );
  26. }
  27. if ( $baner !== false )
  28. {
  29. $html->setvar( "banner_top", $baner );
  30. $html->parse( "banner_top", true );
  31. }
  32. if ( $area == "login" )
  33. {
  34. foreach ( $g_user as $k => $v )
  35. {
  36. $html->setvar( $k, $v );
  37. }
  38. }
  39. foreach ( $g_info as $k => $v )
  40. {
  41. $html->setvar( $k, $v );
  42. }
  43. if ( isset( $g['options']['top_select'] ) && $g['options']['top_select'] == "Y" )
  44. {
  45. $dir = $g['path']['dir_lang']."main/";
  46. if ( is_dir( $dir ) && ( $dh = opendir( $dir ) ) )
  47. {
  48. while ( ( $file = readdir( $dh ) ) !== false )
  49. {
  50. $html->setvar( "language_value", $file );
  51. $html->setvar( "language_title", ucfirst( $file ) );
  52. $html->parse( "language", true );
  53. }
  54. closedir( $dh );
  55. }
  56. $dir = $g['path']['dir_tmpl']."main/";
  57. if ( is_dir( $dir ) && ( $dh = opendir( $dir ) ) )
  58. {
  59. while ( ( $file = readdir( $dh ) ) !== false )
  60. {
  61. $html->setvar( "template_value", $file );
  62. $html->setvar( "template_title", ucfirst( $file ) );
  63. $html->parse( "template", true );
  64. }
  65. closedir( $dh );
  66. }
  67. $html->parse( "view", true );
  68. }
  69. foreach ( $g_info as $k => $v )
  70. {
  71. $html->setvar( "i_".$k, $v );
  72. }
  73. $html->parse( "info" );
  74. if ( $area == "login" )
  75. {
  76. if ( $g['options']['blogs'] == "Y" )
  77. {
  78. $html->parse( "all_blogs", true );
  79. $html->parse( "all_blogs_u", true );
  80. }
  81. if ( $g_user['gold_days'] == 0 )
  82. {
  83. $html->parse( "menu_upgrade" );
  84. }
  85. $pages = array( "home", "users_hon", "top5", "users", "search", "mail", "profile", "blogs", "forum", "chat", "flashchat", "news", "gallery" );
  86. foreach ( $pages as $v )
  87. {
  88. $next = false;
  89. if ( $v == "chat" && $g['options']['chat'] == "N" )
  90. {
  91. $next = true;
  92. }
  93. else if ( $v == "flashchat" && $g['options']['flashchat'] == "N" )
  94. {
  95. $next = true;
  96. }
  97. else if ( $v == "top5" && isset( $g['options']['top5'] ) && $g['options']['top5'] == "N" )
  98. {
  99. $next = true;
  100. }
  101. else if ( $v == "forum" && isset( $g['options']['forum'] ) && $g['options']['forum'] == "N" )
  102. {
  103. $next = true;
  104. }
  105. else if ( $v == "gallery" && isset( $g['options']['gallery'] ) && $g['options']['gallery'] == "N" )
  106. {
  107. $next = true;
  108. }
  109. else if ( $v == "users_hon" && isset( $g['options']['rating'] ) && $g['options']['rating'] == "N" )
  110. {
  111. $next = true;
  112. }
  113. if ( $next )
  114. {
  115. $tmp = explode( ".", $p );
  116. if ( $tmp[0] == "users_hon" )
  117. {
  118. $pa[0] = "users_hon";
  119. }
  120. else
  121. {
  122. $pa = explode( "_", $tmp[0] );
  123. }
  124. if ( $v == $pa[0] )
  125. {
  126. $html->parse( "menu_".$v."_active" );
  127. }
  128. else
  129. {
  130. $html->parse( "menu_".$v."" );
  131. }
  132. }
  133. }
  134. }
  135. $html->parse( "auth" );
  136. ( $html );
  137. }
  138.  
  139. }
  140.  
  141. class cfooter extends chtmlblock
  142. {
  143.  
  144. var $message_template = "";
  145.  
  146. function cfooter( $name, $html_path )
  147. {
  148. $this->chtmlblock( $name, $html_path );
  149. }
  150.  
  151. function parseblock( &$html )
  152. {
  153. $html->parse( "auth" );
  154. ( $html );
  155. }
  156.  
  157. }
  158.  
  159. class csearch extends chtmlblock
  160. {
  161.  
  162. function csearch( $name, $html_path )
  163. {
  164. $this->chtmlblock( $name, $html_path );
  165. }
  166.  
  167. function parseblock( &$html )
  168. {
  169. global $g;
  170. global $l;
  171. global $g_user;
  172. $html->setvar( "p_age_from_options", n_options( $g['options']['users_age'], $g['options']['users_age_max'], get_param( "p_age_from", $g['options']['users_age'] ) ) );
  173. $html->setvar( "p_age_to_options", n_options( $g['options']['users_age'], $g['options']['users_age_max'], get_param( "p_age_to", 99 ) ) );
  174. $status = array( "online" => $l['all']['online'], "new" => $l['all']['new'], "birthday" => $l['all']['birthday'], "all" => $l['all']['all'] );
  175. $html->setvar( "status_options", h_options( $status, "all" ) );
  176. if ( isset( $g_user['p_orientation'] ) )
  177. {
  178. $html->setvar( "p_orientation", $g_user['p_orientation'] );
  179. $html->parse( "p_orientation", true );
  180. }
  181. else
  182. {
  183. $checks = 0;
  184. $this->parsechecks( $html, "p_orientation", "SELECT id, title FROM const_orientation", $checks, 2, 0 );
  185. }
  186. $checks = 0;
  187. $this->parsechecks( $html, "p_relation", "SELECT id, title FROM const_relation", $checks, 2, 0 );
  188. ( $html );
  189. }
  190.  
  191. function parsechecks( &$html, $name, $sql, $mask, $num_columns = 1, $add = 0 )
  192. {
  193. if ( ( $sql ) )
  194. {
  195. $i = 0;
  196. $total_checks = ( );
  197. $in_column = ceil( ( $total_checks + $add ) / $num_columns );
  198. do
  199. {
  200. if ( !( $row = ( ) ) )
  201. {
  202. break;
  203. }
  204. else
  205. {
  206. ++$i;
  207. $html->setvar( "id", $row[0] );
  208. $html->setvar( "title", $row[1] );
  209. }
  210. if ( $mask & 1 << $row[0] - 1 )
  211. {
  212. $html->setvar( "checked", " checked" );
  213. }
  214. else
  215. {
  216. $html->setvar( "checked", "" );
  217. }
  218. if ( $i % $in_column == 0 && $i != 0 && ( $i != $total_checks || 0 < $add ) && $num_columns != 1 )
  219. {
  220. $html->parse( $name."_column", true );
  221. }
  222. else
  223. {
  224. $html->setblockvar( $name."_column", "" );
  225. }
  226. $html->parse( $name, true );
  227. } while ( 1 );
  228. ( );
  229. }
  230. }
  231.  
  232. }
  233.  
  234. class cims extends chtmlblock
  235. {
  236.  
  237. function cims( $name, $html_path )
  238. {
  239. $this->chtmlblock( $name, $html_path );
  240. }
  241.  
  242. function parseblock( &$html )
  243. {
  244. global $g;
  245. global $g_user;
  246. }
  247.  
  248. }
  249.  
  250. class ccomplite extends chtmlblock
  251. {
  252.  
  253. var $sMessage = "";
  254.  
  255. function ccomplite( $name, $html_path )
  256. {
  257. $this->chtmlblock( $name, $html_path );
  258. }
  259.  
  260. function parseblock( &$html )
  261. {
  262. global $g_options;
  263. global $g_user;
  264. global $g_news;
  265. if ( isset( $this->message ) )
  266. {
  267. $html->setvar( "update_message", $this->message );
  268. }
  269. $pc = 0;
  270. $pe = 0;
  271. $p = 0;
  272. $p_pc = 0;
  273. $p_pe = 0;
  274. $p_p = 0;
  275. $b_pc = 0;
  276. $b_pe = 0;
  277. $b_p = 0;
  278. $a_pc = 0;
  279. $a_pe = 0;
  280. $a_p = 0;
  281. foreach ( $g_user as $k => $v )
  282. {
  283. if ( is_int( $k ) || !( $k != "user_id" ) || !( $k != "register" ) || !( $k != "last_visit" ) || !( $k != "last_ip" ) || !( $k != "password" ) || !( $k != "age" ) || !( $k != "p_relation" ) || !( $k != "active" ) || !( $k != "hidden" ) || !( $k != "active_code" ) || !( substr( $k, 0, 4 ) != "set_" ) || !( substr( $k, -3, 3 ) != "_to" ) || !( $k != "gold_days" ) || !( $k != "hide_time" ) )
  284. {
  285. if ( $v == "" || $v == "0" )
  286. {
  287. ++$pe;
  288. ++$p;
  289. }
  290. else
  291. {
  292. ++$pc;
  293. ++$p;
  294. }
  295. if ( substr( $k, 0, 2 ) == "p_" && $k != "p_relation" && substr( $k, -3, 3 ) != "_to" )
  296. {
  297. if ( $k == "p_horoscope" )
  298. {
  299. if ( $v == 0 )
  300. {
  301. ++$p_pe;
  302. ++$p_p;
  303. }
  304. else
  305. {
  306. ++$p_pc;
  307. ++$p_p;
  308. }
  309. }
  310. }
  311. else if ( $k == "name" || $k == "mail" || $k == "headline" || $k == "essay" || $k == "birth" || $k == "country_id" || $k == "state_id" || $k == "city_id" )
  312. {
  313. if ( $v == "" )
  314. {
  315. ++$b_pe;
  316. ++$b_p;
  317. }
  318. else
  319. {
  320. ++$b_pc;
  321. ++$b_p;
  322. }
  323. }
  324. else if ( !( !( $k != "p_relation" ) || !( $k != "active" ) || !( $k != "hidden" ) || !( $k != "active_code" ) || !( $k != "partner" ) ) )
  325. {
  326. continue;
  327. }
  328. else if ( $v == 0 )
  329. {
  330. ++$a_pe;
  331. ++$a_p;
  332. }
  333. else
  334. {
  335. ++$a_pc;
  336. ++$a_p;
  337. }
  338. }
  339. }
  340. $pc = ceil( $pc / $p * 100 );
  341. $pe = floor( $pe / $p * 100 );
  342. $html->setvar( "pc", $pc );
  343. $html->setvar( "pe", $pe );
  344. if ( $p_p == 0 )
  345. {
  346. ++$p_p;
  347. }
  348. $p_pc = ceil( $p_pc / $p_p * 100 );
  349. $p_pe = floor( $p_pe / $p_p * 100 );
  350. $html->setvar( "p_pc", $p_pc );
  351. $html->setvar( "p_pe", $p_pe );
  352. if ( $b_p == 0 )
  353. {
  354. ++$b_p;
  355. }
  356. $b_pc = ceil( $b_pc / $b_p * 100 );
  357. $b_pe = floor( $b_pe / $b_p * 100 );
  358. $html->setvar( "b_pc", $b_pc );
  359. $html->setvar( "b_pe", $b_pe );
  360. if ( $a_p == 0 )
  361. {
  362. ++$a_p;
  363. }
  364. $a_pc = ceil( $a_pc / $a_p * 100 );
  365. $a_pe = floor( $a_pe / $a_p * 100 );
  366. $html->setvar( "a_pc", $a_pc );
  367. $html->setvar( "a_pe", $a_pe );
  368. ( $html );
  369. }
  370.  
  371. }
  372.  
  373. ?>


C'est vraiment très sympa de ta part de filer un coup de main. Encore merci !





OmaR a dit :
Mais il doit te manquer des noms de fonctions ou je sais pas quoi... Ou sinon y'a des choses que je ne connais pas...
Mais je n'ai jamais vu de choses de ce genre:
  1. $total_checks = ();
  2. if ( !( $row = ( ) ) )
  3. ();


C'est comme si ça voulait appeler des fonctions, mais que le nom des fonctions n'étaient pas indiquées, et il resterait que les parenthèses...
D'où est-ce que ça vient ton code ?

C'est un ancien salarié de la boite qui nous as fait ce script, il a démissionné pour travailler à l'étranger, j'ai repris le flambeau.
Beaucoup de module du site appel ce script. Avant qu'il parte il l'a fait fonctionner et tout marchait parfaitement. Depuis que j'ai pris mon poste et que j'ai voulu le faire fonctionner... plus rien.
Le problème étant que de nombreuses heures de travail ont déjà été faites pour construire l'intégralité du site et qu'on ne peut pas se permettre de tout recommencer à cause de ce fichu script... :fou: 
Expert Programmation

Franchement, ne sachant pas le contexte, vu la claretée du code, et des variables nommés "a_pc", "a_pe" etc... c'est difficile de faire quelque chose.

Pour moi, il y a plein de noms de fonctions qui ont été supprimés (il est parti en bons termes ? :) )
Exemple, lignes 136, 154, 188, 193, 196, 200, 228 ou encore 368.
Lassé par la pub ? Créez un compte
Tom's guide dans le monde