Jump to content

chrisrulez001

Members
  • Posts

    38
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by chrisrulez001

  1. Ok thank you for your suggestions, I do need to return the records for a certain user so I will add those to the code. Thank you both for your help.
  2. Ah right, thank you. Well it sort of is a lazy way of doing things, its so that I can add, edit and delete privileges through an admin panel and because it reads the privileges from the database it automatically updates the variables and a HTML form, if that makes sense. Thanks again
  3. Hi there, I have a table in a MySQL database where I keep a list of user privileges. I am trying to create variables where the name of variable matches the privileges in the table. This is also known as variable variables (I think). EDIT (17/07/2014 04:02 PM): This might be a better way to describe what I'd like, so if the value from the table is admin_panel I'd like to dynamically create a variable with that name. I have created a code so far, but all I seem to be getting is a list of Notice errors telling me that the variable is undefined. (I have supplied a list of errors a bit further down the post). Here is the code: <?php $host = "localhost"; $account = "***"; $password = "****"; $dbname = "****"; $connect = mysql_connect($host,$account,$password) or die("Unable To Connect"); $db = mysql_select_db($dbname,$connect) or die("Unable To Select DB"); $perm_query = "SELECT * FROM `privileges`"; $permission_query = mysql_query($perm_query); while($row = mysql_fetch_array($permission_query)) { $rows[] = $row; } foreach($rows as $row) { ${$row['privilege']}; } ?> The list of errors: Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.