Mutley Posted August 8, 2006 Share Posted August 8, 2006 I'm trying to make it simple to make several admin menus but can't seem to get this part right, I just get this error:[quote]Parse error: parse error, unexpected T_VARIABLE on line 21[/quote]Here is the part I get confused with in bold, is this ok to do?[code]<?$team[b]$menu = $addprofile, $manageprofile, $newsform, $logout; [/b] draw__admin_menu($menu, $team);?>[/[/code]Here is the full code, I hope you understand what I'm trying to do:[code]<?$addprofile = "- <a href=\"admin_profileform.php\">Add a new Profile</a>";$manageprofile = "- <a href=\"admin_profilemanage.php\">Manage Profiles</a>";$newsform = "- <a href=\"admin_profilemanage.php\">Manage Profiles</a>";$logout = " - <a href=\"logout.php\">Logout</a>";function draw_admin_menu($menu, $team) {if($logged[username] && $logged[level] ==$team){?><center>Welcome <b><?=$logged[username]?></b><br /></center><br /><br /><?=$menu?><br /><br /><?}}?><br /><br /><br /><?$team$menu = $addprofile, $manageprofile, $newsform, $logout; draw__admin_menu($menu, $team);?>[/code]Thanks. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 8, 2006 Share Posted August 8, 2006 You are misisng a semi-colon after $team Quote Link to comment Share on other sites More sharing options...
ronverdonk Posted August 8, 2006 Share Posted August 8, 2006 And after that you get error "Parse error: parse error, unexpected ',' in file_name on line x" because your assignment $menu=$addprofile must end with a semi-colon. Quote Link to comment Share on other sites More sharing options...
Mutley Posted August 8, 2006 Author Share Posted August 8, 2006 I've changed the common errors and commented it up but it still doesn't work, it won't display the content, I just get a blank white page:[code]<?// Here are the list of menu options I want to call$addprofile = "- <a href=\"admin_profileform.php\">Add a new Profile</a>";$manageprofile = "- <a href=\"admin_profilemanage.php\">Manage Profiles</a>";$newsform = "- <a href=\"admin_profilemanage.php\">Manage Profiles</a>";$logout = " - <a href=\"logout.php\">Logout</a>";// The draw function, so I can create a list of links and user levels instead of doing the same code repeatadlyfunction draw_admin_menu($menu, $team) {if($logged[username] && $logged[level] ==$team){?><center>Welcome <b><?=$logged[username]?></b></center><br /><br /><?=$menu?><br /><br /><?}}?><br /><br /><br /><?// Here is my admin menu calling the functions abovedraw_admin_menu($menu, $team);$team = "under_7s";$menu = "$addprofile, $manageprofile, $newsform, $logout";?>[/code] Quote Link to comment Share on other sites More sharing options...
bltesar Posted August 8, 2006 Share Posted August 8, 2006 you need to define $menu and $team before calling the function Quote Link to comment Share on other sites More sharing options...
Mutley Posted August 8, 2006 Author Share Posted August 8, 2006 I switched it around to this:[code]$team = "under_7s";$menu = "$addprofile, $manageprofile, $newsform, $logout";draw_admin_menu($menu, $team);[/code]No luck, still an empty white page. Thanks for your time so far. Quote Link to comment Share on other sites More sharing options...
bltesar Posted August 8, 2006 Share Posted August 8, 2006 when you view the page source, do you see the '<br /><br /><br />', which would indicate that the function is being executed properly and the conditions set in your if statement are not bieng satisfied? Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 8, 2006 Share Posted August 8, 2006 Try:[code]<?// Here are the list of menu options I want to call$addprofile = "- <a href=\"admin_profileform.php\">Add a new Profile</a>";$manageprofile = "- <a href=\"admin_profilemanage.php\">Manage Profiles</a>";$newsform = "- <a href=\"admin_profilemanage.php\">Manage Profiles</a>";$logout = " - <a href=\"logout.php\">Logout</a>";$teamname = "under_7s";// The draw function, so I can create a list of links and user levels instead of doing the same code repeatadlyfunction draw_admin_menu($menu, $team) {global $addprofile, $manageprofile, $newsform, $logout, $teamname;$menu = "$addprofile, $manageprofile, $newsform, $logout";$team = "$teamname";return $menu, $team;if($logged[username] && $logged[level] ==$team){?><center>Welcome <b><?=$logged[username]?></b></center><br /><br /><?=$menu?><br /><br /><?}}?><br /><br /><br /><?// Here is my admin menu calling the functions aboveecho draw_admin_menu($menu, $team);?>[/code] Quote Link to comment Share on other sites More sharing options...
bltesar Posted August 8, 2006 Share Posted August 8, 2006 the br's in my previous message about viewing the source code of your page were interpreted as line breaks.your function prints out some line breaks, br's, at the end. Check the source code of your blank page to see if those are there, which woul dindicate that the function is executing properly and the problem is probably that the conditions set in your if statement are not being satisfied. Quote Link to comment Share on other sites More sharing options...
Mutley Posted August 8, 2006 Author Share Posted August 8, 2006 Tried it all, still blank page. <br /> is there because it isn't in the function. Just as standalone html. ??? Quote Link to comment Share on other sites More sharing options...
bltesar Posted August 8, 2006 Share Posted August 8, 2006 replace the br's at the end of the function code with 'end of page', load the page and see if this text is displayed. If so, the problem lies in the parameters sent to the function. Quote Link to comment Share on other sites More sharing options...
Mutley Posted August 8, 2006 Author Share Posted August 8, 2006 It is definatly the functions, having $ in a $=... like my topic title says. I did this code:[code]<?// Here are the list of menu options I want to call$addprofile = "- <a href=\"admin_profileform.php\">Add a new Profile</a>";$manageprofile = "- <a href=\"admin_profilemanage.php\">Manage Profiles</a>";$newsform = "- <a href=\"admin_profilemanage.php\">Manage Profiles</a>";$logout = " - <a href=\"logout.php\">Logout</a>";// The draw function, so I can create a list of links and user levels instead of doing the same code repeatadlyfunction draw_admin_menu($team, $menu) {//if($logged[username] && $logged[level] ==$team)//{?><center>Welcome <b><?=$logged[username]?></b></center><br /><br /><?=$menu?><br /><br /><?}//}?>End of page<?// Here is my admin menu calling the functions above$team = "under_7s";$menu = "$addprofile, $manageprofile, $newsform, $logout";draw_admin_menu($menu, $team);?>[/code]...commenting out the "$" parts and it loaded "under_7s" and the word "Welcome" but didn't load any of the $menu or name attributes?I thought it might be a PHP problem, so did this in the $menu part:[code]$menu = <<<INCLUDES$addprofile, $manageprofile, $newsform, $logout;draw_admin_menu($menu, $team)INCLUDES;[/code]Still nothing worked. Quote Link to comment Share on other sites More sharing options...
bltesar Posted August 8, 2006 Share Posted August 8, 2006 it may be that you're missing semicolons. Try:[code]<center>Welcome <b><?=$logged[username];?></b></center><br /><br /><?=$menu;?><br /><br />[/code] Quote Link to comment Share on other sites More sharing options...
Mutley Posted August 9, 2006 Author Share Posted August 9, 2006 Nope.Here is the code as it stands:[code]<?// Here are the list of menu options I want to call$addprofile = "- <a href=\"admin_profileform.php\">Add a new Profile</a>";$manageprofile = "- <a href=\"admin_profilemanage.php\">Manage Profiles</a>";$newsform = "- <a href=\"admin_profilemanage.php\">Manage Profiles</a>";$logout = " - <a href=\"logout.php\">Logout</a>";// The draw function, so I can create a list of links and user levels instead of doing the same code repeatadlyfunction draw_admin_menu($team, $menu) {//if($logged[username] && $logged[level] ==$team)//{?><center>Welcome <b><?=$logged[username];?></b></center><br /><br /><?=$menu;?><br /><br /><?}//}?>End of page<?// Here is my admin menu calling the functions above$team = "under_7s";$menu = <<<INCLUDES$addprofile, $manageprofile, $newsform, $logout;draw_admin_menu($menu, $team)INCLUDES;?>[/code]Someone must know why. :( Quote Link to comment Share on other sites More sharing options...
bltesar Posted August 9, 2006 Share Posted August 9, 2006 perhaps your server is not set up to use ASP style tags. Try[code]//if($logged[username] && $logged[level] ==$team)//{?><center>Welcome <b><?PHP echo $logged[username];?></b></center><br /><br /><?PHP echo $menu;?><br /><br />[/code]Also, I don't understand the following lines of your code:[code]menu = <<<INCLUDES$addprofile, $manageprofile, $newsform, $logout;[/code]Perhaps <<<INCLUDES is something with which I am not familiar, or it's just your notation. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 9, 2006 Share Posted August 9, 2006 Okay. looking at your code you are using an $logged variable in side the draw_admin_menu function. Now the function wont be able to access the $logged function as it is out side of the variable scope of the function. WHat you'll want to do is define as global inside the function like so [code=php:0]global $logged;[/code] Also your parameters where in the wrong order too in your function, and you was calling your function in the wrong place. Try this:[code]<?php// Here are the list of menu options I want to call$addprofile = "- <a href=\"admin_profileform.php\">Add a new Profile</a>";$manageprofile = "- <a href=\"admin_profilemanage.php\">Manage Profiles</a>";$newsform = "- <a href=\"admin_profilemanage.php\">Manage Profiles</a>";$logout = " - <a href=\"logout.php\">Logout</a>";// Here is my admin menu calling the functions above$team = "under_7s";$menu = $addprofile . $manageprofile . $newsform . $logout;// The draw function, so I can create a list of links and user levels instead of doing the same code repeatadlyfunction draw_admin_menu($menu, $team){ global $logged; // define the $logged variable as global so we can access them from within the function. if($logged['username'] && $logged['level'] == $team) { $html = '<center>Welcome <b>' . $logged['username'] . '</b></center><br /><br />' . $menu . '<br /><br />'; } echo $html;}draw_admin_menu($menu, $team);?>End of page[/code] Quote Link to comment Share on other sites More sharing options...
Mutley Posted August 9, 2006 Author Share Posted August 9, 2006 Using that, all I see is "End of page". :(Thanks for your effort so far. I'm really intrested to know what the problem is! Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 9, 2006 Share Posted August 9, 2006 What happens if you use this as the function:[code=php:0]function draw_admin_menu($menu, $team){ global $logged; // define the $logged variable as global so we can access them from within the function. //if($logged['username'] && $logged['level'] == $team) //{ $html = '<center>Welcome <b>' . $logged['username'] . '</b></center><br /><br />' . $menu . '<br /><br />'; //} echo $html;}[/code]Do you get any output. Also where is the $logged variable being created to? Quote Link to comment Share on other sites More sharing options...
Mutley Posted August 9, 2006 Author Share Posted August 9, 2006 [quote author=wildteen88 link=topic=103422.msg412637#msg412637 date=1155150632]What happens if you use this as the function:[code=php:0]function draw_admin_menu($menu, $team){ global $logged; // define the $logged variable as global so we can access them from within the function. //if($logged['username'] && $logged['level'] == $team) //{ $html = '<center>Welcome <b>' . $logged['username'] . '</b></center><br /><br />' . $menu . '<br /><br />'; //} echo $html;}[/code]Do you get any output. Also where is the $logged variable being created to?[/quote]YES! Of course! I forgot to do include('config.php') at the top for my logged variable.Ah thanks, it all works now. Jeez, thanks so much wildteen! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.