persistent MySQL connection?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ernie.bornheimer

    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


  • Erwin Moller

    #2
    Re: persistent MySQL connection?

    ernie.bornheime r 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 defaultconnecti on?

    Regards,
    Erwin Moller

    Comment

    • ernie.bornheimer

      #3
      the MySQL connection that wasn't there


      "Erwin Moller"
      <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c omwrote in
      message news:45d5bf08$0 $326$e4fe514c@n ews.xs4all.nl.. .
      ernie.bornheime r 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 defaultconnecti on?
      >
      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


      Comment

      • ernie.bornheimer

        #4
        Re: the MySQL connection that wasn't there


        "ernie.bornheim er" <ernie.bornheim er@gmail.comwro te in message
        news:BOxBh.4327 4$0u1.24479@new sfe15.phx...
        >
        "Erwin Moller"
        <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c omwrote in
        message news:45d5bf08$0 $326$e4fe514c@n ews.xs4all.nl.. .
        >ernie.bornheim er 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 defaultconnecti on?
        >>
        >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


        Comment

        • Erwin Moller

          #5
          Re: the MySQL connection that wasn't there

          ernie.bornheime r wrote:
          >
          "ernie.bornheim er" <ernie.bornheim er@gmail.comwro te in message
          news:BOxBh.4327 4$0u1.24479@new sfe15.phx...
          >>
          >"Erwin Moller"
          ><since_humans_ read_this_I_am_ spammed_too_muc h@spamyourself. comwrote in
          >message news:45d5bf08$0 $326$e4fe514c@n ews.xs4all.nl.. .
          >>ernie.bornhei mer 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 defaultconnecti on?
          >>>
          >>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

          Comment

          • ernie.bornheimer

            #6
            thank you

            Thanks again, Erwin!

            "Erwin Moller"
            <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c omwrote in
            message news:45d83e22$0 $336$e4fe514c@n ews.xs4all.nl.. .
            ernie.bornheime r wrote:
            >
            >>
            >"ernie.bornhei mer" <ernie.bornheim er@gmail.comwro te in message
            >news:BOxBh.432 74$0u1.24479@ne wsfe15.phx...
            >>>
            >>"Erwin Moller"
            >><since_humans _read_this_I_am _spammed_too_mu ch@spamyourself .comwrote in
            >>message news:45d5bf08$0 $326$e4fe514c@n ews.xs4all.nl.. .
            >>>ernie.bornhe imer 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 defaultconnecti on?
            >>>>
            >>>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
            >

            Comment

            Working...