Re: [PHP-DB] database connection timeout
Juffermans, Jos wrote: I understand your point but since I wasn't getting any response and never received a confirmation email from the system telling me that my email account had been verified, I wasn't sure that the original post was actually sent to the community. Oddly enough I got an email from the system this morning asking me to verify my email address - again :s Fair enough, I've been on that boat before. :) The VPN connection is not always available. I'm afraid I don't have much control over the VPN myself and I believe only the Oracle port has been opened in this VPN. You might want to contact whoever manages the VPN - it sure sounds like it needs to always be up! MN> Essentially, you want ocilogon (complex network function to login to a MN> networked Oracle [in this case] server) to timeout just like fsockopen MN> (fairly simple function to open a socket, including network resources). MN> My suggestion is to try connecting using fsockopen, with the timeout. MN> If it successfully connects - chances are, the majority of the time, MN> your ocilogon that follows will work as well. That's a good idea, I'll try to connect to the Oracle port thru fsockopen. Let us on the list know how/whether or not this works, It's definitely worth having some info on. MN> Another dirty little trick you might use is running the ocilogon in a MN> separate script and making use of set_time_limit() to make sure it MN> doesn't run too long. Just be sure not to set_time_limit() for your MN> whole set of scripts, unless you really want them to abort after the 5 MN> or 10 second limit you're setting ocilogon (unlikely). I'm not sure if I can set the time limit (safemode...) but are you saying that set_time_limit only affects the script that you include and not the caller script? No no no - include() should be the same as if you just placed the code right where the include is, so it would apply it to the whole script. You'll have to call out separately and make it another process, and exec or something - a small script whose sole intention is to determine if the VPN is up. exec() or the likes - like I said - dirty trick/hack. The idea is to just have it return 0 or 1 [actually, depending on how the time limit works, it may not return anything if it ends prematurely]. Definitely try the fsockopen bit first, and give it a few go's if it's not working. I'll try the fsockopen "connection test" on the oracle port. Thanks for your help. Welcome to the list! cheers, -- - Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] database connection timeout
Hi, Martin Norland wrote: MN> I'm afraid phrasing a question multiple ways over a course of days tends MN> not to have much success. In an effort to avoid populating google with MN> just the question, I will give to you what I would try. I understand your point but since I wasn't getting any response and never received a confirmation email from the system telling me that my email account had been verified, I wasn't sure that the original post was actually sent to the community. Oddly enough I got an email from the system this morning asking me to verify my email address - again :s Anyway, at least this time it triggered a response ;) MN> Is it that it's not always available, or that it needs time to 'come MN> back up'. You may want to try running some random low-traffic MN> application over it to make sure it remains running. Some simple SNMP MN> protocol or even simpler just connect to a remote GKrellM. Heck, a ssh MN> connection with top running would do - just something that is constantly MN> transmitting a trickle of data. The VPN connection is not always available. I'm afraid I don't have much control over the VPN myself and I believe only the Oracle port has been opened in this VPN. MN> Essentially, you want ocilogon (complex network function to login to a MN> networked Oracle [in this case] server) to timeout just like fsockopen MN> (fairly simple function to open a socket, including network resources). MN> My suggestion is to try connecting using fsockopen, with the timeout. MN> If it successfully connects - chances are, the majority of the time, MN> your ocilogon that follows will work as well. That's a good idea, I'll try to connect to the Oracle port thru fsockopen. MN> Another dirty little trick you might use is running the ocilogon in a MN> separate script and making use of set_time_limit() to make sure it MN> doesn't run too long. Just be sure not to set_time_limit() for your MN> whole set of scripts, unless you really want them to abort after the 5 MN> or 10 second limit you're setting ocilogon (unlikely). I'm not sure if I can set the time limit (safemode...) but are you saying that set_time_limit only affects the script that you include and not the caller script? I'll try the fsockopen "connection test" on the oracle port. Thanks for your help. Rgds, Jos -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] database connection timeout
Juffermans, Jos wrote: Hi, [snip] Hello, again. I'm afraid phrasing a question multiple ways over a course of days tends not to have much success. In an effort to avoid populating google with just the question, I will give to you what I would try. ( please note the irony of this now. ) I'm trying to connect to an Oracle database (using ocilogon) which is in a different country and connected to our serverfarm via a VPN (the database has no public access). Unfortunately the VPN or the database is not always available. In those cases I will present the visitor with a page explaining that the service is unavailable. [snip] Is it that it's not always available, or that it needs time to 'come back up'. You may want to try running some random low-traffic application over it to make sure it remains running. Some simple SNMP protocol or even simpler just connect to a remote GKrellM. Heck, a ssh connection with top running would do - just something that is constantly transmitting a trickle of data. My problem is that ocilogon takes a long time to return control if the connection cannot be established - often even more than 30 seconds. I've learned that if a connection can be established it'll happen in only a few seconds (usually within 1 second) and am convinced that if the connection is not established in eg 5 seconds, there is no point in waiting another eg 30 seconds. How can I tell ocilogon to timeout after eg 5 seconds (like you can with fsockopen)? [snip] I can't claim whether or not it will work since I don't have an Oracle server handy, so I will merely name functions and talk a bunch. Essentially, you want ocilogon (complex network function to login to a networked Oracle [in this case] server) to timeout just like fsockopen (fairly simple function to open a socket, including network resources). My suggestion is to try connecting using fsockopen, with the timeout. If it successfully connects - chances are, the majority of the time, your ocilogon that follows will work as well. Unfortunately, the stream_set_* functions rely on a valid stream resource, so they won't work with ocilogon (if there was any chance they would). That would have been a nice route to go otherwise. Another dirty little trick you might use is running the ocilogon in a separate script and making use of set_time_limit() to make sure it doesn't run too long. Just be sure not to set_time_limit() for your whole set of scripts, unless you really want them to abort after the 5 or 10 second limit you're setting ocilogon (unlikely). cheers, -- - Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Database connection
undefined function means you don't have mysql support compiled in... prefixing any function with @ suppresses any error messages... On Thu, 17 Jul 2003, Martin wrote: > I'm trying to use PHP 4.2.3 in a database application. > > print "Connected?"; > $dbcnx = mysql_connect("localhost","root","asda"); > if (!$dbcnx) { > echo("Unable to connect to database server."); > exit(); > }else { > print "Connected!"; > } > ?> > > Gives > Connected? > Fatal error: Call to undefined function: mysql_connect() in > /var/www/html/irm/test.php on line 3 > > While changing the line to > $dbcnx = @mysql_connect("localhost","root","asda"); > is in the MySQL example > > simply prints > Connected? > > and nothing more happens. My app isn't using the database (later on). > Never had this problem on 4.0.x which makes me a bit confused. > > What am i doing wrong? > > /M. > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Database Connection
You need to specify some env variables before you connect: heres what I do. # putenv("LD_LIBRARY_PATH=/home/db2inst1/sqllib/lib"); putenv("DB2INSTANCE=db2inst1"); # HTH Mark -Original Message- From: Andrew Hill [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 05, 2002 9:43 AM To: Jerry; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Database Connection Jerry, I believe it's the sqllib dir, but you can try the other or experiment with just /home/db2inst1/sqllib If created by the DB2 client installer, try applying the environment variables script: . /home/db2inst1/sqllib/db2profile Best regards, Andrew Hill Director of Technology Evangelism OpenLink Software http://www.openlinksw.com Universal Data Access & Data Integration Technology Providers > -Original Message- > From: Jerry [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, February 05, 2002 11:36 AM > To: [EMAIL PROTECTED] > Subject: Re: [PHP-DB] Database Connection > > > Thanks Andrew for your answer. > > In the environment variables I have already: > > DB2INSTANCE=db2inst1 > LD_LIBRARY_PATH=:/home/db2inst1/sqllib/lib > > Is it correct ? Or does it need to point to the DB2 Client directory > /usr/IBMdb2/V7.1/lib > > > Thanks. > > Jerry > > > "Andrew Hill" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Jerry, > > > Installing DB2 Client will allow you to use the ODBC functions > in PHP, but > > be aware that you are not actually using any ODBC Drivers in this > instance. > > PHP allows hiding of certain database specific functions under > a "Unified > > ODBC" that uses the ODBC functions without using true ODBC database > communication. > > > That being said, you don't need to link --with-iODBC unless you > are using > > ODBC Drivers, so it's not an issue here. > > > If Apache doesn't start, I'd check it's logs, but you might be > encountering > > a situation where the DB2 libraries were in the path at compile time and > are > > not at Apache start time. Try setting LD_LIBRARY_PATH environment > variable > > to include the location of your DB2 Client. > > > Andrew Hill > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > . > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Database Connection
Jerry, I believe it's the sqllib dir, but you can try the other or experiment with just /home/db2inst1/sqllib If created by the DB2 client installer, try applying the environment variables script: . /home/db2inst1/sqllib/db2profile Best regards, Andrew Hill Director of Technology Evangelism OpenLink Software http://www.openlinksw.com Universal Data Access & Data Integration Technology Providers > -Original Message- > From: Jerry [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, February 05, 2002 11:36 AM > To: [EMAIL PROTECTED] > Subject: Re: [PHP-DB] Database Connection > > > Thanks Andrew for your answer. > > In the environment variables I have already: > > DB2INSTANCE=db2inst1 > LD_LIBRARY_PATH=:/home/db2inst1/sqllib/lib > > Is it correct ? Or does it need to point to the DB2 Client directory > /usr/IBMdb2/V7.1/lib > > > Thanks. > > Jerry > > > "Andrew Hill" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Jerry, > > > Installing DB2 Client will allow you to use the ODBC functions > in PHP, but > > be aware that you are not actually using any ODBC Drivers in this > instance. > > PHP allows hiding of certain database specific functions under > a "Unified > > ODBC" that uses the ODBC functions without using true ODBC database > communication. > > > That being said, you don't need to link --with-iODBC unless you > are using > > ODBC Drivers, so it's not an issue here. > > > If Apache doesn't start, I'd check it's logs, but you might be > encountering > > a situation where the DB2 libraries were in the path at compile time and > are > > not at Apache start time. Try setting LD_LIBRARY_PATH environment > variable > > to include the location of your DB2 Client. > > > Andrew Hill > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > . > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Database Connection
Thanks Andrew for your answer. In the environment variables I have already: DB2INSTANCE=db2inst1 LD_LIBRARY_PATH=:/home/db2inst1/sqllib/lib Is it correct ? Or does it need to point to the DB2 Client directory /usr/IBMdb2/V7.1/lib Thanks. Jerry "Andrew Hill" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Jerry, > Installing DB2 Client will allow you to use the ODBC functions in PHP, but > be aware that you are not actually using any ODBC Drivers in this instance. > PHP allows hiding of certain database specific functions under a "Unified > ODBC" that uses the ODBC functions without using true ODBC database communication. > That being said, you don't need to link --with-iODBC unless you are using > ODBC Drivers, so it's not an issue here. > If Apache doesn't start, I'd check it's logs, but you might be encountering > a situation where the DB2 libraries were in the path at compile time and are > not at Apache start time. Try setting LD_LIBRARY_PATH environment variable > to include the location of your DB2 Client. > Andrew Hill . -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Database Connection
Jerry, Installing DB2 Client will allow you to use the ODBC functions in PHP, but be aware that you are not actually using any ODBC Drivers in this instance. PHP allows hiding of certain database specific functions under a "Unified ODBC" that uses the ODBC functions without using true ODBC database communication. That being said, you don't need to link --with-iODBC unless you are using ODBC Drivers, so it's not an issue here. If Apache doesn't start, I'd check it's logs, but you might be encountering a situation where the DB2 libraries were in the path at compile time and are not at Apache start time. Try setting LD_LIBRARY_PATH environment variable to include the location of your DB2 Client. Hope this helps. Best regards, Andrew Hill Director of Technology Evangelism OpenLink Software http://www.openlinksw.com Universal Data Access & Data Integration Technology Providers > -Original Message- > From: Jerry [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, February 05, 2002 10:46 AM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] Database Connection > > > Hi, > > I have IBM DB2 V7.2 on a windows 2000 server > I have IBM DB2 Client/Administration Client Development Client V7.2 on a > Linux Web Server > >From the Linux server (Command Line) I can connect to the DB2 database > directly. > > I would like to connect to the DB2 Database through PHP4/Apache > > After compiling PHP with the option > "--with-ibm-db2=/home/db2inst1", Apache > doesn't start anymore. > > Do I need to install iODBC (or another ODBC) or is it included ? > > Any idea what can cause this problem and how to solve it ? > > Thanks > > Jerry > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Database Connection Properties
> Given that the data are on a shared server, then your info is available to > anybody else with root access to the database directories. A previous > web-site I had allowed me open access to other users mysql databases. I > could have blown those databases away. Thankfully, I happen to be that root user. :) But it still is a shared server with other users each having access to the system. I've setup MySQL so that each user has access to only their database -- they cannot connect to any other database on the system. Patrick ---| patrick gibson |---+ email: email @ patrickg.com url: http://patrickgibson.com/ + -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Database Connection Properties
> Store the connection strings in an include file preferably outside the > wed root. You can include files with a fully resolved path, or using the > php include_path variable if you have access to the configuration. > Alternately, if you don't have access to directories outside the > webroot, put the That would be slightly more secure, but still not foolproof. Where-ever the file is, it has to ultimately be accessible by the webserver. Any user on the system will either have access to that folder through the shell or through the webserver via their own script. I guess there's not really any great way of protecting database connection information on a shared server? Patrick ---| patrick gibson |---+ email: email @ patrickg.com url: http://patrickgibson.com/ + -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Database Connection Properties
Store the connection strings in an include file preferably outside the wed root. You can include files with a fully resolved path, or using the php include_path variable if you have access to the configuration. Alternately, if you don't have access to directories outside the webroot, put the patrick gibson wrote: > I'm new to PHP, and I have a question regarding the storage of connection > properties to the database. I have a site on a shared (Unix) server. I'm > adding some PHP to a section which will be database-driven. I'm concerned > about storing the username and password to my database (some of the data > contained within this database is sensitive) in my PHP files which are > readable by the webserver, and thus by anyone on the system. > > Is there a recommended strategy for keeping my database username and > password in a secure location so that no other user can access the files? > Any help would be greatly appreciated. > > Thanks very much, > > Patrick > > ---| patrick gibson |---+ > email: email @ patrickg.com > url: http://patrickgibson.com/ > + > > -- "Out beyond the ideas of wrong-doing and right-doing there is a field. I'll meet you there." -Rumi *(O)* [EMAIL PROTECTED] *** under construction *** http://centralcoasthealing.net Healing Resources on the Central Coast http://kornsnake.com Internet Development -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Database Connection Properties
Set the username and password for your database to whatever you want. It doesn't have to be nobody/nobody. Pass the username and password from an include file. Miles Thompson At 09:31 PM 1/6/2002 -0800, patrick gibson wrote: >I'm new to PHP, and I have a question regarding the storage of connection >properties to the database. I have a site on a shared (Unix) server. I'm >adding some PHP to a section which will be database-driven. I'm concerned >about storing the username and password to my database (some of the data >contained within this database is sensitive) in my PHP files which are >readable by the webserver, and thus by anyone on the system. > >Is there a recommended strategy for keeping my database username and >password in a secure location so that no other user can access the files? >Any help would be greatly appreciated. > >Thanks very much, > >Patrick > >---| patrick gibson |---+ > email: email @ patrickg.com > url: http://patrickgibson.com/ >+ > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]