Re: [PHP] A MySQL Question
On Mon, 2008-12-08 at 23:50 -0800, Yeti wrote: ?php define('HUMAN_STUPIDITY', true); function bigbang() { while (HUMAN_STUPIDITY || !isset($debate_is_over)) { } return true; } if (!isset($universe)) bigbang(); ? Who says the big bang is past? I can't hear it. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
German Geek wrote: On Tue, Dec 9, 2008 at 2:46 PM, Micah Gersten [EMAIL PROTECTED] wrote: Robert Cummings wrote: On Tue, 2008-12-09 at 00:16 +, Nathan Rixham wrote: Ashley Sheridan wrote: On Mon, 2008-12-08 at 23:23 +, [EMAIL PROTECTED] wrote: Presumable, the EXISTS sub-query can be optimized sometimes to just stop processing the sub-query and kick things back out to the outer query. IN has to process them all and find them all. Don't forget the special case use as well: IF NOT EXISTS `universe` THEN bigbang() Ash www.ashleysheridan.co.uk any chance of writing the implementation of that bigbang() function? If nothing exists and a universe is created via a big bang... does it make a sound? Can we realistically call it a big bang if it doesn't make a sound? Couldn't we call it the big light show? But then again... if nothing exists and a universe is created via a big light show... does it matter? Can it be perceived? Is this just a proverbial pandrödinger's box? You can't implement the bigbang() function if you don't exist. Cheers, Rob. The function doesn't say who's doing the creating, it just checks for the existence of the universe. Lol, I agree, the function bigbang() doesn't need to be implemented (or it could be empty if it needs to be there for this line to work), because by definition, the universe must exist, if this statement is to exist. Although it would be interesting to see an implementation of a simulation of bigbang(). And, I would say there is a sound, even if no one is there to hear it, assuming it to have happened. Also if there were no sound, there would be no light show either, there would be nothing, which contradicts the assumption that the big bang was there (exists)... Guys, I think this is taking it a bit far... In space, no one can hear you scream... (or bang, for that matter) -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Stack Trace Length for Exceptions
I've been adding in exceptions at various points in the code so that I can more easily track where things are breaking and through which code path, but I just ran into a problem where it seems that the full stack trace isn't showing up in the error_logs. When I check out the logs, it only shows the last three frames, but I'd like it go all the way up the stack. Is the only solution to use something like debug_backtrace() instead, or is there some setting to change what gets printed to the error log? Thanks! Waynn
Re: [PHP] A MySQL Question
As a matter of fact, in space you can't even scream. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Accounting component in PHP
All my queries are complex. If I will use ORM, then I still will need another wrapper to create, for example template criteria objects. I have application that is very similar to billing system. Such type of applications definitely have other business logic levels in addition to ORM queries, as you might notice. Geek (de=German top level domain) wrote: You can do raw SQL queries with ORM as well, at least in symfony ;). An ORM makes other, rather trivial queries a whole lot easier though and a framework like symfony makes development of generic requirements a lot faster and cleaner. -- View this message in context: http://www.nabble.com/Accounting-component-in-PHP-tp20897026p20911661.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Accounting component in PHP
You can do raw queries also... Just makes trivial queries and your model (if you believe in modelling) easier to manage. Believe me, I thought like you did before using symfony. On Tue, Dec 9, 2008 at 10:52 PM, altern [EMAIL PROTECTED] wrote: All my queries are complex. If I will use ORM, then I still will need another wrapper to create, for example template criteria objects. I have application that is very similar to billing system. Such type of applications definitely have other business logic levels in addition to ORM queries, as you might notice. Geek (de=German top level domain) wrote: You can do raw SQL queries with ORM as well, at least in symfony ;). An ORM makes other, rather trivial queries a whole lot easier though and a framework like symfony makes development of generic requirements a lot faster and cleaner. -- View this message in context: http://www.nabble.com/Accounting-component-in-PHP-tp20897026p20911661.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Tim-Hinnerk Heuer http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
Re: [PHP] pear Mail/Mime problem on new Ubuntu Linux server
Might it be the Unix newline characters? Unlikely, IIRC the PEAR mime stuff uses \r\n (ie Windows). Try using the htmlMimeMail5 code here: http://www.phpguru.org/downloads/html.mime.mail/htmlMimeMail5/ -- Richard Heyes HTML5 Graphing for FF, Chrome, Opera and Safari: http://www.rgraph.org (Updated December 5th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Poll of sorts: Javascript Form validation or PHP
Being JSON immediately parsable by both Javascript and PHP it is possible to exploit it to keep the regular expressions for the input fields in a single place, and avoid mantaining them synched between the Js and PHP scripts! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
On Tue, Dec 9, 2008 at 10:49 PM, Yeti [EMAIL PROTECTED] wrote: As a matter of fact, in space you can't even scream. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I don't know if there is a better or best solution to this, but an infinite loop for something that is finite, I don't know... I do like the stick whacking the drum part though. :) And yes, you wouldnt hear anything in space, hadnt thought about that, so you can argue that the big bang didnt make a noise because it wouldnt have been hearable because there was nothing to carry the sound. For that matter it wouldnt have been seeable either. Something being hearable or seeable is different from someone/thing hearing or seeing it though. My point: Not trying to make one, or any sense either, because im probably contradicting myself here as are all of you, no offence. However, I find the big bang theory more convincing than any 7 days creation theory or things like that (sorry to all the religious people out there), But then you can always ask what was before that and before that and so on. But no one ever asks who or what created god in the first place, if s/he/it exists. Was s/he/it always there? Well then one could argue that the universe was always there too and there was no creation or big bang, or was good there for infinity and after a few quadrillion years, s/he/it became so bored and decided to make a big firework or only spend 7 days in creating everything? 7 days is a horribly short time for such a task after an infinite time of boredome. Maybe earth was always there (although this seems unlikely too). But do we really know that? I mean, ive read it in a book and learned it at school, but maybe we're all wrong and its all totally different to what is expected. To me only one thing is clear: We will never know how it all began, because a beginning of time and everything seems illogical to me, because there must have been something before that. Infinity, although to most not graspable seems a more graspable concept to me than finity. Anybody agree or am i alone in this universe? Sorry to go terribly off topic here...
[PHP] pear Mail/Mime problem on new Ubuntu Linux server
Hi All, Can someone think of a reason why when changing from a Windows 2003 Web Edition server running PHP 5.2 to a Ubuntu machine, also with PHP 5.2 can cause the following problem: The emails sent from the server, which should be in HTML format (the client wanted this specifically) now only show the plain text email, but only in Outlook XP or 2003. The Outlook 2007 on my work machine receives it fine, also my gmail account. Unfortunately, the client uses the Outlook version with the problem. Might it be the Unix newline characters? My first suspicion was to blame M$ for letting Outlook check the headers for example.com, postfix or Linux, but that might be a bit exajurated paranoia. lol Thanks for even reading this, even more for replying. :) Tim
[PHP] how do i allow more than 2 threads of php to run?
i'm getting freezes for the 3rd to Nth concurrent request on my homeserver (got root, on debian4 + apache2). how can i allow more threads? like 50 or so? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how do i allow more than 2 threads of php to run?
Rene Veerman schreef: i'm getting freezes for the 3rd to Nth concurrent request on my homeserver (got root, on debian4 + apache2). how can i allow more threads? like 50 or so? probably need to fix the apache.conf to allow more concurrent child processes. also note I said 'processes' - php is not totally threadsafe (due to unknowns in various extensions) and generally run under apache using the [apache] pre-fork worker module. it's apache that decides how many concurrent httpd processes are allowed to run, php merely runs as a part of each httpd process in the form of an apache module. you could be running php as CGI or FastCGI SAPI, which is different to using the apache module SAPI, but for the purposes on the above the same story goes. and if it's not an apache config issue then I guess your looking at some kind of OS limitation ... no idea about that I'm afraid. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] pear Mail/Mime problem on new Ubuntu Linux server
On Tue, Dec 9, 2008 at 6:57 AM, German Geek [EMAIL PROTECTED] wrote: Hi All, Can someone think of a reason why when changing from a Windows 2003 Web Edition server running PHP 5.2 to a Ubuntu machine, also with PHP 5.2 can cause the following problem: The emails sent from the server, which should be in HTML format (the client wanted this specifically) now only show the plain text email, but only in Outlook XP or 2003. The Outlook 2007 on my work machine receives it fine, also my gmail account. Unfortunately, the client uses the Outlook version with the problem. Might it be the Unix newline characters? My first suspicion was to blame M$ for letting Outlook check the headers for example.com, postfix or Linux, but that might be a bit exajurated paranoia. lol Thanks for even reading this, even more for replying. :) Tim I just had this problem. Try normalizing the line returns of your email before sending it. I was building mine from multiple sources (db, files, etc) and some had unix line returns, mac line returns, and windows. Normalizing them into a consistent format fixed it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how do i allow more than 2 threads of php to run?
Jochem Maas wrote: Rene Veerman schreef: i'm getting freezes for the 3rd to Nth concurrent request on my homeserver (got root, on debian4 + apache2). how can i allow more threads? like 50 or so? probably need to fix the apache.conf to allow more concurrent child processes. K, how do i do that? I looked at the apache2 docs but couldnt find the setting to tweak -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
At 12:44 AM +1300 12/10/08, German Geek wrote: Anybody agree or am i alone in this universe? Of course you are alone. As for the existence and history of the Universe, the Earth, you, or God -- it's all a matter of perception; and what you believe to be true; and on what the foundations you accept for those truths. My beliefs will never be yours and vice versa. I don't see: $bigBang = explode(null); to be any more/less true than: $belief = function_exists($God); Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how do i allow more than 2 threads of php to run?
Rene Veerman schreef: Jochem Maas wrote: Rene Veerman schreef: i'm getting freezes for the 3rd to Nth concurrent request on my homeserver (got root, on debian4 + apache2). how can i allow more threads? like 50 or so? probably need to fix the apache.conf to allow more concurrent child processes. K, how do i do that? I looked at the apache2 docs but couldnt find the setting to tweak look for these (these just happen to be the settings for my local dev install): StartServers 1 MinSpareServers 1 MaxSpareServers 2 MaxClients 16 MaxRequestsPerChild 1000 i'd imagine MaxClients is the one you will need to 'up' also STW for 'apache prefork MPM' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how do i allow more than 2 threads of php to run?
Jochem Maas wrote: Rene Veerman schreef: Jochem Maas wrote: Rene Veerman schreef: i'm getting freezes for the 3rd to Nth concurrent request on my homeserver (got root, on debian4 + apache2). how can i allow more threads? like 50 or so? probably need to fix the apache.conf to allow more concurrent child processes. K, how do i do that? I looked at the apache2 docs but couldnt find the setting to tweak look for these (these just happen to be the settings for my local dev install): StartServers 1 MinSpareServers 1 MaxSpareServers 2 MaxClients 16 MaxRequestsPerChild 1000 i'd imagine MaxClients is the one you will need to 'up' also STW for 'apache prefork MPM' sry, but that didn't fix things. it was already at 150 (i tried 250), and my webserver freezes on 1 to 3 open connections, can't tell for sure. but it's a real low number.. # prefork MPM # StartServers: number of server processes to start # MinSpareServers: minimum number of server processes which are kept spare # MaxSpareServers: maximum number of server processes which are kept spare # MaxClients: maximum number of server processes allowed to start # MaxRequestsPerChild: maximum number of requests a server process serves IfModule mpm_prefork_module StartServers 5 MinSpareServers 5 MaxSpareServers 10 MaxClients 150 MaxRequestsPerChild 0 /IfModule # worker MPM # StartServers: initial number of server processes to start # MaxClients: maximum number of simultaneous client connections # MinSpareThreads: minimum number of worker threads which are kept spare # MaxSpareThreads: maximum number of worker threads which are kept spare # ThreadsPerChild: constant number of worker threads in each server process # MaxRequestsPerChild: maximum number of requests a server process serves IfModule mpm_worker_module StartServers 2 MaxClients 150 MinSpareThreads 25 MaxSpareThreads 75 ThreadsPerChild 25 MaxRequestsPerChild 0 /IfModule -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how do i allow more than 2 threads of php to run?
Rene Veerman wrote: i'm getting freezes for the 3rd to Nth concurrent request on my homeserver (got root, on debian4 + apache2). how can i allow more threads? like 50 or so? Any chance that you're using session and checking it from the same browser from different tabs (using same session ID)? If the answer is yes. than you might want to look at the following function: session_write_close() http://www.php.net/manual/en/function.session-write-close.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Poll of sorts: Javascript Form validation or PHP
Being JSON immediately parsable by both Javascript and PHP it is possible to exploit it to keep the regular expressions for the input fields in a single place, and avoid mantaining them synched between the Js and PHP scripts! Yes, but... The Regex engines are not the same, so you have to keep it to simple simple simple expressions that work for both. I've done this before, actually, without the JSON part. //apologies to mathematicians for calling it int $int_pattern = '^[0-9]+$'; $errors = array(); if (!preg_match($int_pattern, $_REQUEST['foo']){ $errors['foo'] = foo must be a number; } /* ... */ if (count($errors[])){ //re-display form with errors highlighted etc } else{ //move along } ? script type=text/javascript var int_pattern = ?php echo $int_pattern?; function validate(){ } /script -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
Perhaps you couldn't hear the big bang in this universe, but what about in the universe that spawned it? :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
On Tue, Dec 9, 2008 at 11:40 AM, [EMAIL PROTECTED] wrote: Perhaps you couldn't hear the big bang in this universe, but what about in the universe that spawned it? :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php The omniverse or the underverse? -- Bastien Cat, the other other white meat
Re: [PHP] Include directive..
dele454 wrote: Hi, I am modifying the apache config file on my domain to include the path to the Zend Framework on a specified location outside the public folder. So in my http.conf file i simply include the path to where the includes file is to customise the virtual host: [CODE] # To customize this VirtualHost use an include file at the following location Include /usr/local/apache/conf/userdata/std/2/domains/mydomain.co.za/me.conf [/CODE] And then me.conf looks like this: [CODE] Include /home/domain/apps Include /home/domain/apps/models Include /home/domain/apps/lib [/CODE] But then i get this error: [CODE] Failed to generate a syntactically correct Apache configuration. Bad configuration file located at /usr/local/apache/conf/httpd.conf.1228614930 Error: Configuration problem detected on line 277 of file /usr/local/apache/conf/httpd.conf.1228614930:: Syntax error on line 1 of /usr/local/apache/conf/userdata/std/2/domain/mydomain.co.za/me.conf: Syntax error on line 1 of /home/domain/apps/Bootstrap.php: /home/maineven/apps/Bootstrap.php:1: ?php was not closed.[/CODE] But i do have the ?php tag closed in my Bootstrap file. I dont know why it is saying otherwise. Please help is needed. Thanks - dee Taking in what everybody else has already pointed out, I would like to add that their is a php configuration option that will do something along the line of what you are trying to do. It is called the 'auto_prepend_file' option. You could do something like this in your httpd.conf file instead of what you are trying to do. VirtualHost IP:PORT ... All Your normal stuff ... php_value auto_prepend_file '/path/to/file.php' /VirtualHost The above code will include your php file as a standard php include every time someone visits the given VirtualHost block. Hope this helps. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] echo SESSION var doesn't work if unset after echo
I set Ecomm to a little javascript code on the previous page then echo it no the next page. session_cache_limiter ('private, must-revalidate'); session_start(); . stuff ... if(isset($_SESSION[Ecomm])) { echo $_SESSION[Ecomm]; unset($_SESSION[Ecomm]); } . stuff ... For some unknown reason echoing this particular session var is now blank and the page's source code proves that it is missing. Now when I comment out the unset statement, then the crazy thing works. I see the code in the page's source. It is as if php is doing this: if(isset($_SESSION[Ecomm])) { unset($_SESSION[Ecomm]); echo $_SESSION[Ecomm]; } No kernel, apache, or php updates have happened. An there's not errors logged. Truely strange. Any ideas? -Eric Wood
Re: [PHP] A MySQL Question
On Tue, 2008-12-09 at 16:40 +, [EMAIL PROTECTED] wrote: Perhaps you couldn't hear the big bang in this universe, but what about in the universe that spawned it? :-) The black hole wouldn't allow it to travel in that direction ;) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
On Tue, 2008-12-09 at 01:49 -0800, Yeti wrote: As a matter of fact, in space you can't even scream. Sure you can... I'm screaming right now... and I'm in space. A container within a container within a container within a container (ad infinitum) is still within the outermost container. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo SESSION var doesn't work if unset after echo
Fire up Live HTTP Headers in Firefox. My theory is that the browser is RE-requesting the data because of the private, must-revalidate. So it goes like this: Browser - GET - Ecomm: fooie ; unset Ecomm Browser - GET - Ecomm: [not set] If you are using Ajax and JS and whatnot, the probability of this being the culprit increases. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include directive..
Dele wrote: Hi, Thanks for the reply. What I did was to edit the includes path in my php.ini file to specify the location to my script folders. I did that but now am experiencing another problem. Don't know if you are into the Zend Framework. :) But any help on tis post will be appreciated thanks Nope, I know nothing about ZF. Sorry. http://www.nabble.com/ZF-live-settings-td20911516.html Regards Dele (C) 071 673 4130 (E) [EMAIL PROTECTED] (S) dee454 Start by doing what's necessary; then do what's possible; and suddenly you are doing the impossible. - St. Francis of Assisi. Disclaimer: This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. -Original Message- From: Jim Lucas [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 09, 2008 8:19 PM To: dele454 Cc: php-general@lists.php.net Subject: Re: [PHP] Include directive.. dele454 wrote: Hi, I am modifying the apache config file on my domain to include the path to the Zend Framework on a specified location outside the public folder. So in my http.conf file i simply include the path to where the includes file is to customise the virtual host: [CODE] # To customize this VirtualHost use an include file at the following location Include /usr/local/apache/conf/userdata/std/2/domains/mydomain.co.za/me.conf [/CODE] And then me.conf looks like this: [CODE] Include /home/domain/apps Include /home/domain/apps/models Include /home/domain/apps/lib [/CODE] But then i get this error: [CODE] Failed to generate a syntactically correct Apache configuration. Bad configuration file located at /usr/local/apache/conf/httpd.conf.1228614930 Error: Configuration problem detected on line 277 of file /usr/local/apache/conf/httpd.conf.1228614930:: Syntax error on line 1 of /usr/local/apache/conf/userdata/std/2/domain/mydomain.co.za/me.conf: Syntax error on line 1 of /home/domain/apps/Bootstrap.php: /home/maineven/apps/Bootstrap.php:1: ?php was not closed.[/CODE] But i do have the ?php tag closed in my Bootstrap file. I dont know why it is saying otherwise. Please help is needed. Thanks - dee Taking in what everybody else has already pointed out, I would like to add that their is a php configuration option that will do something along the line of what you are trying to do. It is called the 'auto_prepend_file' option. You could do something like this in your httpd.conf file instead of what you are trying to do. VirtualHost IP:PORT ... All Your normal stuff ... php_value auto_prepend_file '/path/to/file.php' /VirtualHost The above code will include your php file as a standard php include every time someone visits the given VirtualHost block. Hope this helps. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] get calling function name
Greetings, is there a way (i swear i saw it in the documentation at one point) to get the name of the calling scope (or function) from within another function? eg. function a() { b(); } function b() { echo the calling function is: . func_caller(); } a(); where this would print the calling function is a (i made func_caller() up) I hope this is clear, and i hope there is a quick solution and i just can't find it in the documentation. Thanks, dk
Re: [PHP] A MySQL Question
Sure you can... I'm screaming right now... and I'm in space. A container within a container within a container within a container (ad infinitum) is still within the outermost container. I didn't hear you scream. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] get calling function name
On 9 Dec 2008, at 19:37, Daniel Kolbo wrote: is there a way (i swear i saw it in the documentation at one point) to get the name of the calling scope (or function) from within another function? eg. function a() { b(); } function b() { echo the calling function is: . func_caller(); } a(); where this would print the calling function is a (i made func_caller() up) I hope this is clear, and i hope there is a quick solution and i just can't find it in the documentation. http://php.net/debug_backtrace -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo SESSION var doesn't work if unset after echo
On Tue, 2008-12-09 at 19:11 +, [EMAIL PROTECTED] wrote: Fire up Live HTTP Headers in Firefox. My theory is that the browser is RE-requesting the data because of the private, must-revalidate. So it goes like this: Browser - GET - Ecomm: fooie ; unset Ecomm Browser - GET - Ecomm: [not set] If you are using Ajax and JS and whatnot, the probability of this being the culprit increases. :-) If the php is executed because of a GET request, i.e. from a link, then the page could well be requested twice. I've seen this happen before, where I was adding entries to a database when a user navigated to a certain page from a link. The way I solved it was to add a timestamp and check to see if an exact duplicate entry had been made within the last n seconds before adding it. You could add a time value to the session and check against this before unsetting the session? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo SESSION var doesn't work if unset after echo
On Wed, Dec 10, 2008 at 8:11 AM, [EMAIL PROTECTED] wrote: Fire up Live HTTP Headers in Firefox. Where is this Live HTTP Headers in Firefox? Is it an extension? My theory is that the browser is RE-requesting the data because of the private, must-revalidate. So it goes like this: Browser - GET - Ecomm: fooie ; unset Ecomm Browser - GET - Ecomm: [not set] If you are using Ajax and JS and whatnot, the probability of this being the culprit increases. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Tim-Hinnerk Heuer http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
Re: [PHP] how do i allow more than 2 threads of php to run?
Hi! Please note that most browser follows the RFC:s and does not allow more than two connections to each domain simultaneously. You can do work-arounds to solve this problem, like using subdomains for some requests. In Firefox you might also be able to disable this feature... Regards, Krister Karlström, Helsinki Rene Veerman wrote: i'm getting freezes for the 3rd to Nth concurrent request on my homeserver (got root, on debian4 + apache2). how can i allow more threads? like 50 or so? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how do i allow more than 2 threads of php to run?
Assuming this is in-fact your issue, I ALWAYS do this registry hack on my Windows computers: http://support.microsoft.com/kb/282402 On Tue, 2008-12-09 at 22:10 +0200, Krister Karlström wrote: Hi! Please note that most browser follows the RFC:s and does not allow more than two connections to each domain simultaneously. You can do work-arounds to solve this problem, like using subdomains for some requests. In Firefox you might also be able to disable this feature... Regards, Krister Karlström, Helsinki Rene Veerman wrote: i'm getting freezes for the 3rd to Nth concurrent request on my homeserver (got root, on debian4 + apache2). how can i allow more threads? like 50 or so?
Re: [PHP] how do i allow more than 2 threads of php to run?
On Tue, 2008-12-09 at 12:19 -0800, Daevid Vincent wrote: Assuming this is in-fact your issue, I ALWAYS do this registry hack on my Windows computers: http://support.microsoft.com/kb/282402 On Tue, 2008-12-09 at 22:10 +0200, Krister Karlström wrote: Hi! Please note that most browser follows the RFC:s and does not allow more than two connections to each domain simultaneously. You can do work-arounds to solve this problem, like using subdomains for some requests. In Firefox you might also be able to disable this feature... Regards, Krister Karlström, Helsinki Rene Veerman wrote: i'm getting freezes for the 3rd to Nth concurrent request on my homeserver (got root, on debian4 + apache2). how can i allow more threads? like 50 or so? You still use IE? *gasp* Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] MSSQL_CONNECT problem
Bastien - I'm getting desperate, Yes, I'm using a valid SQL account. I've tried putting both versions of ntwdblib.dll in the php directory, and the system32 directory (not at once of course), and I get the same error. I've pretty much tried everything I've readthe kicker is I can access the SQL Server fine by using ADO in PHP. It's only when I try mssql_connect that the connection fails The whole reason I don't use ADO is because the queries don't stand up to SQL injection...So I wanted to use mssql_connect with mssql_bind so I can do parameterized queries Do you have any other thoughts? Thanks! From: Bastien Koert [mailto:[EMAIL PROTECTED] Sent: Monday, December 08, 2008 10:02 AM To: Dan Shirah Cc: David Stoltz; php-general@lists.php.net Subject: Re: [PHP] MSSQL_CONNECT problem On Mon, Dec 8, 2008 at 9:45 AM, Dan Shirah [EMAIL PROTECTED] wrote: Can't seem to connect with MSSQL_CONNECT. The function IS available. I'm in a Windows environment, connecting to a SQL 2000 instance. My code: mssql_connect('INTRA_SQL,1433', 'uname', 'password'); mssql_select_db('database'); I've tried leaving the port out, tried using server IP address, all to no avail. I've copied the ntwdblib.dll from my SQL 2000 box to my PHP directory on the web server - no go. (this was suggested on the php site). mssql.secure_connection = off (in the php.ini file) extension=php_mssql.dll (is also included in the ini file) Keep getting error message: Unable to connect to server Does anyone have any ideas? Thanks! Dave Dave, For my connection I didn't copy the ntwdblib.dll file from the SQL Server and paste it onto the PHP server...I believe there was an older version of the ntwdblib.dll that I had to download...the file had a modification date of I think 11/2003. Things to check. extension=php_mssql.dll uncommented in your PHP.ini See if your PHP server can talk to your SQL Server. I would assume they are both inside the DMZ and that your DNS resolves the server names, correct? When making your connection try doing it like this: //Assign the server connection to a variable $connect = mssql_connect('SERVERNAME, 'USERNAME', 'PASSWORD'); //Select your database and reference the connection mssql_select_db('DATABASE', $connection); Have you created a mssql account to allow connetion from whereever you are coming from? -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] get calling function name
Stut wrote: On 9 Dec 2008, at 19:37, Daniel Kolbo wrote: is there a way (i swear i saw it in the documentation at one point) to get the name of the calling scope (or function) from within another function? eg. function a() { b(); } function b() { echo the calling function is: . func_caller(); } a(); where this would print the calling function is a (i made func_caller() up) I hope this is clear, and i hope there is a quick solution and i just can't find it in the documentation. http://php.net/debug_backtrace -Stut Stut, that'll do the trick. thanks, dK
Re: [PHP] MSSQL_CONNECT problem
On Tue, Dec 9, 2008 at 3:41 PM, David Stoltz [EMAIL PROTECTED] wrote: Do you have any other thoughts? When posting to the list, please don't top-post. Dave, are you seeing that error from both the CLI and the web? Have you properly configured your DSN? What's the output from the following? ?php mssql_connect('INTRA_SQL,1433', 'uname', 'password') or die('MSSQL Error on Line '.__LINE__.': '.mssql_error()); mssql_select_db('database') or die('MSSQL Error on Line '.__LINE__.': '.mssql_error()); ? -- /Daniel P. Brown http://www.parasane.net/ [EMAIL PROTECTED] || [EMAIL PROTECTED] 50% Off Hosting! http://www.pilotpig.net/specials.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how do i allow more than 2 threads of php to run?
Gal Gur-Arie wrote: Rene Veerman wrote: i'm getting freezes for the 3rd to Nth concurrent request on my homeserver (got root, on debian4 + apache2). how can i allow more threads? like 50 or so? Any chance that you're using session and checking it from the same browser from different tabs (using same session ID)? If the answer is yes. than you might want to look at the following function: session_write_close() http://www.php.net/manual/en/function.session-write-close.php YEEEAH! this fixed it! ur a lifesaver :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] how to not show login info in the url ...what am I looking for?
So I have this login information passing parameters in the url to the next page (this is on a intranet app) which I thought was no big deal until a wise crack graphics guy decided to hack it because he could by changing the ?adminID= until he got one that worked...he didn't do anything except alert my boss so now I have to hide this info how does one do this? Once again I am not a programmer just inherited the joband the code... Here is the login page code: ?php if (isset($_POST['UserName'])) {$UserName = $_POST['UserName'];} else {$UserName = '';} if (isset($_POST['Password'])) {$Password = $_POST['Password'];} else {$Password = '';} $msg = ''; if (!empty($UserName)) { $sql = SELECT * FROM admin WHERE UserName='$UserName' and Password='$Password'; $result = mysql_query ($sql); $row = mysql_fetch_object ($result); If (mysql_num_rows($result) 0) { $_SESSION['AdminLogin'] = OK; header (Location: Main.php?AdminID=. $row-AdminID); } else { $msg = Invalid Login; } } ? HTML HEAD TITLEWork Order System - Administrative Section/TITLE LINK REL=STYLESHEET HREF=inc/style.css script language=JavaScript !-- function leftTrim(sString) { while (sString.substring(0,1) == ' ') { sString = sString.substring(1, sString.length); } return sString; } function chkData1(objForm) { objForm.UserName.value = leftTrim(objForm.UserName.value); if (objForm.UserName.value.length == 0) { alert(Please enter your User Name.); objForm.Email.focus(); return false; } objForm.Password.value = leftTrim(objForm.Password.value); if (objForm.Password.value.length == 0) { alert(Please enter a your Password.); objForm.Password.focus(); objForm.Password.select(); return false; } return true; } //-- /script /HEAD BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 TABLE WIDTH=780 BORDER=0 CELLSPACING=0 CELLPADDING=0 TR TDnbsp;/TD /TR TR TD ALIGN=CENTERBWork Order System - Administrative Section/BBRBR/TD /TR TR TD ?php If (!empty($msg)){ echo div class=\cl_Error\. $msg ./div; } ? form name=form1 method=post action=Index.php onSubmit=return chkData1(this) TABLE WIDTH=300 BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=center bgcolor=#CC TR TD HEIGHT=22div class=admin_MainUsername:/div/TD TD HEIGHT=22 INPUT TYPE=text NAME=UserName/TD /TR TR TDdiv class=admin_MainPassword:/div/TD TDINPUT TYPE=password NAME=Password/TD /TR TR TD colspan=2 align=centerINPUT TYPE=submit VALUE=Login /TD /TR /TABLE /form BR Thanks guys and gals!
Re: [PHP] how to not show login info in the url ...what am I looking for?
On Tue, 2008-12-09 at 15:41 -0600, Terion Miller wrote: So I have this login information passing parameters in the url to the next page (this is on a intranet app) which I thought was no big deal until a wise crack graphics guy decided to hack it because he could by changing the ?adminID= until he got one that worked...he didn't do anything except alert my boss so now I have to hide this info how does one do this? Once again I am not a programmer just inherited the joband the code... Here is the login page code: ?php if (isset($_POST['UserName'])) {$UserName = $_POST['UserName'];} else {$UserName = '';} if (isset($_POST['Password'])) {$Password = $_POST['Password'];} else {$Password = '';} $msg = ''; if (!empty($UserName)) { $sql = SELECT * FROM admin WHERE UserName='$UserName' and Password='$Password'; $result = mysql_query ($sql); $row = mysql_fetch_object ($result); If (mysql_num_rows($result) 0) { $_SESSION['AdminLogin'] = OK; header (Location: Main.php?AdminID=. $row-AdminID); } else { $msg = Invalid Login; } } ? HTML HEAD TITLEWork Order System - Administrative Section/TITLE LINK REL=STYLESHEET HREF=inc/style.css script language=JavaScript !-- function leftTrim(sString) { while (sString.substring(0,1) == ' ') { sString = sString.substring(1, sString.length); } return sString; } function chkData1(objForm) { objForm.UserName.value = leftTrim(objForm.UserName.value); if (objForm.UserName.value.length == 0) { alert(Please enter your User Name.); objForm.Email.focus(); return false; } objForm.Password.value = leftTrim(objForm.Password.value); if (objForm.Password.value.length == 0) { alert(Please enter a your Password.); objForm.Password.focus(); objForm.Password.select(); return false; } return true; } //-- /script /HEAD BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 TABLE WIDTH=780 BORDER=0 CELLSPACING=0 CELLPADDING=0 TR TDnbsp;/TD /TR TR TD ALIGN=CENTERBWork Order System - Administrative Section/BBRBR/TD /TR TR TD ?php If (!empty($msg)){ echo div class=\cl_Error\. $msg ./div; } ? form name=form1 method=post action=Index.php onSubmit=return chkData1(this) TABLE WIDTH=300 BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=center bgcolor=#CC TR TD HEIGHT=22div class=admin_MainUsername:/div/TD TD HEIGHT=22 INPUT TYPE=text NAME=UserName/TD /TR TR TDdiv class=admin_MainPassword:/div/TD TDINPUT TYPE=password NAME=Password/TD /TR TR TD colspan=2 align=centerINPUT TYPE=submit VALUE=Login /TD /TR /TABLE /form BR Thanks guys and gals! You shouldn't be passing info like that over the URL; use sessions instead. I saw a shopping cart system once that passed the price of items over the URL, and when I found out and alerted them, we won the contract for a rebuild and then got accused of hacking by their previous web guys (who incidentally built the system!) Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to not show login info in the url ...what am I looking for?
On 9 Dec 2008, at 21:41, Terion Miller wrote: So I have this login information passing parameters in the url to the next page (this is on a intranet app) which I thought was no big deal until a wise crack graphics guy decided to hack it because he could by changing the ?adminID= until he got one that worked...he didn't do anything except alert my boss so now I have to hide this info how does one do this? Once again I am not a programmer just inherited the joband the code... Here is the login page code: ?php if (isset($_POST['UserName'])) {$UserName = $_POST['UserName'];} else {$UserName = '';} if (isset($_POST['Password'])) {$Password = $_POST['Password'];} else {$Password = '';} $msg = ''; if (!empty($UserName)) { $sql = SELECT * FROM admin WHERE UserName='$UserName' and Password='$Password'; $result = mysql_query ($sql); $row = mysql_fetch_object ($result); If (mysql_num_rows($result) 0) { $_SESSION['AdminLogin'] = OK; header (Location: Main.php?AdminID=. $row-AdminID); } else { $msg = Invalid Login; } } ? No need to pass AdminID in the URL at all. Store that ID in the AdminLogin session variable instead of OK and you can get it from there on every subsequent page. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo SESSION var doesn't work if unset after echo
I have two vars doing the same thing. One is echo'd/unset in the head/head section and the other echo'd/unset in the footer of the page. No re-direct request is being made. Ok now check this. If I use this code: if(isset($_SESSION[Ecomm])) { echo $_SESSION[Ecomm]; unset($_SESSION[Ecomm]); } I can *NOT* see the Ecomm contents in the right-click - View Page Source. I do see the complete in the View Generated Source. Now, If I comment out the unset: if(isset($_SESSION[Ecomm])) { echo $_SESSION[Ecomm]; // unset($_SESSION[Ecomm]); } Then I *CAN* see the Ecomm code in the in the right-click - View Page Source as well as the View Generated Source. I am very humbled right now. -eric wood - Original Message - From: [EMAIL PROTECTED] My theory is that the browser is RE-requesting the data because of the private, must-revalidate. So it goes like this: Browser - GET - Ecomm: fooie ; unset Ecomm Browser - GET - Ecomm: [not set] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo SESSION var doesn't work if unset after echo
On Tue, 2008-12-09 at 16:51 -0500, Eric Wood wrote: I have two vars doing the same thing. One is echo'd/unset in the head/head section and the other echo'd/unset in the footer of the page. No re-direct request is being made. Ok now check this. If I use this code: if(isset($_SESSION[Ecomm])) { echo $_SESSION[Ecomm]; unset($_SESSION[Ecomm]); } I can *NOT* see the Ecomm contents in the right-click - View Page Source. I do see the complete in the View Generated Source. Now, If I comment out the unset: if(isset($_SESSION[Ecomm])) { echo $_SESSION[Ecomm]; // unset($_SESSION[Ecomm]); } Then I *CAN* see the Ecomm code in the in the right-click - View Page Source as well as the View Generated Source. I am very humbled right now. -eric wood - Original Message - From: [EMAIL PROTECTED] My theory is that the browser is RE-requesting the data because of the private, must-revalidate. So it goes like this: Browser - GET - Ecomm: fooie ; unset Ecomm Browser - GET - Ecomm: [not set] I don't think anyone mentioned a redirect request. Rather, to speed up loading of pages, browsers make simultaneous GET requests for the page. This is why forms should always use GET to retrieve data that will not change, and POST to change data or state. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] file_exists and wildcard/regex
What is the preferred method with php to test and see if a file [pattern] exists? For example, i only need to search in one directory, that may have any number of files named such as afile1.txt, afile2.txt, afile3.txt, And also, bfile1.txt, bfile2.txt, bfile3.txt, ... I want to see if any such file 'family' exists. That is, i want to see if there is any file named bfile[1-9][0-9]+.txt. I don't care which bfile number exists, i just want to know if any bfile exists. I hope this is clear enough, if not let me know. thanks, dK
Re: [PHP] file_exists and wildcard/regex
On 9 Dec 2008, at 22:26, Daniel Kolbo wrote: What is the preferred method with php to test and see if a file [pattern] exists? For example, i only need to search in one directory, that may have any number of files named such as afile1.txt, afile2.txt, afile3.txt, And also, bfile1.txt, bfile2.txt, bfile3.txt, ... I want to see if any such file 'family' exists. That is, i want to see if there is any file named bfile[1-9][0-9]+.txt. I don't care which bfile number exists, i just want to know if any bfile exists. I hope this is clear enough, if not let me know. Use glob (http://php.net/glob) and get the size of the array returned. Note that if there could be thousands of matching files you may want to use opendir and readdir to look for matches instead. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_exists and wildcard/regex
Daniel Kolbo wrote: What is the preferred method with php to test and see if a file [pattern] exists? For example, i only need to search in one directory, that may have any number of files named such as afile1.txt, afile2.txt, afile3.txt, And also, bfile1.txt, bfile2.txt, bfile3.txt, ... I want to see if any such file 'family' exists. That is, i want to see if there is any file named bfile[1-9][0-9]+.txt. I don't care which bfile number exists, i just want to know if any bfile exists. I hope this is clear enough, if not let me know. thanks, dK After some more research it seems my options are: 1) loop through the directory contents 2) use scandir (then search the resulting array) 3) use glob. I am not familiar with the glob pattern library, it does not seem like i have the full power of regex when using glob is this correct? Also, searching the whole filesystem seems...overkill. What do you suggest, is there a 4th option? thanks, dK
Re: [PHP] file_exists and wildcard/regex
On Tue, 2008-12-09 at 12:54 -1000, Daniel Kolbo wrote: Daniel Kolbo wrote: What is the preferred method with php to test and see if a file [pattern] exists? For example, i only need to search in one directory, that may have any number of files named such as afile1.txt, afile2.txt, afile3.txt, And also, bfile1.txt, bfile2.txt, bfile3.txt, ... I want to see if any such file 'family' exists. That is, i want to see if there is any file named bfile[1-9][0-9]+.txt. I don't care which bfile number exists, i just want to know if any bfile exists. I hope this is clear enough, if not let me know. thanks, dK After some more research it seems my options are: 1) loop through the directory contents 2) use scandir (then search the resulting array) 3) use glob. I am not familiar with the glob pattern library, it does not seem like i have the full power of regex when using glob is this correct? Also, searching the whole filesystem seems...overkill. What do you suggest, is there a 4th option? thanks, dK If you're on a Linux system, you could look at ls and the regular expressions it lets you use with it. You could exec out and get the returned results. Also, as it's a system call, it should be very speedy. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: file_exists and wildcard/regex
Daniel Kolbo wrote: What is the preferred method with php to test and see if a file [pattern] exists? For example, i only need to search in one directory, that may have any number of files named such as afile1.txt, afile2.txt, afile3.txt, And also, bfile1.txt, bfile2.txt, bfile3.txt, ... I want to see if any such file 'family' exists. That is, i want to see if there is any file named bfile[1-9][0-9]+.txt. I don't care which bfile number exists, i just want to know if any bfile exists. I hope this is clear enough, if not let me know. thanks, dK glob() http://www.php.net/glob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_exists and wildcard/regex
I'm not sure how glob works in the guts, but I know it is dog-slow for large numbers of files (or maybe just large numbers of results). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: file_exists and wildcard/regex
Maciek Sokolewicz wrote: Daniel Kolbo wrote: What is the preferred method with php to test and see if a file [pattern] exists? For example, i only need to search in one directory, that may have any number of files named such as afile1.txt, afile2.txt, afile3.txt, And also, bfile1.txt, bfile2.txt, bfile3.txt, ... I want to see if any such file 'family' exists. That is, i want to see if there is any file named bfile[1-9][0-9]+.txt. I don't care which bfile number exists, i just want to know if any bfile exists. I hope this is clear enough, if not let me know. thanks, dK glob() http://www.php.net/glob How portable is glob? How fast is glob? Being that it searches through the entire filesystem, this could potentially take a long time (like if i have wildcards early in the filepath pattern and lots of matches) correct? If my file variations (wildcards) are just at the end of of the filepaths and i don't have more than 1000 files in the directory then will I most likely be 'alright' with glob (in terms of time)? I have probably spent more time now 'considering' the time implications of glob, than glob actually would consume when operating... Thanks for the quick response/solutions. dK
Re: [PHP] Re: file_exists and wildcard/regex
Daniel Kolbo wrote: Maciek Sokolewicz wrote: Daniel Kolbo wrote: What is the preferred method with php to test and see if a file [pattern] exists? For example, i only need to search in one directory, that may have any number of files named such as afile1.txt, afile2.txt, afile3.txt, And also, bfile1.txt, bfile2.txt, bfile3.txt, ... I want to see if any such file 'family' exists. That is, i want to see if there is any file named bfile[1-9][0-9]+.txt. I don't care which bfile number exists, i just want to know if any bfile exists. I hope this is clear enough, if not let me know. thanks, dK glob() http://www.php.net/glob How portable is glob? How fast is glob? Being that it searches through the entire filesystem, this could potentially take a long time (like if i have wildcards early in the filepath pattern and lots of matches) correct? If my file variations (wildcards) are just at the end of of the filepaths and i don't have more than 1000 files in the directory then will I most likely be 'alright' with glob (in terms of time)? I have probably spent more time now 'considering' the time implications of glob, than glob actually would consume when operating... glob('/path/to/folder/*.txt'); -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: file_exists and wildcard/regex
On 9 Dec 2008, at 23:24, Daniel Kolbo wrote: Maciek Sokolewicz wrote: Daniel Kolbo wrote: What is the preferred method with php to test and see if a file [pattern] exists? For example, i only need to search in one directory, that may have any number of files named such as afile1.txt, afile2.txt, afile3.txt, And also, bfile1.txt, bfile2.txt, bfile3.txt, ... I want to see if any such file 'family' exists. That is, i want to see if there is any file named bfile[1-9][0-9]+.txt. I don't care which bfile number exists, i just want to know if any bfile exists. I hope this is clear enough, if not let me know. thanks, dK glob() http://www.php.net/glob How portable is glob? How fast is glob? Being that it searches through the entire filesystem, this could potentially take a long time (like if i have wildcards early in the filepath pattern and lots of matches) correct? If my file variations (wildcards) are just at the end of of the filepaths and i don't have more than 1000 files in the directory then will I most likely be 'alright' with glob (in terms of time)? I have probably spent more time now 'considering' the time implications of glob, than glob actually would consume when operating... Thanks for the quick response/solutions. dK Glob works on all platforms. Glob does suffer from performance issues above a certain number of files, and this can be system dependant. If you're unsure how many files it may return you'd be better using opendir/readdir. Not sure where you got the idea that glob searches the entire file system, but it's limited to either the current working directory or the directory you specify. So if your PHP file is in /var/www/htdocs and you do glob('*.txt') you'll get all .txt files in /var/www/htdocs. And if you do glob('/tmp/*.txt') you'll get all .txt files in /tmp. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: file_exists and wildcard/regex
On Wed, Dec 10, 2008 at 1:13 PM, Stut [EMAIL PROTECTED] wrote: On 9 Dec 2008, at 23:24, Daniel Kolbo wrote: Maciek Sokolewicz wrote: Daniel Kolbo wrote: What is the preferred method with php to test and see if a file [pattern] exists? For example, i only need to search in one directory, that may have any number of files named such as afile1.txt, afile2.txt, afile3.txt, And also, bfile1.txt, bfile2.txt, bfile3.txt, ... I want to see if any such file 'family' exists. That is, i want to see if there is any file named bfile[1-9][0-9]+.txt. I don't care which bfile number exists, i just want to know if any bfile exists. I hope this is clear enough, if not let me know. thanks, dK glob() http://www.php.net/glob How portable is glob? How fast is glob? Being that it searches through the entire filesystem, this could potentially take a long time (like if i have wildcards early in the filepath pattern and lots of matches) correct? If my file variations (wildcards) are just at the end of of the filepaths and i don't have more than 1000 files in the directory then will I most likely be 'alright' with glob (in terms of time)? I have probably spent more time now 'considering' the time implications of glob, than glob actually would consume when operating... Thanks for the quick response/solutions. dK Glob works on all platforms. Glob does suffer from performance issues above a certain number of files, and this can be system dependant. If you're unsure how many files it may return you'd be better using opendir/readdir. Not sure where you got the idea that glob searches the entire file system, but it's limited to either the current working directory or the directory you specify. So if your PHP file is in /var/www/htdocs and you do glob('*.txt') you'll get all .txt files in /var/www/htdocs. And if you do glob('/tmp/*.txt') you'll get all .txt files in /tmp. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I wrote my own little function for a regex pattern match on files: class FileHandle { public static function copyReg($srcDir, $destDir, $regEx, $mkdir = false) { // ensure we have the right dir separator /(unix) \(win) and not at the end $srcDir = rtrim(str_replace(array('/','\\'), DIRECTORY_SEPARATOR, $srcDir), DIRECTORY_SEPARATOR); $destDir = rtrim(str_replace(array('/','\\'), DIRECTORY_SEPARATOR, $destDir), DIRECTORY_SEPARATOR); //echo DEST: . $destDir . END; if ($mkdir !is_dir($destDir)) mkdir($destDir, 0777, true); //make dir if not exists and mkdir if ($handle = opendir($srcDir)) { while (false !== ($file = readdir($handle))) { //echo $file\n; preg_match($regEx, $file, $matches); if ($file != '.' $file != '..' count($matches) 0) { //print(pre$regEx $srcDir $file \n=. print_r($matches,true)); copy($srcDir . DIRECTORY_SEPARATOR . $file, $destDir . DIRECTORY_SEPARATOR . $file); } } return true; } return false; } } Hope that helps. Don't know how good this will perform. -- Tim-Hinnerk Heuer http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
[PHP] usort for sorting an array of objects
Hi Guys, I need to sort an array of objects. I found this ( at a url that didnt let me send this msg... ) and I would know how to do it, but I believe there might be a cleaner, more elegant way to do it. In Java, you just need to implement the interface Comparable and provide a method called compareTo (as far as i remember) and then you can use one of the many sorting algorithms generically on objects that are comparable... Anyway, I didn't find something like that for PHP. Since I'm using symfony, I had a bit of a play with the objects at hand and simply did a sort($arrayOfObjects) and it did sort them by the id. Just wondering where it got the information on what to sort on (not quite) correctly for my case? Thanks for your interest. -- Tim-Hinnerk Heuer http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
Re: [PHP] MSSQL_CONNECT problem
On Tue, Dec 9, 2008 at 3:41 PM, David Stoltz [EMAIL PROTECTED] wrote: Yes, I'm using a valid SQL account. I've tried putting both versions of ntwdblib.dll in the php directory, and the system32 directory (not at once of course), and I get the same error. I've pretty much tried everything I've readthe kicker is I can access the SQL Server fine by using ADO in PHP. It's only when I try mssql_connect that the connection fails The whole reason I don't use ADO is because the queries don't stand up to SQL injection...So I wanted to use mssql_connect with mssql_bind so I can do parameterized queries Do you have any other thoughts? Thanks! I've had decent luck so far with the SQL Server Driver for PHP published by Microsoft since Jason pointed me to it a while ago. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_exists and wildcard/regex
[EMAIL PROTECTED] wrote: I'm not sure how glob works in the guts, but I know it is dog-slow for large numbers of files (or maybe just large numbers of results). I'm not sure what the context of this was, but the speed of searching a directory with a large number of files, e.g. 100,000s, also depends a lot on the filesystem. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_exists and wildcard/regex
Ashley Sheridan wrote: If you're on a Linux system, you could look at ls and the regular expressions it lets you use with it. You could exec out and get the returned results. Also, as it's a system call, it should be very speedy. 'ls' is just a plain binary (/bin/ls), not a system call. The regex functionality is part of the shell, usually bash. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php