RE: [PHP] Open New URL window
Ok, so I started using the header code that was suggested: And I get this error: Parse error: parse error, unexpected '{' in /home/char-lee/public_html/beta/1.php on line 3 This is the code: --- ?php if ($_POST['pw'] != burgers { header(Location: password.php); } else { header(Location: sept-coupon07.html); } ? --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Open New URL window
On Thu, 20 Sep 2007 02:52:19 -0400 Andrew Prostko said: Ok, so I started using the header code that was suggested: And I get this error: Parse error: parse error, unexpected '{' in /home/char-lee/public_html/beta/1.php on line 3 This is the code: --- ?php if ($_POST['pw'] != burgers { header(Location: password.php); } else { header(Location: sept-coupon07.html); } ? --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Close your parenthesis, daggummit! if ($_POST['pw'] != burgers ) ^^^ -- Don Read [EMAIL PROTECTED] -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Open New URL window FINAL ANSWER
Wow, it really must be late, Thank you for pointing out that missing parenthesis ... 330am and now I can go to bed happy... TY VM Ending Code for anyone listening: Get PW from another .php page using: form action=passwordcheck.php method=post br / What is the Password?: input type=text name=pw / input type=submit value=Submit!/ /form This is the passwordcheck.php code: ?php if ($_POST['pw'] != burgers) { header(Location: password.php); } else { header(Location: sept-coupon07.html); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Open New URL window
Andrew Prostko wrote: Ok, so I started using the header code that was suggested: And I get this error: Parse error: parse error, unexpected '{' in /home/char-lee/public_html/beta/1.php on line 3 This is the code: --- ?php if ($_POST['pw'] != burgers You'll be wanting to put burgers in quotes and close the bracket on the line above. if ($_POST['pw'] != 'burgers') { header(Location: password.php); } else { header(Location: sept-coupon07.html); } ? --- I suggest you find a beginners book or Google for a beginners tutorial on PHP because it would appear you need to learn some fundamentals of the language before continuing. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Open New URL window FINAL ANSWER
Andrew Prostko wrote: Wow, it really must be late, Thank you for pointing out that missing parenthesis ... 330am and now I can go to bed happy... TY VM Ending Code for anyone listening: Get PW from another .php page using: form action=passwordcheck.php method=post br / What is the Password?: input type=text name=pw / input type=submit value=Submit!/ /form This is the passwordcheck.php code: ?php if ($_POST['pw'] != burgers) You might want to quote that as well: 'burgers' otherwise php will look for a defined value called 'burgers', ie: php will look for this: define('burgers', 'xyz'); and try to compare against that (in this case the real password is 'xyz'). If you turn up error reporting: error_reporting(E_ALL); and display errors: ini_set('display_errors', true); you would see a message about this. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] highlighting searchterms as bold text
Hi everyone, I want to highlight (bold) searchterms in text. For example, for all words starting with ethyl: a) replace ethyl by bethyl/b b) replace Ethyl by bEthyl/b c) replace ethylene by bethylene/b d) but not methyl by bmethyl/b Now I use: $patterns[0] = /ethyl/; $replacements[0] = bethyl/b; $text = preg_replace($patterns, $replacements, $text); This works for a) and c), but not for b) and d). Any idea how to do this ? TIA, Cor
Re: [PHP] highlighting searchterms as bold text
- Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 10:38 AM Subject: RE: [PHP] highlighting searchterms as bold text try /^ethyl/i what you want is ignore case and pattern begins with -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:31 PM To: [EMAIL PROTECTED] Subject: [PHP] highlighting searchterms as bold text Hi everyone, I want to highlight (bold) searchterms in text. For example, for all words starting with ethyl: a) replace ethyl by bethyl/b b) replace Ethyl by bEthyl/b c) replace ethylene by bethylene/b d) but not methyl by bmethyl/b Now I use: $patterns[0] = /ethyl/; $replacements[0] = bethyl/b; $text = preg_replace($patterns, $replacements, $text); This works for a) and c), but not for b) and d). Any idea how to do this ? TIA, Cor Thanks Deniz, I tried pattern /^ethyl/i but this does not highlight anything. I also tried pattern /ethyl/i and this highlights all, but also methyl ... Any suggestion ? Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] highlighting searchterms as bold text
Hi everyone, I want to highlight (bold) searchterms in text. For example, for all words starting with ethyl: a) replace ethyl by bethyl/b b) replace Ethyl by bEthyl/b c) replace ethylene by bethylene/b d) but not methyl by bmethyl/b Now I use: $patterns[0] = /ethyl/; $replacements[0] = bethyl/b; $text = preg_replace($patterns, $replacements, $text); This works for a) and c), but not for b) and d). Any idea how to do this ? TIA, Cor Thanks Deniz, I tried pattern /^ethyl/i but this does not highlight anything. I also tried pattern /ethyl/i and this highlights all, but also methyl ... Any suggestion ? Yes, the i pattern modifier makes the search case-insensitive, which is what you want. The carat ^ means start of string, so would only word if the pattern was at the beginning of the line - not what you want. Try something like this: /(\s|)ethyl(\s|)/i The \s means whitespace so (\s|) means only match if ethyl is preceded by whitespace or , i.e. a closing tag. Alternatively, have a look at http://suda.co.uk/projects/SEHL/. Edward -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] highlighting searchterms as bold text
On 20 September 2007 11:34, Edward Kay wrote: Hi everyone, I want to highlight (bold) searchterms in text. For example, for all words starting with ethyl: a) replace ethyl by bethyl/b b) replace Ethyl by bEthyl/b c) replace ethylene by bethylene/b d) but not methyl by bmethyl/b Now I use: $patterns[0] = /ethyl/; $replacements[0] = bethyl/b; $text = preg_replace($patterns, $replacements, $text); This works for a) and c), but not for b) and d). Any idea how to do this ? TIA, Cor Thanks Deniz, I tried pattern /^ethyl/i but this does not highlight anything. I also tried pattern /ethyl/i and this highlights all, but also methyl ... Any suggestion ? Yes, the i pattern modifier makes the search case-insensitive, which is what you want. The carat ^ means start of string, so would only word if the pattern was at the beginning of the line - not what you want. Try something like this: /(\s|)ethyl(\s|)/i The \s means whitespace so (\s|) means only match if ethyl is preceded by whitespace or , i.e. a closing tag. Or you could try the \W character class which means any non-word character, or possibly even better the \b assertion which means word boundary. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, JG125, The Headingley Library, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 812 4730 Fax: +44 113 812 3211 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] highlighting searchterms as bold text
- Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 11:29 AM Subject: RE: [PHP] highlighting searchterms as bold text thats odd because the regex passes when I test it with this online tool: http://samuelfullman.com/team/php/tools/regular_expression_tester_p2.php -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:59 PM To: Deniz Dizman (BST UGB); [EMAIL PROTECTED] Subject: Re: [PHP] highlighting searchterms as bold text - Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 10:38 AM Subject: RE: [PHP] highlighting searchterms as bold text try /^ethyl/i what you want is ignore case and pattern begins with -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:31 PM To: [EMAIL PROTECTED] Subject: [PHP] highlighting searchterms as bold text Hi everyone, I want to highlight (bold) searchterms in text. For example, for all words starting with ethyl: a) replace ethyl by bethyl/b b) replace Ethyl by bEthyl/b c) replace ethylene by bethylene/b d) but not methyl by bmethyl/b Now I use: $patterns[0] = /ethyl/; $replacements[0] = bethyl/b; $text = preg_replace($patterns, $replacements, $text); This works for a) and c), but not for b) and d). Any idea how to do this ? TIA, Cor Thanks Deniz, I tried pattern /^ethyl/i but this does not highlight anything. I also tried pattern /ethyl/i and this highlights all, but also methyl ... Any suggestion ? Cor Hi Deniz, I tried the referred regex tool as well, and I get Bad Result for /^ethyl/i and Good Result for /ethyl/i Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Very Large text file parsing
I have a very large text file that gets dumped into a directoory every now and then. It is typically around 750MB long, at least, and my question is: What is the best method to parse this thing and insert the data into a postgres db? I have tried using file(), fget*() and some others, all with limited success. It goes through OK (I am sending it to a background process on the server and using a callback function to email me when done) but it is really knocking the machine hard, besides taking a real long time to finish. Is there a better way of approaching this? Any help would be greatly appreciated. --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Very Large text file parsing
Paul Scott wrote: I have a very large text file that gets dumped into a directoory every now and then. It is typically around 750MB long, at least, and my question is: What is the best method to parse this thing and insert the data into a postgres db? I have tried using file(), fget*() and some others, all with limited success. It goes through OK (I am sending it to a background process on the server and using a callback function to email me when done) but it is really knocking the machine hard, besides taking a real long time to finish. Is there a better way of approaching this? Any help would be greatly appreciated. First, which is your approach? I suspect that you are doing this with a cron job through php-cli. Now, to avoid using to many resources, try with fopen() and fgets(). Also work with persistent connections, so you don't have that overhead. The problem with file() is that it will load all the file to memory, and you don't want 700+MB in memory. -- 21:50:04 up 2 days, 9:07, 0 users, load average: 0.92, 0.37, 0.18 - Lic. Martín Marqués | SELECT 'mmarques' || Centro de Telemática| '@' || 'unl.edu.ar'; Universidad Nacional| DBA, Programador, del Litoral | Administrador - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] highlighting searchterms as bold text
Hi, Here's what you need: RegEx: /((\w+)?#SearchTermHere#(\w+)?)/i Of course, replace your #SearchTermHere# with what you need, i.e. /((\w+)?ethyl(\w+)?)/i Code sample: $_textToHighlight='ethyl Lorem Ethyl ipsum MeThYl dolor Ethylene sit'; $_search='/((\w+)?ethyl(\w+)?)/i'; $_replace='b\\1/b'; $_highlightedText=preg_replace($_search,$_replace,$_textToHighlight); This should output: bethyl/b Lorem bEthyl/b ipsum bMeThYl/b dolor bEthylene/b sit Hope it helps, PuYa C.R.Vegelin wrote: - Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 11:29 AM Subject: RE: [PHP] highlighting searchterms as bold text thats odd because the regex passes when I test it with this online tool: http://samuelfullman.com/team/php/tools/regular_expression_tester_p2.php -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:59 PM To: Deniz Dizman (BST UGB); [EMAIL PROTECTED] Subject: Re: [PHP] highlighting searchterms as bold text - Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 10:38 AM Subject: RE: [PHP] highlighting searchterms as bold text try /^ethyl/i what you want is ignore case and pattern begins with -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:31 PM To: [EMAIL PROTECTED] Subject: [PHP] highlighting searchterms as bold text Hi everyone, I want to highlight (bold) searchterms in text. For example, for all words starting with ethyl: a) replace ethyl by bethyl/b b) replace Ethyl by bEthyl/b c) replace ethylene by bethylene/b d) but not methyl by bmethyl/b Now I use: $patterns[0] = /ethyl/; $replacements[0] = bethyl/b; $text = preg_replace($patterns, $replacements, $text); This works for a) and c), but not for b) and d). Any idea how to do this ? TIA, Cor Thanks Deniz, I tried pattern /^ethyl/i but this does not highlight anything. I also tried pattern /ethyl/i and this highlights all, but also methyl ... Any suggestion ? Cor Hi Deniz, I tried the referred regex tool as well, and I get Bad Result for /^ethyl/i and Good Result for /ethyl/i Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Very Large text file parsing
Paul Scott wrote: I have a very large text file that gets dumped into a directoory every now and then. It is typically around 750MB long, at least, and my question is: What is the best method to parse this thing and insert the data into a postgres db? I have tried using file(), fget*() and some others, all with limited success. It goes through OK (I am sending it to a background process on the server and using a callback function to email me when done) but it is really knocking the machine hard, besides taking a real long time to finish. Is there a better way of approaching this? Any help would be greatly appreciated. First, which is your approach? I suspect that you are doing this with a cron job through php-cli. Now, to avoid using to many resources, try with fopen() and fgets(). Also work with persistent connections, so you don't have that overhead. The problem with file() is that it will load all the file to memory, and you don't want 700+MB in memory. In addition to Martin's good suggestions (and also assuming you're running php-cli via cron), you could use nice to stop it consuming too many resources: http://en.wikipedia.org/wiki/Nice_%28Unix%29 Edward -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Very Large text file parsing
On Thu, 2007-09-20 at 12:50 +0100, Edward Kay wrote: In addition to Martin's good suggestions (and also assuming you're running php-cli via cron), you could use nice to stop it consuming too many resources: This is the current approach that I am taking, was just really wondering if there was some kind of voodoo that would speed things up a bit. Thanks both for your responses, appreciate it! --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] highlighting searchterms as bold text
Sorry, I didn't read d) right (NOT Methyl), here is teh new regex : /(\b#SearchTermHere#(\w+)?)/i The code sample is the same, replace regex, of course . Output should be : bethyl/b Lorem bEthyl/b ipsum MeThYl dolor bEthylene/b sit Cheers Puiu Hrenciuc wrote: Hi, Here's what you need: RegEx: /((\w+)?#SearchTermHere#(\w+)?)/i Of course, replace your #SearchTermHere# with what you need, i.e. /((\w+)?ethyl(\w+)?)/i Code sample: $_textToHighlight='ethyl Lorem Ethyl ipsum MeThYl dolor Ethylene sit'; $_search='/((\w+)?ethyl(\w+)?)/i'; $_replace='b\\1/b'; $_highlightedText=preg_replace($_search,$_replace,$_textToHighlight); This should output: bethyl/b Lorem bEthyl/b ipsum bMeThYl/b dolor bEthylene/b sit Hope it helps, PuYa C.R.Vegelin wrote: - Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 11:29 AM Subject: RE: [PHP] highlighting searchterms as bold text thats odd because the regex passes when I test it with this online tool: http://samuelfullman.com/team/php/tools/regular_expression_tester_p2.php -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:59 PM To: Deniz Dizman (BST UGB); [EMAIL PROTECTED] Subject: Re: [PHP] highlighting searchterms as bold text - Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 10:38 AM Subject: RE: [PHP] highlighting searchterms as bold text try /^ethyl/i what you want is ignore case and pattern begins with -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:31 PM To: [EMAIL PROTECTED] Subject: [PHP] highlighting searchterms as bold text Hi everyone, I want to highlight (bold) searchterms in text. For example, for all words starting with ethyl: a) replace ethyl by bethyl/b b) replace Ethyl by bEthyl/b c) replace ethylene by bethylene/b d) but not methyl by bmethyl/b Now I use: $patterns[0] = /ethyl/; $replacements[0] = bethyl/b; $text = preg_replace($patterns, $replacements, $text); This works for a) and c), but not for b) and d). Any idea how to do this ? TIA, Cor Thanks Deniz, I tried pattern /^ethyl/i but this does not highlight anything. I also tried pattern /ethyl/i and this highlights all, but also methyl ... Any suggestion ? Cor Hi Deniz, I tried the referred regex tool as well, and I get Bad Result for /^ethyl/i and Good Result for /ethyl/i Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Very Large text file parsing
On Thu, 2007-09-20 at 13:55 +0200, Paul Scott wrote: On Thu, 2007-09-20 at 12:50 +0100, Edward Kay wrote: In addition to Martin's good suggestions (and also assuming you're running php-cli via cron), you could use nice to stop it consuming too many resources: This is the current approach that I am taking, was just really wondering if there was some kind of voodoo that would speed things up a bit. Thanks both for your responses, appreciate it! Post some samples of the data you are parsing and a sample of the code you've written to parse them. If you're parsing 750 megs of data then it's quite likely you could squeeze some performance out of the parse routines themselves. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] highlighting searchterms as bold text
On Thu, 2007-09-20 at 13:09 +0100, C.R.Vegelin wrote: - Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 11:29 AM Subject: RE: [PHP] highlighting searchterms as bold text thats odd because the regex passes when I test it with this online tool: http://samuelfullman.com/team/php/tools/regular_expression_tester_p2.php That makes it syntactically correct... but it tells you nothing about logic. -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:59 PM To: Deniz Dizman (BST UGB); [EMAIL PROTECTED] Subject: Re: [PHP] highlighting searchterms as bold text - Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 10:38 AM Subject: RE: [PHP] highlighting searchterms as bold text try /^ethyl/i what you want is ignore case and pattern begins with -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:31 PM To: [EMAIL PROTECTED] Subject: [PHP] highlighting searchterms as bold text Hi everyone, I want to highlight (bold) searchterms in text. For example, for all words starting with ethyl: a) replace ethyl by bethyl/b b) replace Ethyl by bEthyl/b c) replace ethylene by bethylene/b d) but not methyl by bmethyl/b Now I use: $patterns[0] = /ethyl/; $replacements[0] = bethyl/b; $text = preg_replace($patterns, $replacements, $text); This works for a) and c), but not for b) and d). Any idea how to do this ? TIA, Cor Thanks Deniz, I tried pattern /^ethyl/i but this does not highlight anything. I also tried pattern /ethyl/i and this highlights all, but also methyl ... Any suggestion ? Cor Hi Deniz, I tried the referred regex tool as well, and I get Bad Result for /^ethyl/i and Good Result for /ethyl/i That's because the ^ character matches the beginning of a line and so it would only match ethyl when it is the first word. As some others pointed out, you really want to match the word boundary so that you match ethyl when it is the beginning of a word. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] highlighting searchterms as bold text
- Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 12:25 PM Subject: RE: [PHP] highlighting searchterms as bold text you probably have some characters before/after the phrase that prevents the match. This should do it: (i hope) /(\S|\s)*\bethyl\b(\S|\s)*/i -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 3:09 PM To: Deniz Dizman (BST UGB); [EMAIL PROTECTED] Subject: Re: [PHP] highlighting searchterms as bold text - Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 11:29 AM Subject: RE: [PHP] highlighting searchterms as bold text thats odd because the regex passes when I test it with this online tool: http://samuelfullman.com/team/php/tools/regular_expression_tes ter_p2.php -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:59 PM To: Deniz Dizman (BST UGB); [EMAIL PROTECTED] Subject: Re: [PHP] highlighting searchterms as bold text - Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 10:38 AM Subject: RE: [PHP] highlighting searchterms as bold text try /^ethyl/i what you want is ignore case and pattern begins with -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:31 PM To: [EMAIL PROTECTED] Subject: [PHP] highlighting searchterms as bold text Hi everyone, I want to highlight (bold) searchterms in text. For example, for all words starting with ethyl: a) replace ethyl by bethyl/b b) replace Ethyl by bEthyl/b c) replace ethylene by bethylene/b d) but not methyl by bmethyl/b Now I use: $patterns[0] = /ethyl/; $replacements[0] = bethyl/b; $text = preg_replace($patterns, $replacements, $text); This works for a) and c), but not for b) and d). Any idea how to do this ? TIA, Cor Thanks Deniz, I tried pattern /^ethyl/i but this does not highlight anything. I also tried pattern /ethyl/i and this highlights all, but also methyl ... Any suggestion ? Cor Hi Deniz, I tried the referred regex tool as well, and I get Bad Result for /^ethyl/i and Good Result for /ethyl/i Cor Hi Deniz, Edward, Mike, Thanks for your suggestions. Deniz, pattern /(\S|\s)*\bethyl\b(\S|\s)*/i makes from any line containing ethyl, such as Undenatured ethyl alcohol lines containing only: ethyl Edward, pattern /(\s|)ethyl(\s|)/i makes from: Undenatured ethyl alcohol Undenaturedethylalcohol (stripping spaces). I will take a look at http://suda.co.uk/projects/SEHL/. Mike, the \W character makes from Undenatured ethyl alcohol Undenaturedethylalcohol (stripping spaces). The \b character makes: Undenatured ethyl alcohol (okay) the word methyl is unchanged (okay) but ethylene keeps also unchanged ... Thanks anyway ! Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Very Large text file parsing
On Thu, 2007-09-20 at 08:03 -0400, Robert Cummings wrote: Post some samples of the data you are parsing and a sample of the code you've written to parse them. If you're parsing 750 megs of data then it's quite likely you could squeeze some performance out of the parse routines themselves. Today's dataset is in a CSV (tab separated) , so I am using fgetcsv, it looks like this (geo data): 936374 Roodepoort Roodepoort Roodeport-Maraisburg-26.167 27.867 P PPL ZA ZA 06 0 1759Africa/Johannesburg 2004-05-11 Code: [SNIP] $row = 1; $handle = fopen($csvfile, r); while (($data = fgetcsv($handle, 1000, \t)) !== FALSE) { $num = count($data); $row++; $insarr = array('userid' = $userid, 'geonameid' = $data[0], 'name' = $data[1], 'asciiname' = $data[2], 'alternatenames' = $data[3], 'latitude' = $data[4], 'longitude' = $data[5], 'featureclass' = $data[6], 'featurecode' = $data[7], 'countrycode' = $data[8], 'cc2' = $data[9], 'admin1code' = $data[10], 'admin2code' = $data[11], 'population' = $data[12], 'elevation' = $data[13], 'gtopo30' = $data[14], 'timezoneid' = $data[15], 'moddate' = $data[16] ); $this-objDbGeo-insertRecord($insarr); //$arr[] = $data; } fclose($handle); --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] highlighting searchterms as bold text
- Original Message - From: Puiu Hrenciuc [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Thursday, September 20, 2007 12:56 PM Subject: Re: [PHP] highlighting searchterms as bold text Sorry, I didn't read d) right (NOT Methyl), here is teh new regex : /(\b#SearchTermHere#(\w+)?)/i The code sample is the same, replace regex, of course . Output should be : bethyl/b Lorem bEthyl/b ipsum MeThYl dolor bEthylene/b sit Cheers Puiu Hrenciuc wrote: Hi, Here's what you need: RegEx: /((\w+)?#SearchTermHere#(\w+)?)/i Of course, replace your #SearchTermHere# with what you need, i.e. /((\w+)?ethyl(\w+)?)/i Code sample: $_textToHighlight='ethyl Lorem Ethyl ipsum MeThYl dolor Ethylene sit'; $_search='/((\w+)?ethyl(\w+)?)/i'; $_replace='b\\1/b'; $_highlightedText=preg_replace($_search,$_replace,$_textToHighlight); This should output: bethyl/b Lorem bEthyl/b ipsum bMeThYl/b dolor bEthylene/b sit Hope it helps, PuYa C.R.Vegelin wrote: - Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 11:29 AM Subject: RE: [PHP] highlighting searchterms as bold text thats odd because the regex passes when I test it with this online tool: http://samuelfullman.com/team/php/tools/regular_expression_tester_p2.php -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:59 PM To: Deniz Dizman (BST UGB); [EMAIL PROTECTED] Subject: Re: [PHP] highlighting searchterms as bold text - Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 10:38 AM Subject: RE: [PHP] highlighting searchterms as bold text try /^ethyl/i what you want is ignore case and pattern begins with -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:31 PM To: [EMAIL PROTECTED] Subject: [PHP] highlighting searchterms as bold text Hi everyone, I want to highlight (bold) searchterms in text. For example, for all words starting with ethyl: a) replace ethyl by bethyl/b b) replace Ethyl by bEthyl/b c) replace ethylene by bethylene/b d) but not methyl by bmethyl/b Now I use: $patterns[0] = /ethyl/; $replacements[0] = bethyl/b; $text = preg_replace($patterns, $replacements, $text); This works for a) and c), but not for b) and d). Any idea how to do this ? TIA, Cor Thanks Deniz, I tried pattern /^ethyl/i but this does not highlight anything. I also tried pattern /ethyl/i and this highlights all, but also methyl ... Any suggestion ? Cor Hi Deniz, I tried the referred regex tool as well, and I get Bad Result for /^ethyl/i and Good Result for /ethyl/i Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks Puiu, I tested your regex with the code below. However, it didn't work. Maybe I'm missing something ... To test it, change the $pattern setting. ?php $term = ethyl; $text = Ethylene, ethyl and methyl are different things.; $pattern = /(\b# . $term . #(\w+)?)/i; $replacement = b . $term . /b; // or: $replacement = b\\1/b; echo before: . $text, br /; $text = preg_replace($pattern, $replacement, $text); echo after: . $text, br /; echo wanted:br /bEthyl/bene, bethyl/b and methyl are different things., br /; echo or:br /bethyl/bene, bethyl/b and methyl are different things., br /; ? Regards, Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Very Large text file parsing
Robert Cummings wrote: On Thu, 2007-09-20 at 13:55 +0200, Paul Scott wrote: On Thu, 2007-09-20 at 12:50 +0100, Edward Kay wrote: In addition to Martin's good suggestions (and also assuming you're running php-cli via cron), you could use nice to stop it consuming too many resources: This is the current approach that I am taking, was just really wondering if there was some kind of voodoo that would speed things up a bit. Thanks both for your responses, appreciate it! Post some samples of the data you are parsing and a sample of the code you've written to parse them. If you're parsing 750 megs of data then it's quite likely you could squeeze some performance out of the parse routines themselves. Adding to Robert's comment, try not to copy variables, but to reference them, so you will use less resources. Also free DB results after query. -- 21:50:04 up 2 days, 9:07, 0 users, load average: 0.92, 0.37, 0.18 - Lic. Martín Marqués | SELECT 'mmarques' || Centro de Telemática| '@' || 'unl.edu.ar'; Universidad Nacional| DBA, Programador, del Litoral | Administrador - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] scaling images
I have images of varying sizes. I want them to be scaled prior to upload to a set size of 300 x 200 px $imageinfo = getimagesize($_FILES['userfile']['tmp_name']); $ix=$imageinfo[0]; $iy=$imageinfo[1]; //upload the images script I -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Very Large text file parsing
Paul Scott wrote: On Thu, 2007-09-20 at 08:03 -0400, Robert Cummings wrote: Post some samples of the data you are parsing and a sample of the code you've written to parse them. If you're parsing 750 megs of data then it's quite likely you could squeeze some performance out of the parse routines themselves. Today's dataset is in a CSV (tab separated) , so I am using fgetcsv, it looks like this (geo data): 936374 Roodepoort Roodepoort Roodeport-Maraisburg-26.167 27.867 P PPL ZA ZA 06 0 1759Africa/Johannesburg 2004-05-11 Code: [SNIP] $row = 1; $handle = fopen($csvfile, r); while (($data = fgetcsv($handle, 1000, \t)) !== FALSE) { $num = count($data); $row++; What's $num and $row for? $insarr = array('userid' = $userid, 'geonameid' = $data[0], 'name' = $data[1], 'asciiname' = $data[2], 'alternatenames' = $data[3], 'latitude' = $data[4], 'longitude' = $data[5], 'featureclass' = $data[6], 'featurecode' = $data[7], 'countrycode' = $data[8], 'cc2' = $data[9], 'admin1code' = $data[10], 'admin2code' = $data[11], 'population' = $data[12], 'elevation' = $data[13], 'gtopo30' = $data[14], 'timezoneid' = $data[15], 'moddate' = $data[16] ); $this-objDbGeo-insertRecord($insarr); Those objDbGeo-insertRecord() do some sort of control over the data that is passed in the array? If not, you should just use the COPY command of PostgreSQL (you are using PostgreSQL if I remember correctly) or simply do a bash script using psql and the \copy command. -- 21:50:04 up 2 days, 9:07, 0 users, load average: 0.92, 0.37, 0.18 - Lic. Martín Marqués | SELECT 'mmarques' || Centro de Telemática| '@' || 'unl.edu.ar'; Universidad Nacional| DBA, Programador, del Litoral | Administrador - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Very Large text file parsing
Paul Scott wrote: Code: [SNIP] $row = 1; $handle = fopen($csvfile, r); while (($data = fgetcsv($handle, 1000, \t)) !== FALSE) { $num = count($data); $row++; $insarr = array('userid' = $userid, 'geonameid' = $data[0], [snip] $this-objDbGeo-insertRecord($insarr); //$arr[] = $data; } fclose($handle); For that sort of thing, I'd forget about PHP and just use multi-threaded C. Especially if you've got an SMP machine. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Very Large text file parsing
On Thu, 2007-09-20 at 14:25 +0200, Paul Scott wrote: On Thu, 2007-09-20 at 08:03 -0400, Robert Cummings wrote: Post some samples of the data you are parsing and a sample of the code you've written to parse them. If you're parsing 750 megs of data then it's quite likely you could squeeze some performance out of the parse routines themselves. Today's dataset is in a CSV (tab separated) , so I am using fgetcsv, it looks like this (geo data): 936374Roodepoort Roodepoort Roodeport-Maraisburg -26.167 27.867 P PPL ZA ZA 06 0 1759Africa/Johannesburg 2004-05-11 Code: [SNIP] $row = 1; $handle = fopen($csvfile, r); while (($data = fgetcsv($handle, 1000, \t)) !== FALSE) { $num = count($data); $row++; $insarr = array('userid' = $userid, 'geonameid' = $data[0], 'name' = $data[1], 'asciiname' = $data[2], 'alternatenames' = $data[3], 'latitude' = $data[4], 'longitude' = $data[5], 'featureclass' = $data[6], 'featurecode' = $data[7], 'countrycode' = $data[8], 'cc2' = $data[9], 'admin1code' = $data[10], 'admin2code' = $data[11], 'population' = $data[12], 'elevation' = $data[13], 'gtopo30' = $data[14], 'timezoneid' = $data[15], 'moddate' = $data[16] ); $this-objDbGeo-insertRecord($insarr); //$arr[] = $data; } fclose($handle); --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm You can probably speed this up A LOT if you can batch multiple queries. For instance, in MySQL you can do: INSERT INTO some_table ( x, y, z ) VALUES ( 1, 2, 3 ), ( 2, 3, 4 ), ( 5, 6, 7 ), ... If you do these in batches of 1000 you should be able to make a big time savings. Since you're useing fgetcsv() it's doubtful you can improve the file access/parse. Your bottleneck is most likely the database inserts. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] highlighting searchterms as bold text
C.R.Vegelin wrote: - Original Message - From: Puiu Hrenciuc [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Thursday, September 20, 2007 12:56 PM Subject: Re: [PHP] highlighting searchterms as bold text Sorry, I didn't read d) right (NOT Methyl), here is teh new regex : /(\b#SearchTermHere#(\w+)?)/i The code sample is the same, replace regex, of course . Output should be : bethyl/b Lorem bEthyl/b ipsum MeThYl dolor bEthylene/b sit Cheers Puiu Hrenciuc wrote: Hi, Here's what you need: RegEx: /((\w+)?#SearchTermHere#(\w+)?)/i Of course, replace your #SearchTermHere# with what you need, i.e. /((\w+)?ethyl(\w+)?)/i Code sample: $_textToHighlight='ethyl Lorem Ethyl ipsum MeThYl dolor Ethylene sit'; $_search='/((\w+)?ethyl(\w+)?)/i'; $_replace='b\\1/b'; $_highlightedText=preg_replace($_search,$_replace,$_textToHighlight); This should output: bethyl/b Lorem bEthyl/b ipsum bMeThYl/b dolor bEthylene/b sit Hope it helps, PuYa C.R.Vegelin wrote: - Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 11:29 AM Subject: RE: [PHP] highlighting searchterms as bold text thats odd because the regex passes when I test it with this online tool: http://samuelfullman.com/team/php/tools/regular_expression_tester_p2.php -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:59 PM To: Deniz Dizman (BST UGB); [EMAIL PROTECTED] Subject: Re: [PHP] highlighting searchterms as bold text - Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 10:38 AM Subject: RE: [PHP] highlighting searchterms as bold text try /^ethyl/i what you want is ignore case and pattern begins with -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:31 PM To: [EMAIL PROTECTED] Subject: [PHP] highlighting searchterms as bold text Hi everyone, I want to highlight (bold) searchterms in text. For example, for all words starting with ethyl: a) replace ethyl by bethyl/b b) replace Ethyl by bEthyl/b c) replace ethylene by bethylene/b d) but not methyl by bmethyl/b Now I use: $patterns[0] = /ethyl/; $replacements[0] = bethyl/b; $text = preg_replace($patterns, $replacements, $text); This works for a) and c), but not for b) and d). Any idea how to do this ? TIA, Cor Thanks Deniz, I tried pattern /^ethyl/i but this does not highlight anything. I also tried pattern /ethyl/i and this highlights all, but also methyl ... Any suggestion ? Cor Hi Deniz, I tried the referred regex tool as well, and I get Bad Result for /^ethyl/i and Good Result for /ethyl/i Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks Puiu, I tested your regex with the code below. However, it didn't work. Maybe I'm missing something ... To test it, change the $pattern setting. ?php $term = ethyl; $text = Ethylene, ethyl and methyl are different things.; $pattern = /(\b# . $term . #(\w+)?)/i; $replacement = b . $term . /b; // or: $replacement = b\\1/b; echo before: . $text, br /; $text = preg_replace($pattern, $replacement, $text); echo after: . $text, br /; echo wanted:br /bEthyl/bene, bethyl/b and methyl are different things., br /; echo or:br /bethyl/bene, bethyl/b and methyl are different things., br /; ? Regards, Cor you forgot to also remove '#' and enclose in single quotes, otherwise the '\' character has another meaning :) Also, the replacement should be exactly as I gave it, with \\1, it means 'put here the string that matched first brackets pair ' So these two lines should look like: $pattern = '/(\b' . $term . '(\w+)?)/i'; $replacement = 'b\\1/b'; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Very Large text file parsing
Paul Scott wrote: On Thu, 2007-09-20 at 12:50 +0100, Edward Kay wrote: In addition to Martin's good suggestions (and also assuming you're running php-cli via cron), you could use nice to stop it consuming too many resources: This is the current approach that I am taking, was just really wondering if there was some kind of voodoo that would speed things up a bit. Given that you've got significant IO on both sides (file in, database out), multi-threading it could work wonders. Not sure how you'd go about that in PHP though. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How can I make clean URL site with PHP?
Hi. I like clean URL site like http://del.icio.us/someone/tag (del.icio.us is powered by PHP, right?) But I have no idea how can I do it with PHP. Is this a just apache's rewrite magic? or another different technique? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] scaling images
That's nice. On 9/20/07, Hulf [EMAIL PROTECTED] wrote: I have images of varying sizes. I want them to be scaled prior to upload to a set size of 300 x 200 px $imageinfo = getimagesize($_FILES['userfile']['tmp_name']); $ix=$imageinfo[0]; $iy=$imageinfo[1]; //upload the images script I -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 Give a man a fish, he'll eat for a day. Then you'll find out he was allergic and is hospitalized. See? No good deed goes unpunished -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How can I make clean URL site with PHP?
On Thu, 2007-09-20 at 23:12 +0900, js wrote: Hi. I like clean URL site like http://del.icio.us/someone/tag (del.icio.us is powered by PHP, right?) But I have no idea how can I do it with PHP. Is this a just apache's rewrite magic? or another different technique? Apache rewrite magic can do some, but it's messy and painful. A more likely example is to use a PHP enabled 404 handler page to check the URL requested and lookup/calculate the appropriate real page to be presented. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] scaling images
Hulf wrote: I have images of varying sizes. I want them to be scaled prior to upload to a set size of 300 x 200 px $imageinfo = getimagesize($_FILES['userfile']['tmp_name']); $ix=$imageinfo[0]; $iy=$imageinfo[1]; //upload the images script I So, let me get this straight, you want to resize the image to 300x200 BEFORE you upload to your server? And since you are asking this on a PHP mailing list I am going to assume that you want to do this with PHP, correct? ... -- 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] Re: scaling images
Sorry my message was cut off. Yes I want to scale to 300 x 200px before I upload the image to my folder. Here is my code so far. thanks, H. $imageinfo = getimagesize($_FILES['userfile']['tmp_name']); echo $x=$imageinfo[0]; echo $y=$imageinfo[1]; $newwidth = 300; $newheight = 200; // Load $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($_FILES['userfile']['tmp_name']); // Resize imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // Output $myimage = imagejpeg($thumb); $target_path = ../property_images/$property_id/.basename( $_FILES['userfile']['name']); $img_url= $property_id./.basename( $_FILES['userfile']['name']); if(move_uploaded_file($myimage, $target_path)) { /* echo The file . basename( $_FILES['userfile']['name']). has been uploaded;*/ } else{ echo There was an error uploading the file, please try again!; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: scaling images
Hulf wrote: Sorry my message was cut off. Yes I want to scale to 300 x 200px before I upload the image to my folder. Here is my code so far. thanks, H. $imageinfo = getimagesize($_FILES['userfile']['tmp_name']); echo $x=$imageinfo[0]; echo $y=$imageinfo[1]; $newwidth = 300; $newheight = 200; // Load $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($_FILES['userfile']['tmp_name']); // Resize imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // Output $myimage = imagejpeg($thumb); $target_path = ../property_images/$property_id/.basename( $_FILES['userfile']['name']); $img_url= $property_id./.basename( $_FILES['userfile']['name']); if(move_uploaded_file($myimage, $target_path)) { /* echo The file . basename( $_FILES['userfile']['name']). has been uploaded;*/ } else{ echo There was an error uploading the file, please try again!; } After resizing the image you will have the newly created JPEG data (binary) in the $myimage variable, not a file(name). So you actually have to do something like: file_put_contents($target_path,$myimage); This will put the content in the $myimage variable ( the resized JPEG data) into the target path. Note that you should also check if the uploaded file is a supported image, so do something like : if($source = @imagecreatefromjpeg($_FILES['userfile']['tmp_name'])) { // file is a supported image type, resize it and save it } else { // unsupported image file or not an image file at all, // display some error here } Note: file_put_contents is a PHP5 only function, use fopen,fwrite,fclose for PHP4. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] scaling and uploading the pt 2
This is the full code so far. The files are saving but they are not resizing. Can anyone help? I need to get this $myimage = imagejpeg($thumb); into $target_path directory. H. -- if(isset($_POST['_upload']) $_FILES['userfile']['size'] 0) { $imageinfo = getimagesize($_FILES['userfile']['tmp_name']); echo $width=$imageinfo[0]; echo $height=$imageinfo[1]; $newwidth = 300; $newheight = 200; // Load $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($_FILES['userfile']['tmp_name']); // Resize $myimage = imagecopyresized($thumb, $source, 0, 0, 0, 0, 300, 200, $width, $height); // Output $myimage = imagejpeg($thumb); $target_path = ../property_images/$property_id/.basename( $_FILES['userfile']['name']); $img_url= $property_id./.basename( $_FILES['userfile']['name']); if(move_uploaded_file($_FILES['userfile']['tmp_name'], $target_path)) { /* echo The file . basename( $_FILES['userfile']['name']). has been uploaded;*/ } else{ echo There was an error uploading the file, please try again!; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] scaling and uploading the pt 2
Hulf wrote: This is the full code so far. The files are saving but they are not resizing. Can anyone help? I need to get this $myimage = imagejpeg($thumb); into $target_path directory. H. -- if(isset($_POST['_upload']) $_FILES['userfile']['size'] 0) { $imageinfo = getimagesize($_FILES['userfile']['tmp_name']); echo $width=$imageinfo[0]; echo $height=$imageinfo[1]; $newwidth = 300; $newheight = 200; // Load $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($_FILES['userfile']['tmp_name']); // Resize $myimage = imagecopyresized($thumb, $source, 0, 0, 0, 0, 300, 200, $width, $height); Don't assign to $myimage here. imagecopyresized() returns a boolean. // Output $myimage = imagejpeg($thumb); Same here. $target_path = ../property_images/$property_id/.basename( $_FILES['userfile']['name']); I can't see how you're able to save the file using this path. move_uploaded_file() requires a path from server root (not DOCUMENT_ROOT). $img_url= $property_id./.basename( $_FILES['userfile']['name']); if(move_uploaded_file($_FILES['userfile']['tmp_name'], $target_path)) { /* echo The file . basename( $_FILES['userfile']['name']). has been uploaded;*/ } else{ echo There was an error uploading the file, please try again!; } Here, you're saving the originally-uploaded file, not the re-sized version you created. You want to pass the path to imagejpeg() to have it save the new image at the destination (the 3rd param is the quality setting). Do: // note, also, that you had the dest. width height hard-coded. imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); $target_path = // resolve this if (imagejpeg($thumb, $target_path)) { echo 'Huzzah!'; } else { echo 'back to php-general ...'; } brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] newbie trying to find segfault reasons
Hey all, I'm kinda new at PHP (but not entirely new). I'm having a heck of a time with PHP causing my apache processes to segfault. I've found a few cases where it's something simple, like referring to an object property that does not exist, but it's painstaking work. I'm reduced to commenting out blocks of code, and then trying to comment and uncomment stuff until I can narrow it down to the line where I'm having the problem. Everybody can't be having this trouble. How can I configure PHP so that it will just tell me when I've made a typo, rather than segfaulting? My environment is Apache/2.0.55, Ubuntu Edgy, PHP/5.1.6 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] newbie trying to find segfault reasons
[snip] I'm kinda new at PHP (but not entirely new). I'm having a heck of a time with PHP causing my apache processes to segfault. I've found a few cases where it's something simple, like referring to an object property that does not exist, but it's painstaking work. I'm reduced to commenting out blocks of code, and then trying to comment and uncomment stuff until I can narrow it down to the line where I'm having the problem. Everybody can't be having this trouble. How can I configure PHP so that it will just tell me when I've made a typo, rather than segfaulting? My environment is Apache/2.0.55, Ubuntu Edgy, PHP/5.1.6 [/snip] Typically when this occurs it means that one of your PHP extensions did not compile or build properly. Once you have isolated the code chunk it may clue you into a bad extension. I know that it is long and tedious, but you may be able to test this by commenting an extension, restarting Apache, running the problem code and seeing if a segfault occurs. Once you have id'd the extension you can rebuild or replace. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] disappearing array?
I am not sure what the heck is going with this but here is my problem. I am trying to validate the contents of an array, then determine if the errors are with the array or another form submitted variable. The problem is after the code validates the array and other form variables using an if statement, I then try to determine if the error is in the array but for some reason the contents of the array disappear. Weird. Any help is appreciated. Here is the code: function ValArray( $array ) { echo pre; print_r( $array ); echo /pre; $val = new ValidateStrings(); $data = 0; if( count( $array ) !== 0 ) { for( $x = 0; $x count( $array ); $x++ ) { echo DATA: . $array[$x][0] . br; if( $val-ValidateInteger( $array[$x][0] ) === -1 ) {// || ( $val-ValidateParagraph( $array[$x][1] ) === -1 ) || ( $val-ValidateMoney( $array[$x][2] ) === -1 ) || ( $val-ValidateAlphaChar( $array[$x][3] ) === -1 ) || ( $val-ValidateAlphaChar( $array[$x][4] ) === -1 ) ) { $data = -1; } } } echo RESULTS: . $data . BR; return $data; } if( ValArray( $_POST['add_order_items'] ) === -1 ) { $message = error; echo pre; print_r( $_POST['add_order_items'] ); echo /pre; // here is where it is empty or something else if( $fix-ValArray( $_POST['add_order_items'] === -1 ) ) { $errors['add_order_array'] = $erlink; } echo pre; print_r( $_POST['add_order_items'] ); echo /pre; And the output: Array ( [1] = Array ( [0] = ^%*( [1] = ^*() [2] = ^*() [3] = ^*()_ [4] = ^%*() ) [0] = Array ( [0] = afadsf [1] = adsfasfasdf [2] = asdfasdfasdf [3] = asdfasdfasdf [4] = asdfasdfasdf ) ) DATA: afadsf DATA: ^%*( RESULTS: -1 DATA: RESULTS: -1 Array ( [1] = Array ( [0] = ^%*( [1] = ^*() [2] = ^*() [3] = ^*()_ [4] = ^%*() ) [0] = Array ( [0] = afadsf [1] = adsfasfasdf [2] = asdfasdfasdf [3] = asdfasdfasdf [4] = asdfasdfasdf ) ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Working with XML: DomDocument or SimpleXML?
Hi, Just wondering what people's general opinion is on working with XML in PHP? I like working with SimpleXML but DomDocument seems more useful in some cases (e.g. working with XSLT transforms etc.). So what do you thing? Or do would you simply create a few utility classes to handle conversions? I have written a utility class myself that represents XML internall in either DomDocument, SimpleXML or String format and allows you to access it any of the three which means you can just pass XML object around and use it accordingly depending on the circumstances. I'd be interested to hear other peoples thoughts on the matter tho'. Cheers Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MAX_FILE_SIZE not working with file uploads
The punchline question is: What am I missing? Now for the details. I have a form through which a user uploads image files. In the event the chosen file exceeds the MAX_FILE_SIZE (which I have included as a hidden form field immediately after the form tag), I want to abort the upload process and display an appropriate error message to the user, including the size of the file s/he attempted to upload. But that doesn't seem to be working. Instead, the computer chugs along and then properly refuses to perform the upload, but not immediately. And here is the dump of the $_FILES array (which, notably, reports zero as the size): [code] Array ( [userfile] = Array ( [name] = beach_iStock_00112348_L2.jpg [type] = [tmp_name] = [error] = 2 [size] = 0 ) ) [/code] The file (about 1.2MB) DOES upload when I increase the MAX_FILE_SIZE value to 200. This, from PHP.net: [quote] The MAX_FILE_SIZE hidden field (measured in bytes) must precede the file input field, and its value is the maximum filesize accepted by PHP. Fooling this setting on the browser side is quite easy, so never rely on files with a greater size being blocked by this feature. The PHP settings for maximum-size, however, cannot be fooled. This form element should always be used as it saves users the trouble of waiting for a big file being transferred only to find that it was too big and the transfer failed. [/quote] Here is the form code: [code] form action=__URL__?action=sent method=post enctype=multipart/form-data name=upload id=upload input type=hidden name=MAX_FILE_SIZE value=1024000 Filename on your PC: input name=userfile type=file size=45 Please click ONCE and be patient: input name=Submit type=submit id=Submit value=Upload File /form [/code] Pertinent php.ini settings: version = 4.3.10 file_uploads = on upload_max_filesize = 2M post_max_size = 8M Any guidance would be appreciated. Jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie trying to find segfault reasons
just don't use php 5.1.6 Chris Curvey-2 wrote: Hey all, I'm kinda new at PHP (but not entirely new). I'm having a heck of a time with PHP causing my apache processes to segfault. I've found a few cases where it's something simple, like referring to an object property that does not exist, but it's painstaking work. I'm reduced to commenting out blocks of code, and then trying to comment and uncomment stuff until I can narrow it down to the line where I'm having the problem. Everybody can't be having this trouble. How can I configure PHP so that it will just tell me when I've made a typo, rather than segfaulting? My environment is Apache/2.0.55, Ubuntu Edgy, PHP/5.1.6 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- View this message in context: http://www.nabble.com/newbie-trying-to-find-segfault-reasons-tf4489224.html#a12803960 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] MAX_FILE_SIZE not working with file uploads
In the _ More photos; more messages; more whatever – Get MORE with Windows Live™ Hotmail®. NOW with 5GB storage. http://imagine-windowslive.com/hotmail/?locale=en-usocid=TXT_TAGHM_migration_HM_mini_5G_0907 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Finding next recored in a array
At 4:14 PM -0400 9/19/07, brian wrote: tedd wrote: At 11:52 AM -0400 9/17/07, brian wrote: tedd wrote: Richard Kurth wrote: $Campaign_array| = array('0','1','3','5','8','15','25');| I know that I can find the next recored in a array using next. What I do not understand is if I know the last number was say 5 how do I tell the script that that is the current number so I can select the next record What the next record? Try: $array = array('0','1','3','5','8','15','25'); $val = 5; echo($array[array_search($val, $array)+1]); Cheers, tedd Not quite: $array = array('0','1','3','5','8','15','25'); $val = 25; echo($array[array_search($val, $array)+1]); Notice: Undefined offset: 7 ... brian Duh? You program for that -- you want me to write the entire code? ~sigh~ Grasshopper, the point i was trying to make is that your example displays what *not* to do with array_search(). Though a wonderful teaching aid in itself, it falls somewhat short of being a reasonable solution for the OP. brian ~sigh~ Sorry to disappoint you master. But I was using array_search() to search an array -- it seemed like a reasonable thing to do. So why do you say it's an example of what *not* to do with array_search()? Please be specific. 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
[PHP] safe_mode exec()
Hi gang: Would someone be so kind as to explain to me how one can use exec() with safe_mode on? TIA, 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] Working with XML: DomDocument or SimpleXML?
On Thu, 2007-09-20 at 20:34 +0100, Colin Guthrie wrote: Hi, Just wondering what people's general opinion is on working with XML in PHP? I like working with SimpleXML but DomDocument seems more useful in some cases (e.g. working with XSLT transforms etc.). So what do you thing? Or do would you simply create a few utility classes to handle conversions? I have written a utility class myself that represents XML internall in either DomDocument, SimpleXML or String format and allows you to access it any of the three which means you can just pass XML object around and use it accordingly depending on the circumstances. I'd be interested to hear other peoples thoughts on the matter tho'. I still use PHP4 so I wrote my own XML handling class that wraps the xml_xxx() series of functions. Haven't had a problem with it. Makes working with XML very easy since it uses a path string syntax to focus/access nodes and attributes: http://www.interjinn.com/jinnDoc/interJinn.class.JinnSimpleXml.phtml Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] safe_mode exec()
On Thu, 2007-09-20 at 16:14 -0400, tedd wrote: Hi gang: Would someone be so kind as to explain to me how one can use exec() with safe_mode on? http://ca.php.net/manual/en/features.safe-mode.php#ini.safe-mode-exec-dir Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] disappearing array?
Wow this formatted badly. (new hotmail on Safari -- MS made FF not even render well) Anyway, are you sure you are reaching the code you want to reach? Perhaps !== is overkill and maybe even wrong when you should use ==. Same with the other === usage? Try some echo HERE1\n; echo HERE2\n; to see if you are getting to the line you expect. Like after that count(~) !== . _ Gear up for Halo® 3 with free downloads and an exclusive offer. It’s our way of saying thanks for using Windows Live™. http://gethalo3gear.com?ocid=SeptemberWLHalo3_WLHMTxt_2 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] MAX_FILE_SIZE not working with file uploads
In the To: php-general@lists.php.net Date: Thu, 20 Sep 2007 14:45:36 -0500 From: [EMAIL PROTECTED] Subject: [PHP] MAX_FILE_SIZE not working with file uploads The punchline question is: What am I missing? Now for the details. I have a form through which a user uploads image files. In the event the chosen file exceeds the MAX_FILE_SIZE (which I have included as a hidden form field immediately after the form tag), I want to abort the upload process and display an appropriate error message to the user, including the size of the file s/he attempted to upload. But that doesn't seem to be working. Instead, the computer chugs along and then properly refuses to perform the upload, but not immediately. And here is the dump of the $_FILES array (which, notably, reports zero as the size): [code] Array ( [userfile] = Array ( [name] = beach_iStock_00112348_L2.jpg [type] = [tmp_name] = [error] = 2 [size] = 0 ) ) [/code] The file (about 1.2MB) DOES upload when I increase the MAX_FILE_SIZE value to 200. This, from PHP.net: [quote] The MAX_FILE_SIZE hidden field (measured in bytes) must precede the file input field, and its value is the maximum filesize accepted by PHP. Fooling this setting on the browser side is quite easy, so never rely on files with a greater size being blocked by this feature. The PHP settings for maximum-size, however, cannot be fooled. This form element should always be used as it saves users the trouble of waiting for a big file being transferred only to find that it was too big and the transfer failed. [/quote] Here is the form code: [code] enctype=multipart/form-data name=upload id=upload Filename on your PC: Please click ONCE and be patient: [/code] Pertinent php.ini settings: version = 4.3.10 file_uploads = on upload_max_filesize = 2M post_max_size = 8M Any guidance would be appreciated. Jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Can you find the hidden words? Take a break and play Seekadoo! http://club.live.com/seekadoo.aspx?icid=seek_wlmailtextlink -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Finding next recored in a array
tedd wrote: At 4:14 PM -0400 9/19/07, brian wrote: tedd wrote: Duh? You program for that -- you want me to write the entire code? ~sigh~ Grasshopper, the point i was trying to make is that your example displays what *not* to do with array_search(). Though a wonderful teaching aid in itself, it falls somewhat short of being a reasonable solution for the OP. brian ~sigh~ Sorry to disappoint you master. But I was using array_search() to search an array -- it seemed like a reasonable thing to do. OK, so my joke left a bitter taste; sorry about that. What i'm trying to get across is that this list is here so that we may post our various problems in the hopes that someone else might see the solution we are missing. Sometimes, when we post what we *think* is the correct path to scripting Nirvana, another of us may point out a flaw in our logic. It happens to all of us. The responses to this list should not be taken to be either complete or fully-tested solutions. But, neither should potential bugs be ignored if noticed by any other reader. While your response certainly does *seem* to work just fine, it contains a bug that *will* bite at some point. So why do you say it's an example of what *not* to do with array_search()? Please be specific. Do you really expect me to write the entire code? Perhaps you could just meditate on this a little longer: Not quite: $array = array('0','1','3','5','8','15','25'); $val = 25; echo($array[array_search($val, $array)+1]); Notice: Undefined offset: 7 ... brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Working with XML: DomDocument or SimpleXML?
Robert Cummings wrote: I still use PHP4 so I wrote my own XML handling class that wraps the xml_xxx() series of functions. Haven't had a problem with it. Makes working with XML very easy since it uses a path string syntax to focus/access nodes and attributes: Cheers for that. I know I definitely want to do XSLT stuff and for that I need to use DomDocument (I'm sure there are other ways but this works fine for me so far!). I guess think I asked too open a question, when really I'm looking for fairly specific answers (or rather opinions). I'll phrase it better: one can easily convert a SimpleXML object to a DomDocument[1], but nothing is free (in terms of time taken and memory requirements etc.), so really I guess I want to ask if the trade off of the simplicity of working with SimpleXML is worth it considering the overhead of the conversion process to a DomDocument for subsequent XSLT transforms etc? Col [1] e.g. if ($xml instanceof SimpleXMLElement) { $rv = new DOMDocument('1.0', 'utf-8'); $node = dom_import_simplexml($xml); $node = $rv-importNode($node, true); $rv-appendChild($node); return $rv; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] disappearing array?
On Thu, 20 Sep 2007 12:58:28 -0600, you wrote: I am not sure what the heck is going with this but here is my problem. I am trying to validate the contents of an array, then determine if the errors are with the array or another form submitted variable. The problem is after the code validates the array and other form variables using an if statement, I then try to determine if the error is in the array but for some reason the contents of the array disappear. Weird. Any help is appreciated. Very hard to suggest anything from the snippet presented, as it can't be run without the supporting classes (ValidateStrings and whatever $fix is supposed to be), and it won't parse; the // comment on the end of line 9 borks it, and the if () on line 21 is missing its closing brace. If I assume one run-on if() statement and add the closing brace, I'd say that this looks weird: if( $fix-ValArray( $_POST['add_order_items'] === -1 ) ) { $errors['add_order_array'] = $erlink; } In your snippet ValArray() appears to be a function, rather than a method of $fix. I suggest adding error_reporting(E_ALL); to the top of the script and letting us know what the output is, then try to put together a minimal example that can actually be run (even if you have to fake a ValidateStrings class that always returns -1) and still shows your error. Plus some general suggestions, feel free to ignore... I think you're using || where you mean to use in that run-on if() statement. You're saying IF (NOT Integer OR NOT Paragraph OR NOT Money) which will always evaluate to true. Unless your ValidateStrings class is holding some kind of state data internally, it may be a good candidate for a static class. ValidateStrings::ValidateParagraph() is a bit verbose, how about just Validate::Integer() Validate::Paragraph() etc. In PHP, it's more typical to use true/false for success failure, rather than returning -1 on failure, something like: if (!Validate::Integer($value) !Validate::Paragraph($value)) { /* failure */ } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] MAX_FILE_SIZE not working with file uploads
Max file size is a hint to the browser and not all support it...you can't count on it bastien To: php-general@lists.php.net Date: Thu, 20 Sep 2007 14:45:36 -0500 From: [EMAIL PROTECTED] Subject: [PHP] MAX_FILE_SIZE not working with file uploads The punchline question is: What am I missing? Now for the details. I have a form through which a user uploads image files. In the event the chosen file exceeds the MAX_FILE_SIZE (which I have included as a hidden form field immediately after the form tag), I want to abort the upload process and display an appropriate error message to the user, including the size of the file s/he attempted to upload. But that doesn't seem to be working. Instead, the computer chugs along and then properly refuses to perform the upload, but not immediately. And here is the dump of the $_FILES array (which, notably, reports zero as the size): [code] Array ( [userfile] = Array ( [name] = beach_iStock_00112348_L2.jpg [type] = [tmp_name] = [error] = 2 [size] = 0 ) ) [/code] The file (about 1.2MB) DOES upload when I increase the MAX_FILE_SIZE value to 200. This, from PHP.net: [quote] The MAX_FILE_SIZE hidden field (measured in bytes) must precede the file input field, and its value is the maximum filesize accepted by PHP. Fooling this setting on the browser side is quite easy, so never rely on files with a greater size being blocked by this feature. The PHP settings for maximum-size, however, cannot be fooled. This form element should always be used as it saves users the trouble of waiting for a big file being transferred only to find that it was too big and the transfer failed. [/quote] Here is the form code: [code] form action=__URL__?action=sent method=post enctype=multipart/form-data name=upload id=upload input type=hidden name=MAX_FILE_SIZE value=1024000 Filename on your PC: input name=userfile type=file size=45 Please click ONCE and be patient: input name=Submit type=submit id=Submit value=Upload File /form [/code]Pertinent php.ini settings: version = 4.3.10 file_uploads = on upload_max_filesize = 2M post_max_size = 8M Any guidance would be appreciated. Jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Explore the seven wonders of the world http://search.msn.com/results.aspx?q=7+wonders+worldmkt=en-USform=QBRE
Re: [PHP] Very Large text file parsing
On Thu, 2007-09-20 at 09:54 -0300, Martin Marques wrote: If not, you should just use the COPY command of PostgreSQL (you are using PostgreSQL if I remember correctly) or simply do a bash script using psql and the \copy command. Unfortunately, this has to work on all supported RDBM's - so using postgres or mysql specific functions are not really an option. What I am trying though, is to add a function to do batch inserts as per Rob's suggestion into our database abstraction layer, which may help things a bit. Thanks --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Very Large text file parsing
Paul Scott wrote: On Thu, 2007-09-20 at 09:54 -0300, Martin Marques wrote: If not, you should just use the COPY command of PostgreSQL (you are using PostgreSQL if I remember correctly) or simply do a bash script using psql and the \copy command. Unfortunately, this has to work on all supported RDBM's - so using postgres or mysql specific functions are not really an option. What I am trying though, is to add a function to do batch inserts as per Rob's suggestion into our database abstraction layer, which may help things a bit. Both of these support importing csv files (use \copy as Martin mentioned for postgres). Mysql has this: http://dev.mysql.com/doc/refman/4.1/en/load-data.html If you're supporting more than those two, can't really say whether others support this type of feature :) Try batches: begin; ... 5000 rows commit; and rinse/repeat. I know postgres will be a lot happier with that because otherwise it's doing a transaction per insert. If you take the insert out of the equation (ie it runs through the file, parses it etc) is it fast? That'll tell you at least where the bottleneck is. (Personally I'd use perl over php for processing files that large but that may not be an option). -- 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] MAX_FILE_SIZE not working with file uploads
And here is the dump of the $_FILES array (which, notably, reports zero as the size): snip [error] = 2 And also gives you an error code. http://www.php.net/manual/en/features.file-upload.errors.php -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php