0

I have two tables (users and permissions). How can I check whether a user has pemission? in this case permission for editing topics

1 is the admin account

TABLES: users (id, username, acc_type) (1, mirso, 1)

permissions (id, name, description, acc_type, permission_key) (1, Topic edit, some text, 1, edit_topic)

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331

1 Answers1

0

You are looking for SHOW GRANTS Syntax

SHOW GRANTS displays only the privileges granted explicitly to the named account. Other privileges might be available to the account, but they are not displayed. For example, if an anonymous account exists, the named account might be able to use its privileges, but SHOW GRANTS will not display them.

You may try like this:

Show grants for myuser;

EDIT:-

Not very sure about this but you may give it a try like this:

<?php
$db = mysql_connect('Database_Address','database_user','database_password');
if ($db === false)  {
  die("mysql_connect error: " . mysql_error());
}
$selected = mysql_select_db('Database', $db); 
if ($selected === false)  {
  die("mysql_select_db error: " . mysql_error());
}
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331