PHP and Postgres connection

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lazaroskyr
Forum Newbie
Posts: 11
Joined: Wed Oct 18, 2006 5:21 am

PHP and Postgres connection

Post by lazaroskyr »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I wish to everyone a happy new year.
Here is my "silly" question.

I have this code:

Code: Select all

$conn = pg_connect(...) or die("Couldn't Connect: ".pg_last_error());

if(something) {
insert_something();
}
elseif(something else) {
update_something();
}

function insert_something() {
...some code...(works nice)
}

function update_something() {
...some code...(cannot connect to db- i must reconnect)
}
I cannot understand what is the reason that in the second function I lose connection to postgres and must reconnect...Can anyone help me?


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

lazaroskyr
Forum Newbie
Posts: 11
Joined: Wed Oct 18, 2006 5:21 am

Post by lazaroskyr »

Thanks.I must do my homework more properly.
Post Reply