PostgreSQL ERROR:  permission denied for relation

Posted on 2007-07-20
Last Modified: 2010-05-18
I am designing a website in PHP 5, HTML, CSS, etc using a PostgreSQL 8.1 database on the back-end.

I want to add a new record a new table (confirmemail) I've created in my PUBLIC schema using the "insert into" command.  I can add it from within the PostgreSQL EMS SQL Editor, however when I try to do the same thing through my PHP functions/classes, I keep getting the following error message:

Query failed: ERROR:  permission denied for relation confirmemail.

This is totally baffling me.  Yes, I've set the public grants onthe confirmemail table and I've checked over the table properties to look for any anomalies.  What's worse is that this behaviour seems to be happening to any new tables I add to the database.

Does anybody have any ideas or come across this?
Question by:qu3nt1n
    LVL 14

    Accepted Solution

    First you need to make sure that you are using the same username and password that you use when you want to connect the database by SQL Editor, as what your PHP code is using in its database connect command. In case they are different, you should make sure that the account used by PHP has enough permissions to write into the database.

    Second, you should try to create another table (with no relations to any other tables) and see if PHP can insert into it. If yes, then there is a relationship between the tables that is generating the problem.

    After you did this, post relevant parts of the code here, with the new error messages you would have got.

    Wish I can help
    LVL 5

    Assisted Solution

    LVL 1

    Assisted Solution

    I would like to know the connection string you are using.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
    Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to count occurrences of each item in an array.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now