473,382 Members | 1,165 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

persistent MySQL connection?

Hello

I have a script that works but it shouldn't, and I would like to know why.

I originally wrote it with a statement to connect to the database, then
there's a part to select the database, then I get some records and print
them to the browser. It all works fine. A couple of months ago, I commented
out the connection part (I can't remember why), and it still works. I had
thought that there must be a connection statement. Is the current version of
the code using the same connection from way back when? I'm confused.

I know this is a newbie question. If someone could just point me in the
right direction, I'd be very grateful.

Thank you!

Ernie
Feb 16 '07 #1
5 1804
ernie.bornheimer wrote:
Hello

I have a script that works but it shouldn't, and I would like to know why.

I originally wrote it with a statement to connect to the database, then
there's a part to select the database, then I get some records and print
them to the browser. It all works fine. A couple of months ago, I
commented out the connection part (I can't remember why), and it still
works. I had thought that there must be a connection statement. Is the
current version of the code using the same connection from way back when?
I'm confused.

I know this is a newbie question. If someone could just point me in the
right direction, I'd be very grateful.

Thank you!

Ernie
Hi,

PHP/MySQL also has a real 'persistent connection', so your question is kind
of confusing. :-)

But, really, I think you must overlook something.
If you do not deliver the resource-identifier to the database to PHP, it
will use the last connection, but that only works in 1 script, not the next
invocation of the same script.
Is it possible you have some includefile you overlooked that actually DOES
connect?
Or you have in php.ini configured some defaultconnection?

Regards,
Erwin Moller

Feb 16 '07 #2

"Erwin Moller"
<si******************************************@spam yourself.comwrote in
message news:45*********************@news.xs4all.nl...
ernie.bornheimer wrote:
>Hello

I have a script that works but it shouldn't, and I would like to know
why.

I originally wrote it with a statement to connect to the database, then
there's a part to select the database, then I get some records and print
them to the browser. It all works fine. A couple of months ago, I
commented out the connection part (I can't remember why), and it still
works. I had thought that there must be a connection statement. Is the
current version of the code using the same connection from way back when?
I'm confused.

I know this is a newbie question. If someone could just point me in the
right direction, I'd be very grateful.

Thank you!

Ernie

Hi,

PHP/MySQL also has a real 'persistent connection', so your question is
kind
of confusing. :-)

But, really, I think you must overlook something.
If you do not deliver the resource-identifier to the database to PHP, it
will use the last connection, but that only works in 1 script, not the
next
invocation of the same script.
Is it possible you have some includefile you overlooked that actually DOES
connect?
Or you have in php.ini configured some defaultconnection?

Regards,
Erwin Moller
Erwin

Sorry about the improper use of "persistent." I checked my code again,
including the includes. There is no database connection code. I'll ask my
ISP about php.ini and post again.

Thank you very much!

Ernie
Feb 17 '07 #3

"ernie.bornheimer" <er**************@gmail.comwrote in message
news:BO*******************@newsfe15.phx...
>
"Erwin Moller"
<si******************************************@spam yourself.comwrote in
message news:45*********************@news.xs4all.nl...
>ernie.bornheimer wrote:
>>Hello

I have a script that works but it shouldn't, and I would like to know
why.

I originally wrote it with a statement to connect to the database, then
there's a part to select the database, then I get some records and print
them to the browser. It all works fine. A couple of months ago, I
commented out the connection part (I can't remember why), and it still
works. I had thought that there must be a connection statement. Is the
current version of the code using the same connection from way back
when?
I'm confused.

I know this is a newbie question. If someone could just point me in the
right direction, I'd be very grateful.

Thank you!

Ernie

Hi,

PHP/MySQL also has a real 'persistent connection', so your question is
kind
of confusing. :-)

But, really, I think you must overlook something.
If you do not deliver the resource-identifier to the database to PHP, it
will use the last connection, but that only works in 1 script, not the
next
invocation of the same script.
Is it possible you have some includefile you overlooked that actually
DOES
connect?
Or you have in php.ini configured some defaultconnection?

Regards,
Erwin Moller

Erwin

Sorry about the improper use of "persistent." I checked my code again,
including the includes. There is no database connection code. I'll ask my
ISP about php.ini and post again.

Thank you very much!

Ernie
And here's the word from my hosting company:
"At LAMP Host the default db for each virtualhost is configured in the
Apache
config. So, as you experienced, you don't neccessarily need to set the
connection string. Note that this is an unofficial feature and might not
always work, so you shouldn't depend on it."

Mystery solved. But strange. Is this common practice in the industry?

Thank you!

Ernie
Feb 18 '07 #4
ernie.bornheimer wrote:
>
"ernie.bornheimer" <er**************@gmail.comwrote in message
news:BO*******************@newsfe15.phx...
>>
"Erwin Moller"
<si******************************************@spa myourself.comwrote in
message news:45*********************@news.xs4all.nl...
>>ernie.bornheimer wrote:

Hello

I have a script that works but it shouldn't, and I would like to know
why.

I originally wrote it with a statement to connect to the database, then
there's a part to select the database, then I get some records and
print them to the browser. It all works fine. A couple of months ago, I
commented out the connection part (I can't remember why), and it still
works. I had thought that there must be a connection statement. Is the
current version of the code using the same connection from way back
when?
I'm confused.

I know this is a newbie question. If someone could just point me in the
right direction, I'd be very grateful.

Thank you!

Ernie

Hi,

PHP/MySQL also has a real 'persistent connection', so your question is
kind
of confusing. :-)

But, really, I think you must overlook something.
If you do not deliver the resource-identifier to the database to PHP, it
will use the last connection, but that only works in 1 script, not the
next
invocation of the same script.
Is it possible you have some includefile you overlooked that actually
DOES
connect?
Or you have in php.ini configured some defaultconnection?

Regards,
Erwin Moller

Erwin

Sorry about the improper use of "persistent." I checked my code again,
including the includes. There is no database connection code. I'll ask
my ISP about php.ini and post again.

Thank you very much!

Ernie
And here's the word from my hosting company:
"At LAMP Host the default db for each virtualhost is configured in the
Apache
config. So, as you experienced, you don't neccessarily need to set the
connection string. Note that this is an unofficial feature and might not
always work, so you shouldn't depend on it."

Mystery solved. But strange. Is this common practice in the industry?
No, I have seen preconfigured databaseaccess before (they make sure a
database exists and that you have a connectstring to it), but not this
(preconfigured connections).
But at least you found out why it happens now. :-)

Regards,
Erwin Moller
>
Thank you!

Ernie
Feb 18 '07 #5
Thanks again, Erwin!

"Erwin Moller"
<si******************************************@spam yourself.comwrote in
message news:45*********************@news.xs4all.nl...
ernie.bornheimer wrote:
>>
"ernie.bornheimer" <er**************@gmail.comwrote in message
news:BO*******************@newsfe15.phx...
>>>
"Erwin Moller"
<si******************************************@sp amyourself.comwrote in
message news:45*********************@news.xs4all.nl...
ernie.bornheimer wrote:

Hello
>
I have a script that works but it shouldn't, and I would like to know
why.
>
I originally wrote it with a statement to connect to the database,
then
there's a part to select the database, then I get some records and
print them to the browser. It all works fine. A couple of months ago,
I
commented out the connection part (I can't remember why), and it still
works. I had thought that there must be a connection statement. Is the
current version of the code using the same connection from way back
when?
I'm confused.
>
I know this is a newbie question. If someone could just point me in
the
right direction, I'd be very grateful.
>
Thank you!
>
Ernie

Hi,

PHP/MySQL also has a real 'persistent connection', so your question is
kind
of confusing. :-)

But, really, I think you must overlook something.
If you do not deliver the resource-identifier to the database to PHP,
it
will use the last connection, but that only works in 1 script, not the
next
invocation of the same script.
Is it possible you have some includefile you overlooked that actually
DOES
connect?
Or you have in php.ini configured some defaultconnection?

Regards,
Erwin Moller

Erwin

Sorry about the improper use of "persistent." I checked my code again,
including the includes. There is no database connection code. I'll ask
my ISP about php.ini and post again.

Thank you very much!

Ernie
And here's the word from my hosting company:
"At LAMP Host the default db for each virtualhost is configured in the
Apache
config. So, as you experienced, you don't neccessarily need to set the
connection string. Note that this is an unofficial feature and might not
always work, so you shouldn't depend on it."

Mystery solved. But strange. Is this common practice in the industry?

No, I have seen preconfigured databaseaccess before (they make sure a
database exists and that you have a connectstring to it), but not this
(preconfigured connections).
But at least you found out why it happens now. :-)

Regards,
Erwin Moller
>>
Thank you!

Ernie

Feb 18 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Steve Jenkins | last post by:
Wonder if anyone can help. So, I've read: >> http://uk2.php.net/function.mysql-pconnect >> http://uk2.php.net/manual/en/features.persistent-connections.php Can one seriously see persistent...
4
by: M. Katz | last post by:
I'm relatively new to PHP/MySQL and I've heard about maintaining a persistent connection to the database. To save overhead, I'd like to maintain the connection in a session variable, but I have a...
2
by: Ivan | last post by:
Hi, I have a that page opens an imap connection; I need to refer to the connection across various pages. I don't want to reopen that connection on every page (vast waste of resources). I have...
3
by: Derek Fountain | last post by:
For a low-ish traffic website that is doing the simple "build pages from HTML templates and info in a database" kind of thing, do the wise folks in this newsgroup advocate connecting and...
5
by: Felix E. Klee | last post by:
I've set up a PHP web application where users can log in and open a connection to a NNTP-server. There is a *one-to-one* relationship between sessions and NNTP-connections (i.e. exactly one...
16
by: Paul Rubin | last post by:
I've had this recurring half-baked desire for long enough that I thought I'd post about it, even though I don't have any concrete proposals and the whole idea is fraught with hazards. Basically...
6
by: David Rasmussen | last post by:
I use urllib2 to do some simple HTTP communication with a web server. In one "session", I do maybe 10-15 requests. It seems that urllib2 opens op a connection every time I do a request. Can I...
5
by: lawpoop | last post by:
Hello all! I'm working on a PHP site using Postgres as a back-end. I have an include at the top of each page that runs the pg_connect function. I'm implementing some temporary tables, which I...
9
by: mel | last post by:
Hi all, I need a persistent TCP connection with my web server over page reloads. This means that, even if the user goes to a different page (in my domain), I want to keep a TCP connection...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.