www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] CREATE VIEW command denied to user

  1. #1
    Join Date
    Feb 2003
    Posts
    102

    resolved [RESOLVED] CREATE VIEW command denied to user

    Hi all,

    I am currently having issues creating a VIEW via PHP.

    I have the following code in my "Login" form.
    Code:
    <form name="login" action="login_engine.php" method="POST" style="margin-top:0px;">
    Username: <input type="text" name="loginUsername" style="width:100px;" />
    Password: <input type="text" name="loginPassword" style="width:100px;" /><br />
    <input type="submit" value="LOGIN" name="JobNew" class="menubutton2">
    </form>
    I have the following code in my Login "Engine" php file (login_engine.php).
    Code:
    $loginUsername = $_POST['loginUsername'];
    $loginPassword = $_POST['loginPassword'];
    $retrievedUserAccount = mysql_query("SELECT * FROM systblUserAccounts WHERE Username='$loginUsername' AND Password='$loginPassword'")
    or die(mysql_error() /*"Invalid username and password combination.  Click BACK on your browser to try again!"*/);
    //////////////////////////////////////////////////////////////////////
    $rowUserAccount = mysql_fetch_array( $retrievedUserAccount );
    $currentUserID = $rowUserAccount['UserID'];
    $currentBusinessID = $rowUserAccount['BusinessID'];
    //////////////////////////////////////////////////////////////////////
    mysql_query("CREATE VIEW viewCustomers AS SELECT * FROM tblCustomers WHERE BusinessID=1") or die (mysql_error());
    mysql_query("CREATE VIEW viewCustomerTransfers AS SELECT * FROM tblCustomerTransfers WHERE BusinessID=1") or die (mysql_error());
    mysql_query("CREATE VIEW viewInvoices AS SELECT * FROM tblInvoices WHERE BusinessID=1") or die (mysql_error());
    mysql_query("CREATE VIEW viewJobs AS SELECT * FROM tblJobs WHERE BusinessID=1") or die (mysql_error());
    //////////////////////////////////////////////////////////////////////
    I get the following error message on my screen:
    CREATE VIEW command denied to user 'mybiz_jobmin1'@'localhost' for table 'viewCustomers'

    I thought that this meant I didn't have permission to create views at the Server level. Using excerpts My emails to and from my web host have been as follows...

    Me: Under my account “[AccountName]” I am building a MySQL database with a PHP front-end that will need to be able to use the “CREATE VIEW” MySQL function. I’m fairly certain my syntax is correct. When I look at the list of grants available to me with SHOW GRANTS, my user account has the following permissions:
    Grants for mybiz_jobmin1@localhost] => GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES
    Does this mean I do not have permission to CREATE VIEWs?
    If so, can you please enable this feature for me or show me where I can turn it on?


    WebHost: You have permission to create view. What is the syntax of the view?

    Me: mysql_query("CREATE VIEW viewCustomers AS SELECT * FROM tblCustomers WHERE BusinessID=1") or die (mysql_error());
    mysql_query("CREATE VIEW viewCustomerTransfers AS SELECT * FROM tblCustomerTransfers WHERE BusinessID=1") or die (mysql_error());
    mysql_query("CREATE VIEW viewInvoices AS SELECT * FROM tblInvoices WHERE BusinessID=1") or die (mysql_error());
    mysql_query("CREATE VIEW viewJobs AS SELECT * FROM tblJobs WHERE BusinessID=1") or die (mysql_error());


    WebHost: When you created the username, you have permission to create view.


    So based on this, I presume either one of two things must be happening:
    1) I am doing something wrong (most likely); or
    2) The helpdesk staffer at my Web Host hasn't understood my query or doesn't know their stuff.

    Can anyone shed some light on this issue for me? As per usual, any assistance here is much appreciated.

    If it's an issue with my Web Host, can anyone offer any suggestions as to what I should ask them to do, eg: they need to change setting X in PHP.ini or some such.


    Cheers,

    Chris


    PS: this query follows on from a previous issue I had, which can be found here:
    http://www.webdeveloper.com/forum/sh...d.php?t=239854

    Now that I am dealing with a specific function required for that previous issue, I thought it misleading to have it under that same topic title.
    Officially confused.

  2. #2
    Join Date
    Feb 2003
    Posts
    102
    I should add that I am using MySQL v5.0.91 and am trying to create this view using PHP v5.3.2.

    Cheers,

    Chris
    Officially confused.

  3. #3
    Join Date
    Feb 2003
    Posts
    102
    Bah! Nevermind folks. My code was OK. I decided to deal with the "hold time" and called my ISP. Sure enough, after a few language barrier issues and talking to someone who had no idea about how MySQL worked, I was put through to one of their techs who granted me permissions to create Views.

    So contrary to the email discussion above, I DID NOT have permission to create views!



    Cheers,

    Chris
    Officially confused.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles