[PHP] Google Pagerank script
Hello All, Does anyone have a link to source code for a pagerank script? I want to provide this to users. Thanks! Joey
Re: [PHP] new lines in textareas?
Is \n included literally because you're using single quotes for the variable? $textdata = 'This is a test\nThis is the second line'; vs... $textarea = "This is a test\nThis is the second line"; I would guess a lot of the pages you find are talking about what to do with the text after submitting through the textarea, not re-displaying with proper breaks when loading a page containing a text area that should have data. -TG - Original Message - From: Mary Anderson <[EMAIL PROTECTED]> To: php-general@lists.php.net Date: Sat, 29 Mar 2008 21:26:24 -0700 Subject: [PHP] new lines in textareas? > Hi all, > I have a php script which produces text which is to be displayed in > a textarea. I have the wrap for the text area set to 'hard'. I need to > have newlines inserted in the text. > "\n" and "" don't work. They just get quoted literally in the > text. I suspect I need to use htmlspecialchars , but don't know what > special character to feed it. > > Apologies if this should go to an HTML forum. I checked several > archives and did not find anything useful. (They tended to tell me to > put in \n or !) > > Thanks > > Mary Anderson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] new lines in textareas?
On Sat, Mar 29, 2008 at 9:26 PM, Mary Anderson <[EMAIL PROTECTED]> wrote: > Hi all, > I have a php script which produces text which is to be displayed in > a textarea. I have the wrap for the text area set to 'hard'. I need to > have newlines inserted in the text. > "\n" and "" don't work. They just get quoted literally in the > text. I suspect I need to use htmlspecialchars , but don't know what > special character to feed it. > > Apologies if this should go to an HTML forum. I checked several > archives and did not find anything useful. (They tended to tell me to > put in \n or !) > > Thanks > > Mary Anderson > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > \n, or just a plain line break, should work. Hello, My favorite color is blue. Signed, Me!'; ?> Should work. -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] new lines in textareas?
Hi all, I have a php script which produces text which is to be displayed in a textarea. I have the wrap for the text area set to 'hard'. I need to have newlines inserted in the text. "\n" and "" don't work. They just get quoted literally in the text. I suspect I need to use htmlspecialchars , but don't know what special character to feed it. Apologies if this should go to an HTML forum. I checked several archives and did not find anything useful. (They tended to tell me to put in \n or !) Thanks Mary Anderson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] extract escaped quoted strings
token_get_all, fantastic! Thanks. - Adam On Mar 29, 2008, at 10:02 PM, Robert Cummings wrote: On Sat, 2008-03-29 at 21:31 -0400, Adam Jacob Muller wrote: Yes, php source code. You will not be able to do this with PCRE. You need something that can track state because double quotes can appear within HTML outside of PHP blocks, within HEREDOC, within double-quoted strings when backslashed, and within single quoted strings. You need to account for each type of PHP open/close semantic: And that's just to determine script context. Then you need to know where a double quote is. Is it starting a string? Is it within HEREDOC? Is it within a single quoted string, etc. Your best bet is probably to use the token_get_all() function: http://ca.php.net/manual/en/function.token-get-all.php Cheers, Rob. On Mar 29, 2008, at 8:54 PM, Robert Cummings wrote: On Sat, 2008-03-29 at 20:41 -0400, Adam Jacob Muller wrote: Assume that you should accept any string that PHP itself would accept, though no processing of the actual escapes is required nor desirable. Sorry, I wasn't clear enough :) By source I meant more along the lines of what the text might look like from which these strings are being pulled... for instance are you looking to pull these strings from PHP source code? or something simpler? 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] extract escaped quoted strings
On Sat, 2008-03-29 at 21:31 -0400, Adam Jacob Muller wrote: > Yes, php source code. You will not be able to do this with PCRE. You need something that can track state because double quotes can appear within HTML outside of PHP blocks, within HEREDOC, within double-quoted strings when backslashed, and within single quoted strings. You need to account for each type of PHP open/close semantic: And that's just to determine script context. Then you need to know where a double quote is. Is it starting a string? Is it within HEREDOC? Is it within a single quoted string, etc. Your best bet is probably to use the token_get_all() function: http://ca.php.net/manual/en/function.token-get-all.php Cheers, Rob. > > > On Mar 29, 2008, at 8:54 PM, Robert Cummings wrote: > > > > > On Sat, 2008-03-29 at 20:41 -0400, Adam Jacob Muller wrote: > >> Assume that you should accept any string that PHP itself would > >> accept, > >> though no processing of the actual escapes is required nor desirable. > > > > Sorry, I wasn't clear enough :) By source I meant more along the lines > > of what the text might look like from which these strings are being > > pulled... for instance are you looking to pull these strings from PHP > > source code? or something simpler? > > > > 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] extract escaped quoted strings
On Mar 29, 2008, at 4:16 PM, Adam Jacob Muller <[EMAIL PROTECTED]> wrote: Hi, Have a potentially interesting question here, wondering if anyone has done this one before and could shed some light for me. I have a bit of PHP code that needs to extract some quoted strings, so, very simply: "hello" perfectly fine and works great but, it should also be able to extract "hel\"lo" bit more complex now Ideally, it would also handle "hel\\"lo" properly it should also handle "hel\\\"lo" Any ideason how to do this? attempts to write a PCRE to do this are so-far unsuccessful, i'm sure I could badger some PHP code into doing it perhaps, but i'd love some elegant PCRE solution that thus- far evades me :( Any ideas are appreciated. -Adam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] extract escaped quoted strings
Yes, php source code. On Mar 29, 2008, at 8:54 PM, Robert Cummings wrote: On Sat, 2008-03-29 at 20:41 -0400, Adam Jacob Muller wrote: Assume that you should accept any string that PHP itself would accept, though no processing of the actual escapes is required nor desirable. Sorry, I wasn't clear enough :) By source I meant more along the lines of what the text might look like from which these strings are being pulled... for instance are you looking to pull these strings from PHP source code? or something simpler? 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] extract escaped quoted strings
On Sat, 2008-03-29 at 20:41 -0400, Adam Jacob Muller wrote: > Assume that you should accept any string that PHP itself would accept, > though no processing of the actual escapes is required nor desirable. Sorry, I wasn't clear enough :) By source I meant more along the lines of what the text might look like from which these strings are being pulled... for instance are you looking to pull these strings from PHP source code? or something simpler? 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] extract escaped quoted strings
Assume that you should accept any string that PHP itself would accept, though no processing of the actual escapes is required nor desirable. On Mar 29, 2008, at 8:34 PM, Robert Cummings wrote: On Sat, 2008-03-29 at 19:16 -0400, Adam Jacob Muller wrote: Hi, Have a potentially interesting question here, wondering if anyone has done this one before and could shed some light for me. I have a bit of PHP code that needs to extract some quoted strings, so, very simply: "hello" perfectly fine and works great but, it should also be able to extract "hel\"lo" bit more complex now Ideally, it would also handle "hel\\"lo" properly it should also handle "hel\\\"lo" Any ideason how to do this? attempts to write a PCRE to do this are so- far unsuccessful, i'm sure I could badger some PHP code into doing it perhaps, but i'd love some elegant PCRE solution that thus-far evades me :( Any ideas are appreciated. Extract quoted strings from what? The source makes a huge difference on the complexity required to extract the strings. 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] extract escaped quoted strings
On Sat, 2008-03-29 at 19:16 -0400, Adam Jacob Muller wrote: > Hi, > Have a potentially interesting question here, wondering if anyone has > done this one before and could shed some light for me. > I have a bit of PHP code that needs to extract some quoted strings, > so, very simply: > "hello" > perfectly fine and works great > but, it should also be able to extract > "hel\"lo" > bit more complex now > > Ideally, it would also handle > "hel\\"lo" > properly > > it should also handle > "hel\\\"lo" > > > Any ideason how to do this? attempts to write a PCRE to do this are so- > far unsuccessful, i'm sure I could badger some PHP code into doing it > perhaps, but i'd love some elegant PCRE solution that thus-far evades > me :( > > > Any ideas are appreciated. Extract quoted strings from what? The source makes a huge difference on the complexity required to extract the strings. 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
[PHP] extract escaped quoted strings
Hi, Have a potentially interesting question here, wondering if anyone has done this one before and could shed some light for me. I have a bit of PHP code that needs to extract some quoted strings, so, very simply: "hello" perfectly fine and works great but, it should also be able to extract "hel\"lo" bit more complex now Ideally, it would also handle "hel\\"lo" properly it should also handle "hel\\\"lo" Any ideason how to do this? attempts to write a PCRE to do this are so- far unsuccessful, i'm sure I could badger some PHP code into doing it perhaps, but i'd love some elegant PCRE solution that thus-far evades me :( Any ideas are appreciated. -Adam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: character encoding
Hello, on 03/29/2008 12:43 PM Bill said the following: >> You can build mailto: links with a default subject and text, but I am >> not sure you can force Outlook to use specific HTML. It's wiser to not >> rely on mailto: . > > Hotmail will accept mail delivery from PHP ? Sure. There is nothing specific of PHP that prevents Hotmail from accepting messages sent by PHP scripts. -- Regards, Manuel Lemos PHP professionals looking for PHP jobs http://www.phpclasses.org/professionals/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: optimilize web page loading
On Sat, 2008-03-29 at 10:16 +0100, Zoltán Németh wrote: > > > > One last thing though... > > even if this were escaped and even if there were fifty variables > > embedded, a good bytecode optimizer (not quite the same as a bytecode > > cacher) would optimize the bytecode for caching so that the string is > > broken up according to what needs to be interpolated and what does not. > > could you tell me more about this bytecode optimizer stuff? how does it > work, how much better/faster is it then APC/EAccelerator/etc? It really depends on what an optimizer optimizes. TurckMMCache had.has an optimizer. Zend offers an optimizer too. Optimizer can work in a number of ways. They may be an explicit part of the bytecode cache mechanism or possibly plugged as one element in a chain of bytecode processors... parser -> optmizer -> cacher. I'm not exactly sure how it works for PHP. The main difference between a cacher and an optimizer though is that generally speaking a caher only deals with caching the bytecode. No processing occurs on the produced bytecode. On the other hand an optimizer may perform alterates on the bytecodes to enhance speed. For example... by now most people on the list probably know that: ++$i; Is faster than: $i++; An optmizer might see $i++ and determine that the return value is not used and thus the operation can be changed from $i++ to ++$i. Smilarly, the optimizer might encounter the following expression: $foo = 1 << 8 And reduce the constant expression (1 << 8) to (256). So the expression essentially becomes: $foo = 256 Similarly if you take the following expression: $text = "There was an old man from Nantuckit\n" ."Who's sole possession was a bucket.\n" ."One day with a grin,\n" ."While scratching his chin\n" ."He thought, \"I think I'll build a rocket.\"\n"; This could be optimized by removing concatenation operations and producing a single unified string within the bytecode. These are just basic optimizations obviously. Optimization is not a new thing, if you've ever used the -O flags when building a C program then you know that C compilers can also perform optimizations. 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
[PHP] Re: character encoding
Bill wrote: >> You can build mailto: links with a default subject and text, but I am >> not sure you can force Outlook to use specific HTML. It's wiser to not >> rely on mailto: . > > Hotmail will accept mail delivery from PHP ? mailto: links have nothing to do with PHP but generally speaking mailto: is not compatible with webmail unless you have some sort of extension/url handler installed. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to install PHP 5.x on Windows Server 2000 with IIS5and MySQL 5.x
On 3/29/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Shawn McKenzie wrote: > > >[EMAIL PROTECTED] wrote: > > > > > >>Shawn McKenzie wrote: > >> > >> > >> > >>>Paul Scott wrote: > >>> > >>> > >>> > >>> > On Thu, 2008-03-27 at 10:32 -0400, Wolf wrote: > > > > > >I'd suggest going with a real operating system (linux) which keeps > >patches updated quicker... > > > > > > > > > > > As much of a Free Software advocate as I am, that is not the answer to > the question. That being said, however, I would replace the IIS with > Apache2 at least... > > I seem to remember someone posting a really good guide to setting this > all up at some stage, so a quick search through the archives should > reveal all. > > > --Paul > > > > > > All Email originating from UWC is covered by disclaimer > http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm > > > > > >>>Download the zip and read the install.txt. It doesn't get any easier > >>>than that. It's very straight forward and has worked for me every time. > >>> > >>>-Shawn > >>> > >>> > >>> > >>> > >>> > >>Hello Shawn, > >> > >>How to enable php 5.2.5 with MySQL 5.0.51a ? > >> > >>Thank for your help ! > >> > >>Edward. > >> > >> > >> > >Make sure your extensions path is correct in php.ini and uncomment the > >extension=mysql.ini line in php.ini. > > > >-Shawn > > > > > > > Hello, > > 1, I had edited with extension=php_mysql.dll > 2, Test the php with mysql by using php page with phpinfo() function,the > result of mysql is enabled. > 3, I can edit the db data though the phpmyadmin tools. > 4, BUT test the connection with mysql as the following code is fail : > > //remember to change the password to whatever you set > //it to in mysql instance configuration > > //first parameter is server name, 2nd username 'root', 3rd is password > $rst = @mysql_connect("localhost","root","root"); > > if (!$rst){ > echo( "Unable to connect to database manager."); > die('Could not connect: ' . mysql_error()); > exit(); > } else { > echo("Successfully Connected to MySQL Database Manager!"); > } > > if (! @mysql_select_db("mysql") ){ > echo( "Unable to connect database..."); > exit(); > } else { > echo("Successfully Connected to Database 'MYSQL'!"); > } > ?> > > The warning message is "Access denied" > So, any more help ? That means that the user "root" with the password "root" does not have permission to connect to the MySQL server. I'm late to this thread, but if you have not touched MySQL's user accounts in any way, there should be a user "root" with an empty password. Try: $rst = @mysql_connect("localhost","root",""); -- -David. When the power of love overcomes the love of power, the world will know peace. -Jimi Hendrix -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] page content duration
Hi, i have a strange behavior on my web page. i have a form where users can enter their email address to subscribe to newsletter. if user already exists the page inform him and allow him to go back thanks a button. clicking on this button, load another page (initial page with the form for newsletter registration). if user enter another email address and click on the submit button... even if the email is not registered into DB (as user who want newsletter registration), the page display the message "user already registered". it's like it keeps in mind the previous email address... here is my code : > method="POST" action="../newsletter/"> > value='' > onfocus="if(this.value==' module_msg($welcome,$Lang, 'type_email'); ?>'){this.value=''};" > onblur="if (this.value==''){ this.value=' print module_msg($welcome,$Lang, 'type_email'); ?>' };" /> > value='' /> > > > i just added a feature to auto-complete the text field (email) in case of user already wrote email and clicked on back button of the registration checking page just to avoid him to rewrite email address... but anyway it should not keep it in mind... there is not $_SESSION variable. this code works perfectly under FF, but not under Opera, safari and IE 6. what could it be ? -- Alain Windows XP SP2 PostgreSQL 8.2.4 / MS SQL server 2005 Apache 2.2.4 PHP 5.2.4 C# 2005-2008
Re: [PHP] How to install PHP 5.x on Windows Server 2000 with IIS5and MySQL 5.x
Shawn McKenzie wrote: >[EMAIL PROTECTED] wrote: > > >>Shawn McKenzie wrote: >> >> >> >>>Paul Scott wrote: >>> >>> >>> >>> On Thu, 2008-03-27 at 10:32 -0400, Wolf wrote: >I'd suggest going with a real operating system (linux) which keeps patches >updated quicker... > > > > > As much of a Free Software advocate as I am, that is not the answer to the question. That being said, however, I would replace the IIS with Apache2 at least... I seem to remember someone posting a really good guide to setting this all up at some stage, so a quick search through the archives should reveal all. --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm >>>Download the zip and read the install.txt. It doesn't get any easier >>>than that. It's very straight forward and has worked for me every time. >>> >>>-Shawn >>> >>> >>> >>> >>> >>Hello Shawn, >> >>How to enable php 5.2.5 with MySQL 5.0.51a ? >> >>Thank for your help ! >> >>Edward. >> >> >> >Make sure your extensions path is correct in php.ini and uncomment the >extension=mysql.ini line in php.ini. > >-Shawn > > > Hello, 1, I had edited with extension=php_mysql.dll 2, Test the php with mysql by using php page with phpinfo() function,the result of mysql is enabled. 3, I can edit the db data though the phpmyadmin tools. 4, BUT test the connection with mysql as the following code is fail : Unable to connect to database manager."); die('Could not connect: ' . mysql_error()); exit(); } else { echo("Successfully Connected to MySQL Database Manager!"); } if (! @mysql_select_db("mysql") ){ echo( "Unable to connect database..."); exit(); } else { echo("Successfully Connected to Database 'MYSQL'!"); } ?> The warning message is "Access denied" So, any more help ? For the IIS configuration, load the c:\php\php-cgi.exe... Thanks ! Edward.
[PHP] Re: character encoding
Hi Manuel > You can build mailto: links with a default subject and text, but I am > not sure you can force Outlook to use specific HTML. It's wiser to not > rely on mailto: . Hotmail will accept mail delivery from PHP ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to install PHP 5.x on Windows Server 2000 with IIS5and MySQL 5.x
[EMAIL PROTECTED] wrote: > Shawn McKenzie wrote: > >> Paul Scott wrote: >> >> >>> On Thu, 2008-03-27 at 10:32 -0400, Wolf wrote: >>> >>> I'd suggest going with a real operating system (linux) which keeps patches updated quicker... >>> As much of a Free Software advocate as I am, that is not the answer to >>> the question. That being said, however, I would replace the IIS with >>> Apache2 at least... >>> >>> I seem to remember someone posting a really good guide to setting this >>> all up at some stage, so a quick search through the archives should >>> reveal all. >>> >>> >>> --Paul >>> >>> >>> >>> >>> >>> All Email originating from UWC is covered by disclaimer >>> http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm >>> >>> >> Download the zip and read the install.txt. It doesn't get any easier >> than that. It's very straight forward and has worked for me every time. >> >> -Shawn >> >> >> > Hello Shawn, > > How to enable php 5.2.5 with MySQL 5.0.51a ? > > Thank for your help ! > > Edward. > Make sure your extensions path is correct in php.ini and uncomment the extension=mysql.ini line in php.ini. -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to install PHP 5.x on Windows Server 2000 with IIS 5and MySQL 5.x
Shawn McKenzie wrote: >Paul Scott wrote: > > >>On Thu, 2008-03-27 at 10:32 -0400, Wolf wrote: >> >> >>>I'd suggest going with a real operating system (linux) which keeps patches >>>updated quicker... >>> >>> >>> >>As much of a Free Software advocate as I am, that is not the answer to >>the question. That being said, however, I would replace the IIS with >>Apache2 at least... >> >>I seem to remember someone posting a really good guide to setting this >>all up at some stage, so a quick search through the archives should >>reveal all. >> >> >>--Paul >> >> >> >> >> >>All Email originating from UWC is covered by disclaimer >>http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm >> >> > >Download the zip and read the install.txt. It doesn't get any easier >than that. It's very straight forward and has worked for me every time. > >-Shawn > > > Hello Shawn, How to enable php 5.2.5 with MySQL 5.0.51a ? Thank for your help ! Edward.
Re: [PHP] Simple RegEx to pull out content between 2 markers
Jon Bennett wrote: Hi, I need to grab the what's between 2 markers in a Textile / html string, but my regex skills aren't all that hot. The text I have is: h3. Article Content Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. p(image). !/app/image/1/large! Caption p(image). !/app/image/24/large! drunken jonty h3. Article Content !/app/image/7/thumb! Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. h3. Article Content Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. * Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. * Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. I'd like to grab the contents of left, right and main individually so I can place them in separate form fields. Any help greatly appreciated. I'm certain this is a cinch for people who use regex often. It's really not that hard if you use three separate expressions: $left = preg_match('/(.*)/is', $text, $matches); $right = preg_match('/(.*)/is', $text, $matches); $main = preg_match('/(.*)/is', $text, $matches); And then, IIRC, the content you're after will be in $matches[1]. -- Richard Heyes Employ me: http://www.phpguru.org/cv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple RegEx to pull out content between 2 markers
2008. 03. 29, szombat keltezéssel 11.26-kor Jon Bennett ezt írta: > Hi, > > I need to grab the what's between 2 markers in a Textile / html > string, but my regex skills aren't all that hot. The text I have is: > > > > h3. Article Content > > Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do > eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad > minim veniam, quis nostrud exercitation ullamco laboris nisi ut > aliquip ex ea commodo consequat. Duis aute irure dolor in > reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla > pariatur. Excepteur sint occaecat cupidatat non proident, sunt in > culpa qui officia deserunt mollit anim id est laborum. > > p(image). !/app/image/1/large! Caption > > p(image). !/app/image/24/large! drunken jonty > > > > > > h3. Article Content > > !/app/image/7/thumb! Lorem ipsum dolor sit amet, consectetur > adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore > magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation > ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute > irure dolor in reprehenderit in voluptate velit esse cillum dolore eu > fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, > sunt in culpa qui officia deserunt mollit anim id est laborum. > > > > > > h3. Article Content > > Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do > eiusmod tempor incididunt ut labore et dolore magna aliqua. > > * Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris > nisi ut aliquip ex ea commodo consequat. > * Duis aute irure dolor in reprehenderit in voluptate velit esse > cillum dolore eu fugiat nulla pariatur. > * Excepteur sint occaecat cupidatat non proident, sunt in culpa qui > officia deserunt mollit anim id est laborum. > > > > I'd like to grab the contents of left, right and main individually so > I can place them in separate form fields. > > Any help greatly appreciated. I'm certain this is a cinch for people > who use regex often. preg_match('/(.*)/sUi', $string, $matches); echo $matches[1]; it's not very complicated, the only interesting bits are the s and U modifiers at the end of the pattern. s makes the dot (.) to match newlines too, so the matched text can be more than one line, the U makes the engine 'ungreedy' which means that it stops after the first match. this means that if you have a string like and match for (.*), without the U modifier you would get the part between the first and the last . with the modifier you get the parts between any and the next more info here: http://hu.php.net/manual/en/reference.pcre.pattern.modifiers.php http://hu.php.net/manual/en/reference.pcre.pattern.syntax.php greets, Zoltán Németh > > Thanks, > > Jon > > > -- > > jon bennett > w: http://www.jben.net/ > iChat (AIM): jbendotnet Skype: jon-bennett > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Simple RegEx to pull out content between 2 markers
Hi, I need to grab the what's between 2 markers in a Textile / html string, but my regex skills aren't all that hot. The text I have is: h3. Article Content Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. p(image). !/app/image/1/large! Caption p(image). !/app/image/24/large! drunken jonty h3. Article Content !/app/image/7/thumb! Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. h3. Article Content Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. * Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. * Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. I'd like to grab the contents of left, right and main individually so I can place them in separate form fields. Any help greatly appreciated. I'm certain this is a cinch for people who use regex often. Thanks, Jon -- jon bennett w: http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP code to write excel spreadsheet with multiple workbooks
Mary Anderson wrote: I have a linux based web app which prints an html screen of results. My users really want Excel spreadsheets with the same results. There is a PEAR application which does this, but from the PEAR description it seems to be pretty buggy (65 open bugs, average days open 616 days) and dated. As long as your spreadsheets are simple without too much formatting etc., I don't think you should worry too much about these bugs. I have used the package in a variety of contexts without problems. My spreadsheets will be somewhat simple. They will have multiple workbooks and could be as large as 1 rows spread out over 100 workbooks I assume you mean multiple worksheets, not workbooks (AFAIK there can be only one workbook per file)? I don't have any experience with a file that big. You may also have a look at the PHPExcel package: http://www.phpexcel.net/ Christian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Posting Summary for Week Ending 28 March, 2008: php-general@lists.php.net
hey I made into the top five! celebrating this, now I top post :D ;) greets, Zoltán Németh 2008. 03. 28, péntek keltezéssel 16.00-kor PostTrack [Dan Brown] ezt írta: > Posting Summary for PHP-General List > Week Ending: Friday, 28 March, 2008 > > Messages| Bytes | Sender > ++-- > 311 (100%) 850774 (100%) EVERYONE > 18 (5.8%) 24095 (2.8%) Daniel Brown dot com> > 18 (5.8%) 24878 (2.9%) Mark Weaver dot com> > 16 (5.1%) 14590 (1.7%) tedd dot com> > 14 (4.5%) 20197 (2.4%) Nilesh Govindrajan itech7 dot com> > 10 (3.2%) 22378 (2.6%) Zoltán Németh alterationx dot hu> > 9 (2.9%) 10777 (1.3%) Casey com> > 9 (2.9%) 19224 (2.3%) Robert Cummings interjinn dot com> > 9 (2.9%) 16853 (2%)Shawn McKenzie mckenzies dot net> > 9 (2.9%) 7941(0.9%) Wolf com> > 8 (2.6%) 15638 (1.8%) Eric Butera gmail dot com> > 8 (2.6%) 10532 (1.2%) Andrew Ballard gmail dot com> > 7 (2.3%) 13758 (1.6%) Jason Pruim dot com> > 7 (2.3%) 12869 (1.5%) Lamp Lists yahoo dot com> > 7 (2.3%) 10655 (1.3%) Al > 7 (2.3%) 11444 (1.3%) Jim Lucas com> > 7 (2.3%) 11986 (1.4%) Richard Lynch com> > 4 (1.3%) 13584 (1.6%) Peter Ford dot com> > 4 (1.3%) 6940(0.8%) Philip Thompson gmail dot com> > 4 (1.3%) 5937(0.7%) Robin Vickery dot com> > 4 (1.3%) 5202(0.6%) Sudhakar dot com> > 4 (1.3%) 3466(0.4%) Greg Bowser dot com> > 3 (1%)3596(0.4%) Alain Roger gmail dot com> > 3 (1%)4162(0.5%) Bastien Koert dot com> > 3 (1%)4872(0.6%) VamVan com> > 3 (1%)3178(0.4%) Colin Guthrie dot guthr dot ie> > 3 (1%)9221(1.1%) Richard > 3 (1%)4352(0.5%) Michelle Konzack at freenet dot de> > 3 (1%)3090(0.4%) Bill com> > 3 (1%)3208(0.4%) Richard Heyes phpguru dot org> > 2 (0.6%) 95298 (11.2%) Andy Chong com> > 2 (0.6%) 1890(0.2%) Chris > 2 (0.6%) 2032(0.2%) Bill Guion dot net> > 2 (0.6%) 2417(0.3%) Liz Kim com> > 2 (0.6%) 95298 (11.2%) Andy Chong com dot sg> > 2 (0.6%) 2299(0.3%) Christoph Boget boget at gmail dot com> > 2 (0.6%) 10009 (1.2%) N dot Boatswain hotmail dot com> > 2 (0.6%) 95298 (11.2%) Andy Chong com dot cn> > 2 (0.6%) 1889(0.2%) Eric Wood com> > 2 (0.6%) 2183(0.3%) Paul Scott dot za> > 2 (0.6%) 2549(0.3%) Dan > 2 (0.6%) 1504(0.2%) It Maq com> > 2 (0.6%) 2288(0.3%) Manuel Lemos org> > 2 (0.6%) 1704(0.2%) Jeremy Privett omegavortex dot net> > 2 (0.6%) 1591(0.2%) Mário Gamito dot com> > 2 (0.6%) 1987(0.2%) Aschwin Wesselius illuminated dot nl> > 2 (0.6%) 2682(0.3%) Olivier Dupuis olivier at lemonde dot fr> > 2 (0.6%) 2557(0.3%) Simon Welsh co dot nz> > 2 (0.6%) 1606(0.2%) M dot Sokolewicz php dot net> > 2 (0.6%) 95298 (11.2%) Andy Chong url dot com dot tw> > 2 (0.6%) 3904(0.5%) Brandon Orther orther at think-done dot com> > 2 (0.6%) 2619(0.3%) Ron Piggott actsministries dot org> > 2 (0.6%) 1371(0.2%) Bagus Nugroho unisemgroup dot com> > 2 (0.6%) 4248(0.5%) Thiago Pojda at softpartech dot com dot br> > 2 (0.6%) 1942(0.2%) Ray Hauge lists at gmail dot com> > 2 (0.6%) 2551(0.3%) Kirk dot Johnson at zootweb dot > com > 1 (0.3%) 475 (0.1%) thomas Armstrong gmail dot com> > 1 (0.3%) 1377(0.2%) Alfredo CV loslibrosusados dot net> > 1 (0.3%) 793 (0.1%) Rod Clay rr dot com> > 1 (0.3%) 1007(0.1%) David Lidstone dot co dot uk> > 1 (0.3%) 1576(0.2%) jeffry s com> > 1 (0.3%) 1585(0.2%) Tom Chubb com> > 1 (0.3%) 3016(0.4%) robert com> > 1 (0.3%) 184 (0%)Sancar Saran at evodot dot co
Re: [PHP] why won't my array work?
2008. 03. 28, péntek keltezéssel 12.28-kor Jason Pruim ezt írta: > Hi everyone :) Happy friday to all of you! > > Here's my issues, I am attempting to echo the results of mysqli query > out to my script just so I can make sure it's working right, what I'm > hoping to do in the long run is compare what was typed in a text box > to this info... It's for verifying a old password before changing to a > new password... So here is my query: > > $oldpasswordquery = "SELECT loginPassword, Record FROM current WHERE > loginPassword='{$oldPassHash}' AND Record='{$Record}'"; > $chpwold[] = mysqli_query($chpwpostlink, $oldpasswordquery) or > die("Sorry read failed: ". mysqli_error($chpwpostlink)); > $chpwresult = $chpwold[0]; > $chpwrow[] = mysqli_fetch_assoc($chpwresult) or die('Sorry it didn\'t > work' .mysqli_error($chpwpostlink)); > echo $chpwrow['loginPassword']; > print_r($chpwrow); > > > The echo and the print_r are for debugging and obviously wont' be in > the final script... Here is the error that I am getting: > > [Fri Mar 28 12:14:39 2008] [error] PHP Notice: Undefined index: > loginPassword in /Volumes/RAIDer/webserver/Documents/dev/OLDBv2/admin/ > chpwpost.php on line 18 > > > Line 18 is where the echo is... > > the print_r though shows this: > > Array ( [0] => Array ( [loginPassword] => > 42205baa2581d3fcd8d8f9c6b9746a1f [Record] => 2 ) ) > > So why can't I access it via $chpwrow['loginPassword']? I'm > stumped Anyone that can help me has a free beer waiting for them > the next time they are in my town! :) from the print_r it looks like that you could access it like $chpwrow[0]['loginPassword'] greets, Zoltán Németh > > -- > > Jason Pruim > Raoset Inc. > Technology Manager > MQC Specialist > 3251 132nd ave > Holland, MI, 49424-9337 > www.raoset.com > [EMAIL PROTECTED] > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: optimilize web page loading
2008. 03. 28, péntek keltezéssel 11.31-kor tedd ezt írta: > At 9:14 AM +0100 3/28/08, Zoltán Németh wrote: > > > This way for literal strings, the PHP parser doesn't have to evaluate > > > this string to determine if anything needs to be translated (e.g., > > > $report .= "I like to $foo"). A minimal speedup, but nonetheless... > > > >that above statement is simply not true. parsing "foo" and 'foo' is all > >the same > >a good read about it: > >http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html > > > >greets, > >Zoltán Németh > > I read it, but it still doesn't disprove the premise. yeah, that was morning time and I got mixed up a bit :) Anyway, I had to admit that I was wrong in this matter, Rob Cummings has just proven me that there is a difference, however little is it greets, Zoltán Németh > > 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] Re: optimilize web page loading
2008. 03. 28, péntek keltezéssel 10.59-kor Robert Cummings ezt írta: > On Fri, 2008-03-28 at 15:30 +0100, Zoltán Németh wrote: > > 2008. 03. 28, péntek keltezéssel 10.24-kor Robert Cummings ezt írta: > > > On Fri, 2008-03-28 at 14:46 +0100, Zoltán Németh wrote: > > > > > > > > yeah maybe. you're right, the bytecode is the same. but somewhere I > > > > heard that the parsing is the same too - because escaped characters can > > > > be in any string, though I'm not that sure about this anymore, as my > > > > link proved something else ;) > > > > > > Single quoted strings do support some escape characters. As far as I > > > know only you can only escape a single quote and a backslash when > > > creating a string via single quotes. > > > > yes, but I think the parser would still need to tokenize the string and > > verify each token whether it contains an escape character or not - which > > should be the same process as tokenizing and checking for escape > > character and $ signs. > > Nope, when processing a single quoted string there should be 4 available > parse branches: > > EOF > '(end of string) > \ > EOF > \ > ' > anything else > anything else > > Whereas with a double quoted string you have something along the lines > of: > > EOF > "(end of string) > $(begin variable) > {(possible begin interpolation) > $(begin interpolation) > \ > EOF > \ > ' > " > t > n > r > x > v > f > > anything else > anything else > > So presuming no variable is embeded and assuming no escaped > characters... double quotes still need to check for the beginning of > variable interpolation which has 2 different start possibilities. With > respect to creating the byte code single quotes have 4 branches, double > quotes have 6 branches in the simplest of cases with no escape and no > interpolation. So one would expect compile time for double quotes to be > approximately 33% slower than for single quotes. good points, thanks for the detailed info (not that I'd focus on it while coding but its sooo interesting :) ) > Once compiled though, > the point is moot especially since most sites use a bytecode cache like > eAccelerator or APC. Even without a cache htough, the time difference is > tncy, and this is just for informational purposes :) There are > usually bigger eggs to fry when optimizing. sure, these questions like 'echo or print' and 'single or double quotes' and 'for or while' and so on should never be mentioned when talking about real life code optimizing, as the difference they may make is so minimal. talking about these is good only for satisfying some of my (and maybe some other people's) curiosity about how php works internally :) > One last thing though... > even if this were escaped and even if there were fifty variables > embedded, a good bytecode optimizer (not quite the same as a bytecode > cacher) would optimize the bytecode for caching so that the string is > broken up according to what needs to be interpolated and what does not. could you tell me more about this bytecode optimizer stuff? how does it work, how much better/faster is it then APC/EAccelerator/etc? greets, Zoltán Németh > > Cheers, > Rob. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php