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