php-general Digest 12 Jan 2011 07:38:24 -0000 Issue 7128

Topics (messages 310678 through 310688):

Re: Stripping carriage returns
        310678 by: Mari Masuda
        310683 by: Jim Lucas

Re: Validate Domain Name by Regular Express
        310679 by: Steve Staples
        310680 by: Ashley Sheridan

Server Response
        310681 by: Al

Re: Craigslist Jobs
        310682 by: Mujtaba Arshad

HTML errors
        310684 by: David McGlone
        310685 by: Chen Dong
        310686 by: David Robley
        310687 by: Daniel Brown
        310688 by: Jim Lucas

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
On Jan 11, 2011, at 11:34 AM, Richard S. Crawford wrote:

> Strangely, when I use \n, or nl2br(), or PHP_EOL, or anything like that, it
> strips out not just line breaks, but most of the rest of the text as well. I
> suspect an encoding issue at this point.
> 
> Daniel, you were right when you said that neither of my str_replace lines
> had repl.acement values; that was indeed a typo when I was copying the code
> over into my email.
> 
> Ashley, I've already been using strip_tags to eliminate all but <p>, <ol>,
> <ul>, and <li> tags.
> 

Perhaps you could use tidy to clean up the formatting  (use -wrap 0) before 
attempting to strip out the stuff you want to get rid of.

Mari

--- End Message ---
--- Begin Message ---
On 1/11/2011 11:13 AM, Richard S. Crawford wrote:
> I'm retrieving CLOB data from an Oracle database, and cleaning up the HTML
> in it. I'm using the following commands:
> 
>     $content =
> strip_tags($description->fields['CONTENT'],'<p><ol><ul><li>');
>     $content = preg_replace("/<p.*>/","<p>",$content);
> 
> The second line is necessary because the <p> tag frequently comes with class
> or style descriptions that must be eliminated.
> 
> This works on the whole except where the <p> tag with the style definition
> is broken up over two or more lines. In other words, something like:
> 
> <p class = "bullettext" style = "line-height: normal
> border: 3;">
> 
> In this case, the second line of my code does not strip the class or style
> definitions from the paragraph tag. I've tried:
> 
> $content = nl2br($content)
> 
> and
> 
> $content = str_replace(chr(13),$content)
> 
> and
> 
> $content = preg_replace("/[".chr(10)."|".chr(13)."]/","",$content)
> (I've read that Oracle uses chr(10) or chr(13) to represent line breaks
> internally, so I decided to give those a try as well.)
> 
> and
> 
> $content = str_replace(array('\n','\r','\r\n'),$content)
> 
> all to no avail; these all leave the line break intact, which means my
> preg_replace('/<p.*>/','<p>',$content) line still breaks.
> 
> Anyone have any ideas?
> 

Richard,

Looks like you need to read up on the modifiers for preg_* functions.  Start
here:  http://us3.php.net/manual/en/reference.pcre.pattern.modifiers.php

I would change your "second line" regex to the following.

$content = preg_replace("/<p.*>/is", "<p>", $content);

The modifiers after the second / are

i = case-insensitive
s = include new lines in your '.' character match.
    New lines are excluded by default.

Can't remember right now, nor do I have the time to test, you might need to
invert the greediness of the match using a 'U' after the second / also.

So...

$content = preg_replace("/<p.*>/isU", "<p>", $content);

YMMV

Let us know how this works out for you.

Jim Lucas

PS: you might want to swap the order of these two statements.

--- End Message ---
--- Begin Message ---
On Tue, 2011-01-11 at 19:00 +0000, Ashley Sheridan wrote:
> On Tue, 2011-01-11 at 17:07 +0100, Michelle Konzack wrote:
> 
> > Hello Ashley Sheridan,
> > 
> > Am 2011-01-08 17:09:27, hacktest Du folgendes herunter:
> > > Also, each label is checked to ensure it doesn't run over 63 characters,
> > > and the whole thing isn't over 253 characters. Lastly, each label is
> > > checked to ensure it doesn't completely consist of digits.
> > 
> > Do you know, that there are MANY domains with numbers only?
> > 
> > Like <163.com> or <126.net> which are legal names.
> > 
> > Oh I should mention that I block ANY mails from this two  domains  since
> > chinese spamers use it excessively.
> > 
> > Thanks, Greetings and nice Day/Evening
> >     Michelle Konzack
> > 
> 
> 
> I just based the code on the spec.
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> 

my old (still kinda active but not really) business was/is called
990WEBS, and my URL is www.990webs.ca / www.990webs.com  is the url with
preceeding numerals an issue?  or is this only numerals only?

it also is my business number :P   990-9327 (WEBS)

TheStapler.ca is also my domain...   which is a my nickname (last name
is staples).... ANYWAY... way off topic there, was just wodnering about
the "legality" of my 990webs domains... since i can't think of any other
domains that start with numbers off the top of my head?



-- 

Steve Staples
Web Application Developer
519.258.2333 x8414


--- End Message ---
--- Begin Message ---
On Tue, 2011-01-11 at 14:44 -0500, Steve Staples wrote:

> On Tue, 2011-01-11 at 19:00 +0000, Ashley Sheridan wrote:
> > On Tue, 2011-01-11 at 17:07 +0100, Michelle Konzack wrote:
> > 
> > > Hello Ashley Sheridan,
> > > 
> > > Am 2011-01-08 17:09:27, hacktest Du folgendes herunter:
> > > > Also, each label is checked to ensure it doesn't run over 63 characters,
> > > > and the whole thing isn't over 253 characters. Lastly, each label is
> > > > checked to ensure it doesn't completely consist of digits.
> > > 
> > > Do you know, that there are MANY domains with numbers only?
> > > 
> > > Like <163.com> or <126.net> which are legal names.
> > > 
> > > Oh I should mention that I block ANY mails from this two  domains  since
> > > chinese spamers use it excessively.
> > > 
> > > Thanks, Greetings and nice Day/Evening
> > >     Michelle Konzack
> > > 
> > 
> > 
> > I just based the code on the spec.
> > 
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> > 
> > 
> 
> my old (still kinda active but not really) business was/is called
> 990WEBS, and my URL is www.990webs.ca / www.990webs.com  is the url with
> preceeding numerals an issue?  or is this only numerals only?
> 
> it also is my business number :P   990-9327 (WEBS)
> 
> TheStapler.ca is also my domain...   which is a my nickname (last name
> is staples).... ANYWAY... way off topic there, was just wodnering about
> the "legality" of my 990webs domains... since i can't think of any other
> domains that start with numbers off the top of my head?
> 
> 
> 
> -- 
> 
> Steve Staples
> Web Application Developer
> 519.258.2333 x8414
> 
> 


Ah, it was my mistake, I misread the spec. It's only the TLD that must
not be completely numeric, so that check can be taken out of the code I
gave earlier.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
Newsgroup server response is terrible and has a strange behavior.

Response for first posting or two is fast, then it acts like it doesn't want to give me any additional postings.

You fixed it about about 2 or 3 weeks ago; but issue has returned,

Al..............

--- End Message ---
--- Begin Message ---
join oDesk. They have a lot of programming jobs on there, it is also pretty
secure.

On Tue, Jan 11, 2011 at 12:57 PM, Matty Sarro <[email protected]> wrote:

> Quote:"Yes, you will get burned a few times, and have both good and
> bad experiences when you least expect them - the main thing is just to
> remember the clients are people, with a problem to solve, you're there
> to solve that problem in a cost effective manner, and ultimately your
> work has two values, the first is what you require to put food on the
> table, and the second is what the project is worth to the the client.
> If you land anywhere between the two of those, then you're doing well
> :)"
>
> That is awesome advice for any employee in any field, anywhere. :)
>
> On Tue, Jan 11, 2011 at 12:27 PM, Nathan Rixham <[email protected]> wrote:
> > Ethan Rosenberg wrote:
> >>
> >> Dear List -
> >>
> >> I am a NEWBIE, so .....
> >>
> >> How do I handle Craigslist postings? Is there anything special I should
> >> do?  Any advice for other web sites?
> >>
> >> At this point I am talking about small jobs.
> >>
> >> 1] My payment.  Should I ask for something up front?  If so how much?
> >
> > depends on the amount, how comfortable you are, and how comfortable they
> > are, escrow is safer for larger amounts.
> >
> >> 2] How do I protect myself so that I do not deliver code and not get
> paid.
> >
> > pretty much the same way you protect yourself from not getting run over
> or
> > robbed.
> >
> >> 3] What is a reasonable hourly rate?
> >
> > multiple factors here, a good starting point is to figure out how much
> you
> > need to make an hour, add 20-40% on, then figure out how many hours it'll
> > take you, multiply it all up and add on another 20-40%
> >
> > All this depends on your skill level, if you can do the job, if the
> customer
> > has the budget and so forth - just agree something you're both
> comfortable
> > with.
> >
> >> 4] Any other information that I should know?
> >
> > Yes, you will get burned a few times, and have both good and bad
> experiences
> > when you least expect them - the main thing is just to remember the
> clients
> > are people, with a problem to solve, you're there to solve that problem
> in a
> > cost effective manner, and ultimately your work has two values, the first
> is
> > what you require to put food on the table, and the second is what the
> > project is worth to the the client. If you land anywhere between the two
> of
> > those, then you're doing well :)
> >
> > Best,
> >
> > Nathan
> >
> > --
> > 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
>
>


-- 
Mujtaba

--- End Message ---
--- Begin Message ---
Hi Everyone, I'm having a problem validating some links I have in a foreach.
Here is my code:
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd";>

my PHP code:
$categorys = array('home', 'services', 'gallery', 'about_us', 'contact_us', 
'testimonials');
foreach($categorys as $category){
$replace = str_replace("_", " ", $category); 
echo "<li><a href='index.php?page=$category'>$replace</a></li>";
}

Validator Error:
an attribute value must be a literal unless it contains only name characters

…ome>home</a></li><li><a href=index.php?page=services>services</a></li><li><a 
h…

I have tried various combinatons and different doctypes. I'm beginning to 
wonder if this code is allowed at all.


-- 
Blessings
David M.

--- End Message ---
--- Begin Message ---
Hi David:

Quote your attribute value in "..."

On Wed, Jan 12, 2011 at 2:35 PM, David McGlone <[email protected]> wrote:

> Hi Everyone, I'm having a problem validating some links I have in a
> foreach.
> Here is my code:
>  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd";>
>
> my PHP code:
> $categorys = array('home', 'services', 'gallery', 'about_us', 'contact_us',
> 'testimonials');
> foreach($categorys as $category){
> $replace = str_replace("_", " ", $category);
> echo "<li><a href='index.php?page=$category'>$replace</a></li>";
> }
>
> Validator Error:
> an attribute value must be a literal unless it contains only name
> characters
>
> …ome>home</a></li><li><a
> href=index.php?page=services>services</a></li><li><a
> h…
>
> I have tried various combinatons and different doctypes. I'm beginning to
> wonder if this code is allowed at all.
>
>
> --
> Blessings
> David M.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Regards,
CHEN Dong

--- End Message ---
--- Begin Message ---
David McGlone wrote:

> Hi Everyone, I'm having a problem validating some links I have in a
> foreach. Here is my code:
>  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd";>
> 
> my PHP code:
> $categorys = array('home', 'services', 'gallery', 'about_us',
> 'contact_us', 'testimonials');
> foreach($categorys as $category){
> $replace = str_replace("_", " ", $category);
> echo "<li><a href='index.php?page=$category'>$replace</a></li>";
> }
> 
> Validator Error:
> an attribute value must be a literal unless it contains only name
> characters
> 
> ?ome>home</a></li><li><a
> href=index.php?page=services>services</a></li><li><a h?
> 
> I have tried various combinatons and different doctypes. I'm beginning to
> wonder if this code is allowed at all.
> 
> 

In this tag you aren't getting the href value enclosed in quotes which I
suspect would trigger the validator error.

<a href=index.php?page=services>



Cheers
-- 
David Robley

"I'll take that," said Tom appropriately.
Today is Boomtime, the 12nd day of Chaos in the YOLD 3177. 


--- End Message ---
--- Begin Message ---
On Tue, Jan 11, 2011 at 22:35, David McGlone <[email protected]> wrote:
> Hi Everyone, I'm having a problem validating some links I have in a foreach.
> Here is my code:
>  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd";>
>
> my PHP code:
> $categorys = array('home', 'services', 'gallery', 'about_us', 'contact_us',
> 'testimonials');
> foreach($categorys as $category){
> $replace = str_replace("_", " ", $category);
> echo "<li><a href='index.php?page=$category'>$replace</a></li>";
> }
>
> Validator Error:
> an attribute value must be a literal unless it contains only name characters

    This is because you misspelled $categorys, where it should
actually be $categories.  In some of the most recent updates to the
core, primarily by Felipe Pena, PHP will now, by default, kick out
errors in validation due to misspellings and incorrect grammar.  To
override this, you must uncomment the following line in your system's
php.ini:

        ;human = true

    This will allow the parser to understand that you're human, thus
capable of mistakes.  Please keep in mind, however, that it's only
able to be set in php.ini.  This is to keep bots and the like from
hijacking shared hosts, where an INI_PERDIR setting could potentially
be written to the local account by exploitation of a variety of means
(including, but not limited to, XSS, file inclusion, and SQL injection
techniques).

    While it may seem a bit of a hassle to need to take this extra
step, we all agree that Felipe has done this with the best interests
of the community at heart.  Having seen the substitutions of 'r' for
'are' and 'u' for 'you' (among many others), he has single-handedly
taken it upon himself to use PHP not only as a tool to assist in
technological projects, but as a means to teach proper spelling,
grammar, and even punctuation to the world (in PHP 7, semicolons will
be replaced by commas, periods, and question marks, as appropriate).

    To learn more about his efforts, go to
http://ca2.php.net/spelling-enforcement.php

-- 
</Daniel P. Brown>
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

--- End Message ---
--- Begin Message ---
On 1/11/2011 7:35 PM, David McGlone wrote:
Hi Everyone, I'm having a problem validating some links I have in a foreach.
Here is my code:
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd";>

my PHP code:
$categorys = array('home', 'services', 'gallery', 'about_us', 'contact_us',
'testimonials');
foreach($categorys as $category){
$replace = str_replace("_", " ", $category);
echo "<li><a href='index.php?page=$category'>$replace</a></li>";

Try this instead

echo '<li><a href="index.php?page=',$category,'">',$replace,'</a></li>';

Jim Lucas

}

Validator Error:
an attribute value must be a literal unless it contains only name characters

…ome>home</a></li><li><a href=index.php?page=services>services</a></li><li><a
h…

I have tried various combinatons and different doctypes. I'm beginning to
wonder if this code is allowed at all.




--- End Message ---

Reply via email to