CodeIgniter Forums
How to check if the user has the right privilege to install db in php - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to check if the user has the right privilege to install db in php (/showthread.php?tid=45790)



How to check if the user has the right privilege to install db in php - El Forum - 10-05-2011

[eluser]Wondering Coder[/eluser]
I know this might be the right forum to ask this but in the first place I've finished my first ever CI web app and now my adviser told me to create an installer. So here goes

First I want to show the mysql.user table that I query but unable to do this T_T. Then after this I will check if the particular user has enough privileges to create db and insert values. I have this code:
Code:
<?php
    $server_name=$_POST['server_name'];
    $user_name=$_POST['user_name'];
    $user_pass=$_POST['user_password'];
    $database_name=$_POST['database_name'];


    if(!empty($user_name)) {
        $query = "SELECT * FROM mysql.user WHERE user='".$user_name."' AND host='".$server_name."'";
        #print_r($query);
        $result = mysql_query($query);
        $row = mysql_fetch_array($result);

        echo $row['user'];
    }

and this gives me an error:
Code:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\dcs-pps\install\check_step3.php on line 34