Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record addition failed, not sure why?

Status
Not open for further replies.

jisoo22

Programmer
Apr 30, 2001
277
0
0
US
Hello all,

I've thrown myself headlong into the world of PHP, Postgresql, and Linux so please bear with me =) I've created a simple database that has only one table with several fields (i.e. last name, first name, etc). I believe I have my html form and my php scripts written correctly but when I try to run them I get this error:

Warning: pg_exec() query failed: ERROR: users: permission denied in /var/ on line 11

Is there some sort of permission on the database that needs to be changed or something? If so, is this something to be rememdied by logging into Linux as root? I'm not quite sure what to do here, any suggestions would be great =)

Thanks,
Jisoo22
 
I figured out the problem partially. I found that I had to grant table access privileges to the apache account. After I did that, I received a different kind of error, does anyone know what this is talking about?

Warning: pg_exec() query failed: ERROR: users_user_id_seq.nextval: you don't have permissions to set sequence users_user_id_seq in /var/ on line 11

Any ideas/solutions would be appreciated.

Thanks,
Jisoo22
 
A-ha, found out why. Apparently there is a separate permission for serial-based primary key fields apart from the general permissions any typical user account has. For any who would like to know, use PGAccess do the following:

Open your database.
Click on your table.
Click "Design Selected Object"
Click "Permissions"
Click "User-Group Manager"
Click on appropriate account name under "Users" menu
Scroll down and find "Sequences"
Click on appropriate sequence
Enable whatever permissions you need to by clicking black buttons on right until they're white

Jisoo22
 
You really shouldn't have to grant table access privileges to the Apache account, unless you are just using the "generic" pg_connect syntax, withouth specifying the username and password. In that case, then PostgreSQL will assume that you are logging in with the permissions of the current process, which of course is httpd running as user "nobody", usually.

In fact, I think its probably a bad idea to allow the apache process owner access to the database. Could be a security risk.

So, if you specify your complete connection string, as mentioned in you should be able to use whatever user you want.

-------------------------------------------

My PostgreSQL FAQ --
 
Hi rycamor,

Just a little tid-bit. For some reason, under RH Linux the httpd process runs under user and group apache.

LelandJ

Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
Yeah, I remember now, although I was trying to forget ;-)... RedHat always has to be a little non-standard. Don't even get me started on "/usr" vs "/usr/local" Give me Slackware/FreeBSD any day.

-------------------------------------------

My PostgreSQL FAQ --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top