RE: [PHP] how do i check if a server is online ?
> i have the problem that i need to connect to a database on a server wich > is quiet often offline. > > how can i connect to this database (mysql) and can check if the server is > online. > like.. if server is online -> fine we work as normaly > if server is NOT online -> print out message and say "server offline try > later" > > i tried something like mysql_connect and then die ... > but it takes approx 5 mins.. till i get the message.. > do i have to set the timeout lower? and if yes.. how do i do that ? This should do what you want: system("ping -c 1 www.someurl.com", $retval); if($retval == 0) { #server is alive } else { #server is down } HTH -Marc- #/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/# #Marc Swanson | \|||/ # #MSwanson Consulting | /o o\ # #Phone: (603)868-1721|-oooOooo-# #Fax:(603)868-1730| Solutions in: # #[EMAIL PROTECTED] | 'PHP'Perl # # | 'SQL'C++ # # | 'HTML 'Sh/Csh# # http://www.mswanson.com | 'Javascript# #/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/# -- PHP General 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] when 1+1 is not equal to 2... STRANGE float behavior
I understand the issues about binary precision for floating point numbers on standard base 2 systems but I'm unsure of the propper way to fix this problem. Here is the base test case: = $contract_amount)\n\n"; if(($paid_to_date + $billable_this_month) >= $contract_amount) { echo"true"; } else { echo"false"; } ?> This is mostly a cut and paste of a problem that I am trying to fix for a client for a particular record which is coming out of the database and not evaluating like I want it to. you would expect (498.05 + 9462.95) to be equal to 9961.00 . In the case of this problem, all variables in question are of type double at time of comparison. ideas? I tried casting to various different types without success. I'd prefer not to round if at all possible... Thanks! -- - Marc Swanson MSwanson Consulting Phone: (603)868-1721 Fax:(603)868-1730 Mobile: (603)512-1267 [EMAIL PROTECTED] http://www.mswanson.com - -- PHP General 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] when 1+1 is not equal to 2... STRANGE float behavior
Answered my own question... rounding using the "round" function to two decimal places did the trick: = $contract_amount)\n\n"; if(($paid_to_date + $billable_this_month) >= $contract_amount) { echo"true"; } else { echo"false"; } ?> now outputs "true". :-) -- - Marc Swanson MSwanson Consulting Phone: (603)868-1721 Fax:(603)868-1730 Mobile: (603)512-1267 [EMAIL PROTECTED] http://www.mswanson.com - -- PHP General 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] wierd function behavior within classes.. Bug?
I'm not sure if this is a known feature in php.. but the following code will generate this warning: Warning: Missing argument 2 for foo() in /raid/htdocs/test.php on line 7 - \n"; } function Foo($bar,$baz) { // one argument constructor echo"Two argument constructor.\n\n"; } } $foo = new Foo("foobared constructor"); ?> - while simply swapping the functions around removes the warning - \n"; } function Foo($bar) { // no argument constructor echo"One argument Constructor.\n\n"; } } $foo = new Foo("foobared constructor"); ?> -- This is running on php version 4.0.3pl1 Is it supposed to be this way for some reason or is this a bug? I believe I found that it happens with all functions within a class (not just constructors). Thanks -- - Marc Swanson MSwanson Consulting Phone: (603)868-1721 Fax:(603)868-1730 Mobile: (603)512-1267 [EMAIL PROTECTED] http://www.mswanson.com - -- PHP General 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] wierd function behavior within classes.. Bug?
> PHP does not support having multiple methods with the same name. Write a > single method and check the number of args in that. surprising that I've never come across this limitation even after writing php for quite some time. Sorry for the wasted bandwidth! -- ----- Marc Swanson MSwanson Consulting Phone: (603)868-1721 Fax:(603)868-1730 Mobile: (603)512-1267 [EMAIL PROTECTED] http://www.mswanson.com - -- PHP General 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] mysql_insert_id + mysql_pconnect = race condition??
In my code I have a few places where I use mysql_pconnect to open a persistant database connection to mysql in order to reduce overhead. I also use mysql_insert_id to fetch insert ids for various insert commands. Since mysql_pconnect uses the SAME database connection between my php scripts... is it concievable that a call to mysql_insert_id COULD return the id of another insert call if one is happening at that exact moment? Or am I worrying about nothing? If this IS a problem I'll be sure to change my code to open a new database connection before calling mysql_insert_id. Thanks! -- - Marc Swanson MSwanson Consulting Phone: (603)868-1721 Fax:(603)868-1730 Mobile: (603)512-1267 [EMAIL PROTECTED] http://www.mswanson.com - -- PHP General 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] chewing up apache logs
> I've just changed ISPs, and my old ISP used webalizer to report > usuage/everything else stats about a website. The new ISP offers a > simular product for a cost, but it looks very clumsy and bloated. I had the same problem... I used to host my own and then had to switch to a hosting service with a log analyzer I didn't like. Being a fan of webalizer.. heres what I did. I wrote a perl script to download my raw log file to my local machine, process it with webalizer, and then upload the webalizer files to my server. The file is attached. Note that the code is set up to grab log data from .logs/data so you may have to change that and also it is set up to process 3 websites since I am runnning one main site and 2 virtual hosts. Just trim that stuff out. Hope that helps! -- --------- Marc Swanson MSwanson Consulting Phone: (603)868-1721 Fax:(603)868-1730 Mobile: (603)512-1267 [EMAIL PROTECTED] http://www.mswanson.com - logger.pl -- PHP General 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] Print current page with no printer dialog box - How ?
> Do you know how to create a button to print current page without > bringing up the printer dialog box? I just print to the default printer. > > And also how do I insert a page break ? Yes, to both questions. See http://www.meadroid.com/scriptx It is an ActiveX component that allows pretty much FULL control over the printing environment. It is designed for IE but they have a product called "Neptune" that allows you to run ActiveX stuff in netscape.. on windows platforms only :-/ As far as the page breaks go use CSS. BTDT recently on an intranet application where the users are chained to IE anyway HTH -- ----- Marc Swanson MSwanson Consulting Phone: (603)868-1721 Fax:(603)868-1730 Mobile: (603)512-1267 [EMAIL PROTECTED] http://www.mswanson.com - -- PHP General 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]