Re: [PHP] unexpected '@' in preg_replace??? - SOLVED
2007. 10. 29, hétfő keltezéssel 09.17-kor Jim Lucas ezt írta: > Daniel Brown wrote: > > On 10/29/07, Zoltán Németh <[EMAIL PROTECTED]> wrote: > >> hi list, > >> > >> I have this code: > > [snip!] > >> Parse error: syntax error, unexpected '@' > >> in /home/znemeth/public_html/test/pregreplacetest1.php(94) : regexp code > >> on line 1 > >> > >> Fatal error: preg_replace() [ >> href='function.preg-replace'>function.preg-replace]: Failed > >> evaluating code: [EMAIL PROTECTED] > >> in /home/znemeth/public_html/test/pregreplacetest1.php on line 94 > > [snip=again!] > > > > Zoltan, > > > > If you're using preg_replace(), where are your start and stop > > characters for the pattern and subject? > > > > $szoveg = preg_replace('/'.$mit.'/','/'.$mire.'/',$dokumentum); > > > > You could otherwise try ereg_replace(); without the slashes, or do > > an htmlentities($dokumentum);. > > > > Look again and you will notice that $mit and $mire are both arrays. > > Also, the starting and stopping points are in the $mit array elements. > > The starting and stopping points are not allowed in the $mire array. > > This was the offending line in the code. I removed the e from the modifiers > list and it started > working. See if you can run the code without it. > > '/]*>(.*?)<\/strong>/i', // many thanks Jim, it solved the issue > > > you missed your closing option > '/<\/?p[^>]*>/i', // > > or maybe you should have a different entry to remove the and replace it > with nothing. > this > '/]*>/i', // > that >"\n\n\t", > > this > '/<\/p[^>]*>/i', // > that >'', thanks for this also, I added it > > Side note, you might want to look into using the '+' instead of the '*'. > '+' = must be one or more > '*' = 0 or more > > In some of the cases here, I see where this can bite you in the butt later. > thanks for the tip, I will look at it greets Zoltán Németh > > -- > 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
Re: [PHP] moving over to php 5
Larry Garfield wrote: > On Monday 29 October 2007, Per Jessen wrote: >> Cristian Vrabie wrote: >> > Hmm 117,223 hosts with php4 only support. Did you actually checked >> > how many have php5 support? Many more. >> >> There are 178.112 hosters that have PHP5 support. I checked. > > Where and how did you check? Well, I didn't. I just provided a silly answer to an impossible question. There is no way anyone could possibly come up with a remotely accurate number of how many hosters have this or that. So I made the numbers up. $RANDOM. > I have a hard time believing that there are 300,000 different > commercial web hosting companies out there. That many servers, sure, > but companies? 300,000 is probably a lot, yes. Still, Switzerland alone has roughly 335.000 companies. About 400 of those are members of a Swiss association for ISPs, but there's probably another couple of hundred that aren't. Extrapolating from e.g. 500 webhosters for a population of 7million, that would make roughly 35,000 in the EU (pop. 480mill). /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] moving over to php 5
Larry Garfield wrote: > Here's a bigger question: When will people stop using mysql_ as their > example API, when PDO is more standard in PHP 5 and more secure, and > mysqli is available as well? As always, the key question must be - what's the advantage of moving? When the developer benefits from something being "more standard" and more secure, then he'll change. If you want to force someone to change, you remove the interface (after having marked it deprecated for a while). /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] isodd() php5?
Hi, Is there a built in function in PHP5 to determine if an integer is even or odd? Ross -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] isodd() php5?
At 09:32 30/10/2007, Hulf wrote: Hi, Is there a built in function in PHP5 to determine if an integer is even or odd? How about : if ($IntegerValue % 2) { // odd } else { // even } HTH J -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP installation
Hi, Trying to install PHP, however it's failing with the following: Configuring extensions checking whether to enable LIBXML support... yes checking libxml2 install dir... /usr/lib64 checking for xml2-config path... /usr/bin/xml2-config checking whether libxml build works... no configure: error: build test failed. Please check the config.log for details. The following is in config.log: configure:20028: checking whether libxml build works configure:20055: gcc -o conftest -g -O2 conftest.c -lresolv -lm -ldl -lnsl -lxml2 -lz -lm 1>&5 /usr/bin/ld: cannot find -lz collect2: ld returned 1 exit status configure: failed program was: #line 20044 "configure" #include "confdefs.h" char xmlInitParser(); int main() { xmlInitParser(); return 0; } If it helps, this is a bit of an `ls -l` of /usr/lib64: libxml2.so -> libxml2.so.2.6.27 libxml2.so.2 -> libxml2.so.2.6.27 libxml2.so.2.6.19 libxml2.so.2.6.27 And this is what's at the end of my config.log: configure:19793: checking whether to enable LIBXML support configure:19841: checking libxml2 install dir configure:19870: checking for xml2-config path configure:20028: checking whether libxml build works configure:20055: gcc -o conftest -g -O2 conftest.c -lresolv -lm -ldl -lnsl -lxml2 -lz -lm 1>&5 /usr/bin/ld: cannot find -lz collect2: ld returned 1 exit status configure: failed program was: #line 20044 "configure" #include "confdefs.h" char xmlInitParser(); int main() { xmlInitParser(); return 0; } Thanks. -- Richard Heyes +44 (0)800 0213 172 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software that can cut the cost of online support -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP installation
Richard Heyes wrote: > The following is in config.log: > > configure:20028: checking whether libxml build works > configure:20055: gcc -o conftest -g -O2 conftest.c > > -lresolv -lm -ldl -lnsl -lxml2 -lz -lm 1>&5 > /usr/bin/ld: cannot find -lz Looks like you need to install libz. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] REGEX: grouping of alternative patterns
Hey list, I'm having problems with grouped alternative patterns. The regex I would like to use, is the following: /\s*(`?.+`?)\s*int\s*(\(([0-9]+)\))?\s*(unsigned)?\s*(((auto_increment)?\s*(primary\s*key)?)|((not\s*null)?\s*(default\s*(`.*`|[0-9]*)?)?))\s*/i It matches this statement: `id` INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY But not this: `test4` INT(11) UNSIGNED NOT NULL DEFAULT 5 However, if I switch the alternatives, the first statement doesn't match, but the second does. FYI: In both cases, the column name and data type are matched, as expected. It appears to be doing lazy evaluation on the pattern, even though every resource I can find states that every alternative is tried in turn until a match is found. Any ideas on how this can be resolved would be greatly appreciated. Here is some code: $pattern1 = '/\s*(`?.+`?)\s*int\s*(\(([0-9]+)\))?\s*(unsigned)?\s*(((auto_increment)?\s*(primary\s*key)?)|((not\s*null)?\s*(default\s*(`.*`|[0-9]*)?)?))\s*/i'; $pattern2 = '/\s*(`?.+`?)\s*int\s*(\(([0-9]+)\))?\s*(unsigned)?\s*(((not\s*null)?\s*(default\s*(`.*`|[0-9]*)?)?)|((auto_increment)?\s*(primary\s*key)?))\s*/i'; $column1 = '`id` INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY'; $column2 = '`test4` INT(11) UNSIGNED NOT NULL DEFAULT 5'; $matches = array(); preg_match($pattern1, $column1, $matches); print_r($matches); // match preg_match($pattern1, $column2, $matches); print_r($matches); // doesn't match preg_match($pattern2, $column1, $matches); print_r($matches); // doesn't match preg_match($pattern2, $column2, $matches); print_r($matches); // match ?> Greetz, Stijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP installation
Per Jessen wrote: Richard Heyes wrote: The following is in config.log: configure:20028: checking whether libxml build works configure:20055: gcc -o conftest -g -O2 conftest.c -lresolv -lm -ldl -lnsl -lxml2 -lz -lm 1>&5 /usr/bin/ld: cannot find -lz Looks like you need to install libz. I installed various zlib and zlib-devel packages, but finally went with an rpm, but when I run `apachectl configtest` I get this: Cannot load /usr/lib64/httpd/modules/libphp5.so into server: /usr/lib64/httpd/modules/libphp5.so: undefined symbol: apr_pool_cleanup_null Umm help? -- Richard Heyes +44 (0)800 0213 172 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software that can cut the cost of online support -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP installation
Richard Heyes wrote: Per Jessen wrote: Richard Heyes wrote: The following is in config.log: configure:20028: checking whether libxml build works configure:20055: gcc -o conftest -g -O2 conftest.c -lresolv -lm -ldl -lnsl -lxml2 -lz -lm 1>&5 /usr/bin/ld: cannot find -lz Looks like you need to install libz. I installed various zlib and zlib-devel packages, but finally went with an rpm, but when I run `apachectl configtest` I get this: Cannot load /usr/lib64/httpd/modules/libphp5.so into server: /usr/lib64/httpd/modules/libphp5.so: undefined symbol: apr_pool_cleanup_null OK so now I'm back to compiling PHP after the ridiculous nightmare of rpms. I checked /lib and have the following: [EMAIL PROTECTED] php-5.2.4]# ls -l /lib/libz.so.1.2.3 -rwxr-xr-x 1 root root 71744 Sep 21 19:23 /lib/libz.so.1.2.3 Is PHP looking for a different file? Thanks. -- Richard Heyes +44 (0)800 0213 172 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software that can cut the cost of online support -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] isodd() php5?
At 9:32 AM + 10/30/07, Hulf wrote: Hi, Is there a built in function in PHP5 to determine if an integer is even or odd? Ross Try: echo($integer & 1); 1 = odd, 0 = even. 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] REGEX: grouping of alternative patterns
On 30/10/2007, Stijn Verholen <[EMAIL PROTECTED]> wrote: > Hey list, > > I'm having problems with grouped alternative patterns. > The regex I would like to use, is the following: > > /\s*(`?.+`?)\s*int\s*(\(([0-9]+)\))?\s*(unsigned)?\s*(((auto_increment)?\s*(primary\s*key)?)|((not\s*null)?\s*(default\s*(`.*`|[0-9]*)?)?))\s*/i > > It matches this statement: > > `id` INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY > > But not this: > > `test4` INT(11) UNSIGNED NOT NULL DEFAULT 5 > > However, if I switch the alternatives, the first statement doesn't > match, but the second does. > FYI: In both cases, the column name and data type are matched, as expected. > It appears to be doing lazy evaluation on the pattern, even though every > resource I can find states that every alternative is tried in turn until > a match is found. It's not lazy. Given alternate matching subpatterns, the pcre engine choses the leftmost pattern, not the longest. For instance: Array ( [0] => a ) This isn't what you'd expect if you were familiar with POSIX regular expressions, but matches Perl's behaviour. Because each of your subpatterns can match an empty string, the lefthand subpattern always matches and the righthand subpattern might as well not be there. The simplest solution, if you don't want to completely rethink your regexp might be to replace \s with [[:space:]], remove the delimiters and the i modifier and just use eregi(). like so: $pattern = '[[:space:]]*(`?.+`?)[[:space:]]*int[[:space:]]*(\(([0-9]+)\))?[[:space:]]*(unsigned)?[[:space:]]*(((auto_increment)?[[:space:]]*(primary[[:space:]]*key)?)|((not[[:space:]]*null)?[[:space:]]*(default[[:space:]]*(`.*`|[0-9]*)?)?))[[:space:]]*'; eregi($pattern, $column1, $matches); print_r($matches); // match eregi($pattern, $column2, $matches); print_r($matches); // match -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] REGEX: grouping of alternative patterns
On 30 October 2007 11:07, Stijn Verholen wrote: > Hey list, > > I'm having problems with grouped alternative patterns. > The regex I would like to use, is the following: > > /\s*(`?.+`?)\s*int\s*(\(([0-9]+)\))?\s*(unsigned)?\s*(((auto_i > ncrement)?\s*(primary\s*key)?)|((not\s*null)?\s*(default\s*(`. > *`|[0-9]*)?)?))\s*/i Since all the parts beyond the id and datatype are optional, I don't see how this can ever not match. Please define more accurately what you mean by "doesn't match". 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] moving over to php 5
On 30/10/2007, Per Jessen <[EMAIL PROTECTED]> wrote: > Larry Garfield wrote: > > > On Monday 29 October 2007, Per Jessen wrote: > >> Cristian Vrabie wrote: > >> > Hmm 117,223 hosts with php4 only support. Did you actually checked > >> > how many have php5 support? Many more. > >> > >> There are 178.112 hosters that have PHP5 support. I checked. > > > > Where and how did you check? > > Well, I didn't. I just provided a silly answer to an impossible > question. There is no way anyone could possibly come up with a > remotely accurate number of how many hosters have this or that. So I > made the numbers up. $RANDOM. > > > I have a hard time believing that there are 300,000 different > > commercial web hosting companies out there. That many servers, sure, > > but companies? > > 300,000 is probably a lot, yes. Still, Switzerland alone has roughly > 335.000 companies. About 400 of those are members of a Swiss > association for ISPs, but there's probably another couple of hundred > that aren't. Extrapolating from e.g. 500 webhosters for a population > of 7million, that would make roughly 35,000 in the EU (pop. 480mill). Besides, the set of fictitious companies that support PHP4 and the set of fictitious companies that support PHP5 probably intersect to a large extent. In fact, I researched the matter thoroughly a couple of minutes ago and found that 108,064 companies support both versions of PHP, so there's only a total of 187,271 PHP hosting companies. Anyone still do PHP/FI? -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] REGEX: grouping of alternative patterns [SOLVED]
Robin Vickery schreef: [snip] Because each of your subpatterns can match an empty string, the lefthand subpattern always matches and the righthand subpattern might as well not be there. Indeed they do, i did not realise that. The simplest solution, if you don't want to completely rethink your regexp might be to replace \s with [[:space:]], remove the delimiters and the i modifier and just use eregi(). like so: Because this is for a proof-of-concept application that will only be used by me for the time being, and because I always give a default value when specifying 'not null', I'm going to use the following, and think about a more general solution if and when the need arises. This matches both my cases: /\s*(`?.+`?)\s*int\s*(\(([0-9]+)\))?\s*(unsigned)?\s*(((not\s*null)\s*(default\s*(`.*`|[0-9]*)?))|((auto_increment)?\s*(primary\s*key)?))\s*/i [snip] -robin Thanks for your insights, Robin ! Greetz, Stijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] moving over to php 5
On Tuesday 30 October 2007, Per Jessen wrote: > Larry Garfield wrote: > > Here's a bigger question: When will people stop using mysql_ as their > > example API, when PDO is more standard in PHP 5 and more secure, and > > mysqli is available as well? > > As always, the key question must be - what's the advantage of moving? > When the developer benefits from something being "more standard" and > more secure, then he'll change. > If you want to force someone to change, you remove the interface (after > having marked it deprecated for a while). Prepared statements are inherently more secure than doing your own escaping. Thus, given the bad rap that PHP had for years on the security front, encouraging the use of prepared statements is up there with discouraging the use of register_globals. The sooner you convince new PHP programmers to do things in a naturally more secure way, the fewer bugs they will accidentally introduce later. (And I say more secure because nothing is 100% secure for you without effort; prepared statements and the filter extension just make it a lot easier to write secure code.) -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unexpected '@' in preg_replace???
On 10/30/07, Zoltán Németh <[EMAIL PROTECTED]> wrote: > 2007. 10. 29, hétfő keltezéssel 11.17-kor Daniel Brown ezt írta: > > On 10/29/07, Zoltán Németh <[EMAIL PROTECTED]> wrote: > > > hi list, > > > > > > I have this code: > > [snip!] > > > Parse error: syntax error, unexpected '@' > > > in /home/znemeth/public_html/test/pregreplacetest1.php(94) : regexp code > > > on line 1 > > > > > > Fatal error: preg_replace() [ > > href='function.preg-replace'>function.preg-replace]: Failed > > > evaluating code: [EMAIL PROTECTED] > > > in /home/znemeth/public_html/test/pregreplacetest1.php on line 94 > > [snip=again!] > > > > Zoltan, > > > > If you're using preg_replace(), where are your start and stop > > characters for the pattern and subject? > > > > $szoveg = preg_replace('/'.$mit.'/','/'.$mire.'/',$dokumentum); > > $mit and $mire are arrays. $mit contains all the patterns, they all > start and end with / > $mire contains all the replacements. > > > > > You could otherwise try ereg_replace(); without the slashes, or do > > an htmlentities($dokumentum);. > > ereg_replace cannot take arrays as arguments... > htmlentities might work but then all my patterns containing < or > has > to be modified - and then it might replace strings which I don't want to > get replaced. e.g.