elite_prodigy Posted December 12, 2008 Share Posted December 12, 2008 I have no idea what is going on here. I'm doing something very similar elsewhere in my site, and it works, but this is not working.... This page is included in a file called main.php which sets up which files to include and includes every other file for my Site Control Pannel, I include main.php in index.php. This file gets the permissions stored in the database and builds a list of links based on those permissions. This file gives no errors, but when I try to echo the variables to the page, I get a Notice: Undefined variable: pages_Links in C:\wamp\www\team\index.php on line 55 and so on for each variable I attempt to echo. I've tried including this file in index.php itself, but I get the same error. Well, without further ado, here is the file: <?php include 'config.php'; mysql_select_db("exembar_site"); $id = $_SESSION['id']; $sql = "SELECT * FROM `permissions` WHERE `id`='{$id}'"; $result = mysql_query($sql); $info = mysql_fetch_array($result); $pages = $info['pages']; $staff = $info['staff']; $profile = $info['profile']; $security = $info['security']; //set permissions for page modification if($pages == 1){ define = $pages_links, ' <a href="<?php echo $root; ?>index.php?action=0">Edit</a> <a href="<?php echo $root; ?>index.php?action=1">Create</a> <a href="<?php echo $root; ?>index.php?action=2">Delete</a> '; } else{ $pages_links = "Access Denied"; } //set permissions for staff modification if($staff == 1){ $staff_links = ' <a href="<?php echo $root; ?>index.php?action=3">Hire</a> <a href="<?php echo $root; ?>index.php?action=4">Fire</a> '; } else{ $staff_links = "Access Denied"; } //set permissions for profile modification if($profile == 1){ $profile_links = ' <a href="<?php echo $root; ?>index.php?action=5">Options</a> '; } else{ $profile_links = "Access Denied"; } //set permissions for site security modification if($security == 1){ $security_links = ' Comming Soon '; } else{ $security_links = "Access Denied"; } ?> Quote Link to comment Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 are you checking that you're getting rows back from your query? Quote Link to comment Share on other sites More sharing options...
Brian W Posted December 12, 2008 Share Posted December 12, 2008 are u able in PHP to do this: if($pages == 1){ define = $pages_links, <a href="<?php echo $root; ?>index.php?action=0">Edit</a> <a href="<?php echo $root; ?>index.php?action=1">Create</a> <a href="<?php echo $root; ?>index.php?action=2">Delete</a> '; } I see a problem with line 3-5 of the above... but I'm relatively new to PHP. Quote Link to comment Share on other sites More sharing options...
elite_prodigy Posted December 12, 2008 Author Share Posted December 12, 2008 White space is ignored in most languages. That was done for readability. Quote Link to comment Share on other sites More sharing options...
Brian W Posted December 12, 2008 Share Posted December 12, 2008 umm, not exactly what I was talking about. I use white space all the time for readability... what I mean is that this is all in <?php ?> tags but then on those lines he says <a href="<?php echo $root; ?>index.php?action=0">Edit</a> but like I said, I'm kinda a noob and I don't know all of the rules of PHP Quote Link to comment Share on other sites More sharing options...
elite_prodigy Posted December 12, 2008 Author Share Posted December 12, 2008 No, you're not. It probably didn't render an error because it was in a literal. However, I'm still getting the error even after I fixed everything. And I am getting things back from the query. Quote Link to comment Share on other sites More sharing options...
elite_prodigy Posted December 12, 2008 Author Share Posted December 12, 2008 <?php include 'config.php'; mysql_select_db("exembar_site"); $id = $_SESSION['id']; $sql = "SELECT * FROM `permissions` WHERE `staffId`='{$id}'"; $result = mysql_query($sql); $info = mysql_fetch_array($result); $pages = $info['pages']; $staff = $info['staff']; $profile = $info['profile']; $security = $info['security']; //set permissions for page modification if($pages == 1){ $pages_links = ' <a href="'.$root.'index.php?action=0">Edit</a> <a href="'.$root.'index.php?action=1">Create</a> <a href="'.$root.'index.php?action=2">Delete</a> '; } else{ $pages_links = "Access Denied"; } //set permissions for staff modification if($staff == 1){ $staff_links = ' <a href="'.$root.'index.php?action=3">Hire</a> <a href="'.$root.'index.php?action=4">Fire</a> '; } else{ $staff_links = "Access Denied"; } //set permissions for profile modification if($profile == 1){ $profile_links = ' <a href="'.$root.'index.php?action=5">Options</a> '; } else{ $profile_links = "Access Denied"; } //set permissions for site security modification if($security == 1){ $security_links = ' Comming Soon '; } else{ $security_links = "Access Denied"; } ?> This is my current updated code, I fixed a lot of errors :/. Quote Link to comment Share on other sites More sharing options...
Brian W Posted December 12, 2008 Share Posted December 12, 2008 No, you're not. It probably didn't render an error because it was in a literal. However, I'm still getting the error even after I fixed everything. And I am getting things back from the query. I'm not what? what is the error you are getting? Quote Link to comment Share on other sites More sharing options...
elite_prodigy Posted December 12, 2008 Author Share Posted December 12, 2008 You're not supposed to use PHP tags the way I did. That happened because I was orriginally just placing the links there, and when I created the security settings, I just copy/pasted the links. And since the links were originally in an HTML page they had the Tags so that I could use the root address. I'm getting an undefined variable as described in my first post. Quote Link to comment Share on other sites More sharing options...
Brian W Posted December 12, 2008 Share Posted December 12, 2008 does it tell you line 55 still? for me, line 55 is Comming Soon Quote Link to comment Share on other sites More sharing options...
elite_prodigy Posted December 13, 2008 Author Share Posted December 13, 2008 Non, line 55 in index.php. I got it to work by sepparating the one file into 4 and including them where I needed them and adding an echo command into each of them, but I'd rather not do it the way.... 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.