php-general Digest 23 Jul 2005 06:49:32 -0000 Issue 3583
php-general Digest 23 Jul 2005 06:49:32 - Issue 3583 Topics (messages 219235 through 219247): Re: gloabl reference behavior question? 219235 by: Surendra Singhi Re: Konqueror does not like my Website 219236 by: Rick Emery Re: Is there a way to get a variable name as a string? 219237 by: Daevid Vincent 219238 by: Daevid Vincent Re: how to post a question? 219239 by: Edward Vermillion On register_shutdown_function: What might be the problem? 219240 by: Liang ZHONG 219241 by: André Medeiros 219242 by: Liang ZHONG 219243 by: Jasper Bryant-Greene 219246 by: Rasmus Lerdorf 219247 by: Liang ZHONG Re: System specific information gathering 219244 by: Vidyut Luther 219245 by: Ramil Sagum Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: php-general@lists.php.net -- ---BeginMessage--- Richard Lynch [EMAIL PROTECTED] writes: The operator is not, as far as I know, defined for an array assignment operation. True, you can use in the parameter list in some versions to keep PHP from copying the whole array. But that does not legitimatize what you are doing, I don't think. I never claimed, what I was doing was correct, rather I didn't knew well enough that 'PHP is not C++', and I was misunderstanding how reference and global variables work in PHP. I could be 100% wrong. I've never even *TRIED* to use a reference to an array because I simply don't want to write code that confusing in the first place. I don't think it will make the code confusing, but the person looking at the code should understand how reference and global variables work. Using reference variables avoids unnecessary extra copying of objects, and while using large arrays it can make a big difference in speed. The lesson to learn from this thread is that variables declared in a function as global (using global keyword) are new reference variables to the actual global variable. And, so when these global variables in functions are assigned a new reference, it breaks the old reference and makes them refer to the new location, and the actual global variable is not affected. But in contrast, if the global variables in the function are assigned a new value, this does changes the value of the variable in the outer global scope. -- Surendra Singhi http://www.spikesource.com http://www.public.asu.edu/~sksinghi/ ---End Message--- ---BeginMessage--- Quoting Michelle Konzack [EMAIL PROTECTED]: Am 2005-07-22 10:12:17, schrieb John Nichel: You mean the 'posting a totally non-php question to a php list' bug? Because the page is generated by a couple of PHP scripts and ONLY THIS PAGE is not working. So I was thinking there is a problem with the file-extension *.php and Konqueror can not handel this... (It is KDE 3.4) Greetings Michelle I just opened it in Konqueror 3.4.1 to look for any javascript errors, and it seemed to load and work fine. Sorry I wasn't any help, Rick -- Rick Emery When once you have tasted flight, you will forever walk the Earth with your eyes turned skyward, for there you have been, and there you will always long to return -- Leonardo Da Vinci ---End Message--- ---BeginMessage--- What I was thinking with debug_backtrace() is that you could get the information for the function that called the function you want the variable name for, *reducing* the likelyhood of duplicate values, but admitedly not eliminating it. You could also pass the name of the variable to the function: someFunction($foo, $varName=){ print $varName; } call it with - someFunction($bar, 'bar'); That would definately get you what you want, but again it would be messy to look at. Well if you called someFunction('bar'); Function someFunction($myVar) { global $$myVar; echo the variable name is '$myVar' and has the value of .$$myVar; } But that relies on the global and is also a bit messy in a recursive situation. ---End Message--- ---BeginMessage--- He wants a function that, if you put in $x, you get out 'x' For *ANY* $variable. There is no such function. Usually the person asking it is doing something very newbie-ish, and very wrong. Actually it's not either... Since you can't easily debug when generating XML, as malformed XML will STB, I have this function which dumps out an array and recursively sub arrays. It would be very useful to dump out the name of the variable as part of this, as a lot of text is on the screen with all the tags and such. It always annoyed me about print_r() that it doesn't tell you the variable name either, so you have to always prefix it with an echo/print just above the print_r. /** * Print out an array in
php-general Digest 23 Jul 2005 18:57:06 -0000 Issue 3584
php-general Digest 23 Jul 2005 18:57:06 - Issue 3584 Topics (messages 219248 through 219255): Re: On register_shutdown_function: What might be the problem? 219248 by: Rasmus Lerdorf speed - PHP/MYSQL 219249 by: balwant singh 219250 by: Jasper Bryant-Greene Re: Rasmus' 30 second AJAX Tutorial - [was Re: [PHP] AJAX PHP] 219251 by: Chris Boget 219254 by: Rasmus Lerdorf PEAR DB issue 219252 by: Chris Boget Re: System specific information gathering 219253 by: André Medeiros Re: AJAX PHP 219255 by: Brian V Bonini Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: php-general@lists.php.net -- ---BeginMessage--- If you don't flush some output after setting the header() then the headers won't go out until the end of the request. So do something like: ignore_user_abort(true); header(Location: http://whatever;); echo foo\n; flush(); Then whatever comes after this should run and the browser is long gone. -Rasmus Liang ZHONG wrote: I think I did not express myself clearly. What I want is to be able to redirect user an existing page (let them get it immediately), and to close the connection actively, NOT passively by user abort, at last, to run the function in background. But the redirecting using function header() with location has a problem that header() always does return the page to user after the entire program, including registered showdown function finish running, which is against the will. I put a time consuming task into a function that registered to be a shutdown function and hoping it runs after the user has got the redirected page and the connection has been closed. But experiements (using browsers, curl command line tool as well as perl::LWP code) show that the user got the redirected page only after the shutdown function finished, which is against the description of register_shutdown_function at php website. It seems only header() function use to redirect page has this problem (not executed until register_shutdown_function finished) while other functions like print()/echo(), exec() have not. The code looks like: - ?php set_time_limit(1); function f(){ set_time_limit(20); $count=5000; for($i=0; $i$count; $i++){ } echo end; exec(touch /home/.nappy/liang/liang.ns2user.info/php/aaa); } register_shutdown_function('f'); header(Content-type: text/plain); header(Location: y.html); ? - http client who sends the request to the php program will only get the page back as response after function f finsihes (file aaa created). Changing the $count will make a lot difference. My BIGGEST question is: How to make user get the redirect page immediately after the header() is called, and not until function f() ends, while making sure that the function f() will finally fully (and might slowly) execute? Thank you very much for kindly replying. With high respect, Liang Liang ZHONG wrote: My Question is: What is the correct way to keep the function running after I redirect an existing page to http client (which I want the client get immediately) and then immediately close the connection? ignore_user_abort(true); -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- Hi, I have made a webpage in php which retrieves the data from a huge MYSQL tables as below:- $i=0; while ($i=23) { select a, b from table where hour(time)=$i and date='' order by desc time limit 1; $i++; } then i substract the current hour output from the last hour output for calcuating the output in that hour through PHP code and then display it. But my problem is that this page takes approx. 90 seconds or more for loading even when i refresh the page, it is taking the same time. I have done indexing on that table, tune the php and apache but it is still taking same time. I have other tables also when PHP is doing more calculatios but those pages are not taking so much time they load in 5 sec. or so. Is there anything needs to be done more, please advise. -- With Best Wishes Balwant Singh ---End Message--- ---BeginMessage--- balwant singh wrote: Hi, I have made a webpage in php which retrieves the data from a huge MYSQL tables as below:- $i=0; while ($i=23) { select a, b from table where hour(time)=$i and date='' order by desc time limit 1; $i++; } then i substract the current hour output from the last hour output for calcuating the output in that hour through PHP code and then
Re: [PHP] On register_shutdown_function: What might be the problem?
I think I did not express myself clearly. What I want is to be able to redirect user an existing page (let them get it immediately), and to close the connection actively, NOT passively by user abort, at last, to run the function in background. But the redirecting using function header() with location has a problem that header() always does return the page to user after the entire program, including registered showdown function finish running, which is against the will. I put a time consuming task into a function that registered to be a shutdown function and hoping it runs after the user has got the redirected page and the connection has been closed. But experiements (using browsers, curl command line tool as well as perl::LWP code) show that the user got the redirected page only after the shutdown function finished, which is against the description of register_shutdown_function at php website. It seems only header() function use to redirect page has this problem (not executed until register_shutdown_function finished) while other functions like print()/echo(), exec() have not. The code looks like: - ?php set_time_limit(1); function f(){ set_time_limit(20); $count=5000; for($i=0; $i$count; $i++){ } echo end; exec(touch /home/.nappy/liang/liang.ns2user.info/php/aaa); } register_shutdown_function('f'); header(Content-type: text/plain); header(Location: y.html); ? - http client who sends the request to the php program will only get the page back as response after function f finsihes (file aaa created). Changing the $count will make a lot difference. My BIGGEST question is: How to make user get the redirect page immediately after the header() is called, and not until function f() ends, while making sure that the function f() will finally fully (and might slowly) execute? Thank you very much for kindly replying. With high respect, Liang Liang ZHONG wrote: My Question is: What is the correct way to keep the function running after I redirect an existing page to http client (which I want the client get immediately) and then immediately close the connection? ignore_user_abort(true); -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] On register_shutdown_function: What might be the problem?
If you don't flush some output after setting the header() then the headers won't go out until the end of the request. So do something like: ignore_user_abort(true); header(Location: http://whatever;); echo foo\n; flush(); Then whatever comes after this should run and the browser is long gone. -Rasmus Liang ZHONG wrote: I think I did not express myself clearly. What I want is to be able to redirect user an existing page (let them get it immediately), and to close the connection actively, NOT passively by user abort, at last, to run the function in background. But the redirecting using function header() with location has a problem that header() always does return the page to user after the entire program, including registered showdown function finish running, which is against the will. I put a time consuming task into a function that registered to be a shutdown function and hoping it runs after the user has got the redirected page and the connection has been closed. But experiements (using browsers, curl command line tool as well as perl::LWP code) show that the user got the redirected page only after the shutdown function finished, which is against the description of register_shutdown_function at php website. It seems only header() function use to redirect page has this problem (not executed until register_shutdown_function finished) while other functions like print()/echo(), exec() have not. The code looks like: - ?php set_time_limit(1); function f(){ set_time_limit(20); $count=5000; for($i=0; $i$count; $i++){ } echo end; exec(touch /home/.nappy/liang/liang.ns2user.info/php/aaa); } register_shutdown_function('f'); header(Content-type: text/plain); header(Location: y.html); ? - http client who sends the request to the php program will only get the page back as response after function f finsihes (file aaa created). Changing the $count will make a lot difference. My BIGGEST question is: How to make user get the redirect page immediately after the header() is called, and not until function f() ends, while making sure that the function f() will finally fully (and might slowly) execute? Thank you very much for kindly replying. With high respect, Liang Liang ZHONG wrote: My Question is: What is the correct way to keep the function running after I redirect an existing page to http client (which I want the client get immediately) and then immediately close the connection? ignore_user_abort(true); -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] speed - PHP/MYSQL
Hi, I have made a webpage in php which retrieves the data from a huge MYSQL tables as below:- $i=0; while ($i=23) { select a, b from table where hour(time)=$i and date='' order by desc time limit 1; $i++; } then i substract the current hour output from the last hour output for calcuating the output in that hour through PHP code and then display it. But my problem is that this page takes approx. 90 seconds or more for loading even when i refresh the page, it is taking the same time. I have done indexing on that table, tune the php and apache but it is still taking same time. I have other tables also when PHP is doing more calculatios but those pages are not taking so much time they load in 5 sec. or so. Is there anything needs to be done more, please advise. -- With Best Wishes Balwant Singh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] speed - PHP/MYSQL
balwant singh wrote: Hi, I have made a webpage in php which retrieves the data from a huge MYSQL tables as below:- $i=0; while ($i=23) { select a, b from table where hour(time)=$i and date='' order by desc time limit 1; $i++; } then i substract the current hour output from the last hour output for calcuating the output in that hour through PHP code and then display it. But my problem is that this page takes approx. 90 seconds or more for loading even when i refresh the page, it is taking the same time. I have done indexing on that table, tune the php and apache but it is still taking same time. I have other tables also when PHP is doing more calculatios but those pages are not taking so much time they load in 5 sec. or so. Is there anything needs to be done more, please advise. Don't loop through in PHP and execute the query 23 times. Instead, execute the query once (without the hour(time)=$1 and and the limit 1, and use a while($row = mysql_fetch_assoc($result)) { } type function to get all 23 rows. That will be much faster. By the way, that should probably be order by time desc not order by desc time. Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Rasmus' 30 second AJAX Tutorial - [was Re: [PHP] AJAX PHP]
function sndReq(action) { http.open('get', 'rpc.php?action='+action); http.onreadystatechange = handleResponse; http.send(null); } So with AJAX, the data gets sent back to the browser using GET? Is there any way you can do it using POST? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PEAR DB issue
I'm using PEAR::DB to connect to a MS SQL Server 2000. I'm attempting to run the following query: SELECT * FROM myTable FOR XML AUTO, ELEMENTS When I run the above query using the Query Analyzer, I get back the results as expected. However, when I try to run the same query using PEAR, I get the following error: [nativecode=4004 - Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier.] and I'm not sure why. I've googled the error and see that alot of other people are getting the same error (though, it doesn't seem that they are necessarily using PEAR). From what I can tell, it is a client error and not a server error. So my questions are 1) is there something wrong with PEAR and 2) if so, is there a fix in the works? Does anyone know? But that aside, has anyone else come up against this issue and found a workaround using PEAR? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: System specific information gathering
First of all, you want to have the two values in seperate variables. After reading the contents from the file, do something like: -8- function parseUptimeSeconds( $seconds ) { $resultArray = Array( 'weeks' = 0, 'days' = 0, 'hours' = 0, 'minutes' = 0, 'seconds' = 0); // check weeks while( $seconds 604800 ) { $resultArray['weeks']++; $seconds -= 604800; } // check days while( $seconds 86400) { $resultArray['days']++; $seconds -= 86400; } // check hours while( $seconds 3600) { $resultArray['hours']++; $seconds -= 3600; } // check minutes while( $seconds 60) { $resultArray['minutes']++; $seconds -= 60; } $resultArray['seconds'] = $seconds; return( $resultArray ); } // separate both values list( $uptimeSeconds, $idleSeconds ) = explode( ' ', $lineReadFromFile ); $uptimeElements = parseUptimeSeconds( $uptimeSeconds ); $idleElements = parseUptimeSeconds( $idleSeconds ); -8- I know there might be a more efficient way of doing this, like using the modulus operator, but hey :) On 7/23/05, Ramil Sagum [EMAIL PROTECTED] wrote: On 7/23/05, Vidyut Luther [EMAIL PROTECTED] wrote: Ok, If I use the file_get_contents.. how do I actually parse the contents on /proc/uptime cat /proc/uptime 1400293.13 1317047.64 The first number is the total uptime in seconds, the second number is the total idle time. -- ramil http://ramil.sagum.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Rasmus' 30 second AJAX Tutorial - [was Re: [PHP] AJAX PHP]
Chris Boget wrote: function sndReq(action) { http.open('get', 'rpc.php?action='+action); http.onreadystatechange = handleResponse; http.send(null); } So with AJAX, the data gets sent back to the browser using GET? Is there any way you can do it using POST? The prototype for the http.open method looks like this: open(method,URL,async,uname,pswd) So to do a POST request instead, just use 'post' instead of 'get' in the first argument. Then put the url encoded post data in the http.send() call. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] AJAX PHP
On Thu, 2005-07-21 at 08:23, Marco Tabini wrote: We had a webcast on PHP and Ajax a while back--the recordings are still available for free at http://blogs.phparch.com/mt/index.php?p=49. Nice, totally crashes Firefox in Linux. -- s/:-[(/]/:-)/g BrianGnuPG - KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu == gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC Key Info: http://gfx-design.com/keys Linux Registered User #339825 at http://counter.li.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] AJAX PHP
Hmm.. Works for me. Firefox 1.0.6 on gentoo. On 7/23/05, Brian V Bonini [EMAIL PROTECTED] wrote: On Thu, 2005-07-21 at 08:23, Marco Tabini wrote: We had a webcast on PHP and Ajax a while back--the recordings are still available for free at http://blogs.phparch.com/mt/index.php?p=49. Nice, totally crashes Firefox in Linux. -- s/:-[(/]/:-)/g BrianGnuPG - KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu == gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC Key Info: http://gfx-design.com/keys Linux Registered User #339825 at http://counter.li.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Don't ejecute a sentence if a field is empty
Hello I'm new: I need to know how can I stop a php sentence if my db is empty, for example I have writed a php sentence, if every fields from mmy db are full, there is no problem, but I delete every values from the all fields in my db when I ejecute my script mysql give me an error, Ej: $fecha = mysql_query(SELECT event_day, event_month, event_year FROM $db_table WHERE event_title = $dia_maximo); $fecha_max = mysql_fetch_array($fecha); $fecha_maxima = $fecha_max['event_day']; $diames_maximo = $fecha_max['event_month']; wehen I ejecute the script the error message is it: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/cfg/prueba/calendar_este2/index.php on line 277 sorry for my english, I'm cuban -- Este mensaje ha sido analizado por MailScanner en busca de virus y otros contenidos peligrosos, y se considera que está limpio. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and Perl
I am needing to write a front end for an online application written in Perl. Is there a way for PHP to call a module or function written in Perl? Thanks, Linda -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] zlib-1.2.3 php-4.4.0
compiled without any problems but when i fired up phpinfo(); it said linked zlib version 1.2.2, so i tried recompiling php but moved the system ones files /usr/lib, /usr/include and placed the old ones in their place but still it says linked zlib version is 1.2.2 within a call to phpinfo();, i also checked the makefile and that had my correct locations for the zlib-1.2.3 version libs. anyone know why? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP and Perl
Linda H wrote: I am needing to write a front end for an online application written in Perl. Is there a way for PHP to call a module or function written in Perl? Firstly, please don't reply to existing threads with a completely new topic. For those of us that use threaded newsreaders, your message is hidden within another thread and is very likely to be missed. In this situation I would simply use the PHP execution functions (exec(), system(), shell_exec(), etc.) to call Perl scripts that use the modules or functions written in Perl. Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Don't ejecute a sentence if a field is empty
Jesús Alain Rodríguez Santos wrote: Hello I'm new: I need to know how can I stop a php sentence if my db is empty, for example I have writed a php sentence, if every fields from mmy db are full, there is no problem, but I delete every values from the all fields in my db when I ejecute my script mysql give me an error, Ej: $fecha = mysql_query(SELECT event_day, event_month, event_year FROM $db_table WHERE event_title = $dia_maximo); $fecha_max = mysql_fetch_array($fecha); $fecha_maxima = $fecha_max['event_day']; $diames_maximo = $fecha_max['event_month']; wehen I ejecute the script the error message is it: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/cfg/prueba/calendar_este2/index.php on line 277 $fecha = mysql_query(SELECT event_day, event_month, event_year FROM $db_table WHERE event_title = $dia_maximo); if($fecha) { $fecha_max = mysql_fetch_array($fecha); $fecha_maxima = $fecha_max['event_day']; $diames_maximo = $fecha_max['event_month']; } else { // No row returned... } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] AJAX PHP
On 7/23/05, Brian V Bonini [EMAIL PROTECTED] wrote: On Thu, 2005-07-21 at 08:23, Marco Tabini wrote: We had a webcast on PHP and Ajax a while back--the recordings are still available for free at http://blogs.phparch.com/mt/index.php?p=49. Nice, totally crashes Firefox in Linux. Works fine here, Firefox 1.04 on Debian GNU/Linux 3.1. -- Greg Donald Zend Certified Engineer MySQL Core Certification http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] AJAX PHP
Yep, I integrated it into one of our in house apps a few weeks back just to try it out and it worked ok. Nothing special, just allowed a user to put in a name in a search box and the js called a php script which did a lookup into the db and returned the results as the user typed but worked well with php. On 7/21/05, balwant singh [EMAIL PROTECTED] wrote: Have anybody tried PHP AJAX, may please share your experience. also pls. suggest good link of tutorial on this. With Best Wishes Balwant Singh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] speed - PHP/MYSQL
I agree with Jasper here, you want to make it a point to optimize your queries so that fewer trips are made to the database server. On the topic of indexing, I'm curious as to how you did that and if your using it as intended. In your query you are testing columns `time`,`date` so you'll want to make sure that those are two columns that have been indexed. You might want to investigate different types of indexes and how to optimize them too. In my own experience I know that FULLTEXT indexes work wonders for large 'search engine' tables. Multiple Column index - http://dev.mysql.com/doc/mysql/en/multiple-column-indexes.html FULLTEXT index - http://dev.mysql.com/doc/mysql/en/fulltext-search.html Another thing to look at is optimizing your column types. If for instance you have single characters stored in a column that is defined as type BLOB instead of CHAR, your going to slow your queries a bit. - http://dev.mysql.com/doc/mysql/en/data-size.html Good luck! -Joe On Jul 23, 2005, at 6:18 AM, Jasper Bryant-Greene wrote: balwant singh wrote: Hi, I have made a webpage in php which retrieves the data from a huge MYSQL tables as below:- $i=0; while ($i=23) { select a, b from table where hour(time)=$i and date='' order by desc time limit 1; $i++; } then i substract the current hour output from the last hour output for calcuating the output in that hour through PHP code and then display it. But my problem is that this page takes approx. 90 seconds or more for loading even when i refresh the page, it is taking the same time. I have done indexing on that table, tune the php and apache but it is still taking same time. I have other tables also when PHP is doing more calculatios but those pages are not taking so much time they load in 5 sec. or so. Is there anything needs to be done more, please advise. Don't loop through in PHP and execute the query 23 times. Instead, execute the query once (without the hour(time)=$1 and and the limit 1, and use a while($row = mysql_fetch_assoc($result)) { } type function to get all 23 rows. That will be much faster. By the way, that should probably be order by time desc not order by desc time. Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: System specific information gathering
As always, look for someone else's existing project and see how they did it. ;-) http://phpsysinfo.sourceforge.net/ Good Luck! -Joe On Jul 23, 2005, at 9:25 AM, André Medeiros wrote: First of all, you want to have the two values in seperate variables. After reading the contents from the file, do something like: -8--- -- function parseUptimeSeconds( $seconds ) { $resultArray = Array( 'weeks' = 0, 'days' = 0, 'hours' = 0, 'minutes' = 0, 'seconds' = 0); // check weeks while( $seconds 604800 ) { $resultArray['weeks']++; $seconds -= 604800; } // check days while( $seconds 86400) { $resultArray['days']++; $seconds -= 86400; } // check hours while( $seconds 3600) { $resultArray['hours']++; $seconds -= 3600; } // check minutes while( $seconds 60) { $resultArray['minutes']++; $seconds -= 60; } $resultArray['seconds'] = $seconds; return( $resultArray ); } // separate both values list( $uptimeSeconds, $idleSeconds ) = explode( ' ', $lineReadFromFile ); $uptimeElements = parseUptimeSeconds( $uptimeSeconds ); $idleElements = parseUptimeSeconds( $idleSeconds ); -8--- -- I know there might be a more efficient way of doing this, like using the modulus operator, but hey :) On 7/23/05, Ramil Sagum [EMAIL PROTECTED] wrote: On 7/23/05, Vidyut Luther [EMAIL PROTECTED] wrote: Ok, If I use the file_get_contents.. how do I actually parse the contents on /proc/uptime cat /proc/uptime 1400293.13 1317047.64 The first number is the total uptime in seconds, the second number is the total idle time. -- ramil http://ramil.sagum.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PEAR DB issue
* Chris Boget [EMAIL PROTECTED]: I'm using PEAR::DB to connect to a MS SQL Server 2000. I'm attempting to run the following query: SELECT * FROM myTable FOR XML AUTO, ELEMENTS When I run the above query using the Query Analyzer, I get back the results as expected. However, when I try to run the same query using PEAR, I get the following error: [nativecode=4004 - Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier.] and I'm not sure why. I've googled the error and see that alot of other people are getting the same error (though, it doesn't seem that they are necessarily using PEAR). From what I can tell, it is a client error and not a server error. So my questions are 1) is there something wrong with PEAR and 2) if so, is there a fix in the works? Does anyone know? But that aside, has anyone else come up against this issue and found a workaround using PEAR? You should probably post this to php-pear-general, or to the pear-dev list. If no response there, or if no solutions are forthcoming, file a bug report with PEAR::DB. PEAR::DB *is* under active maintainership, from what I can tell, and some of the more recent changes had to do with MS-SQL report, if memory serves. Good luck! -- Matthew Weier O'Phinney Zend Certified Engineer http://weierophinney.net/matthew/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php