|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general-digest-help
lists.php.net
Date: Tue May 13 2008 - 14:15:24 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 13 May 2008 19:15:24 -0000 Issue 5457
Topics (messages 274227 through 274266):
Re: tracking Mials Which were bounced.
274227 by: Aschwin Wesselius
274228 by: mike
274244 by: Per Jessen
Re: A Little Something.
274229 by: Peter Ford
274232 by: Stut
274233 by: Robin Vickery
274234 by: Stut
274238 by: Robin Vickery
274246 by: tedd
274252 by: Shawn McKenzie
274253 by: Daniel Brown
274262 by: tedd
274263 by: Thiago Pojda
274265 by: Robert Cummings
Re: Good HTML parser needed
274230 by: James Dempster
274235 by: Per Jessen
calling rsync from php script
274231 by: Jean-Christophe Roux
274247 by: Daniel Brown
Scripts slowing down?
274236 by: René Leboeuf
274237 by: Per Jessen
274239 by: Peter Ford
274243 by: Thiago Pojda
Re: convert query result to array
274240 by: Sanjeev N
Re: Replacing accented characters by non-accented characters
274241 by: Per Jessen
Re: Permissions set on php script question
274242 by: Bojan Tesanovic
Re: using variable in php form before the form is POSTed
274245 by: tedd
validating textarea using php
274248 by: Sudhakar
274249 by: Thijs Lensselink
274250 by: Richard Heyes
274251 by: Warren Vail
274254 by: Thiago Pojda
274256 by: Hiep Nguyen
274258 by: Usamah al-Amin
274259 by: Dan Joseph
274260 by: Jim Lucas
274261 by: Robert Cummings
Can Safari 3 be forced to cache a large jpeg with PHP headers?
274255 by: Rob Gould
Re: Why doesn't working with array's ever stick in my thick head?
274257 by: Jason Pruim
$_SESSION NOT WORKING
274264 by: Balpo
274266 by: Dmitri
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Chetan Rane wrote:
> Hi All
>
> I am using a PHP Mailer to send mass mails.
> How can I Identify how mails have bounced.
>
Hi,
I guess you have to read some RFC's to get an idea about e-mail protocols.
--
Aschwin Wesselius
/'What you would like to be done to you, do that to the other....'/
attached mail follows:
Seems like the general way is to create a mailbox (POP3 or IMAP) to
accept the bounces, then check it periodically and mark the emails as
invalid in your local database.
I would set threshholds so you don't mark something failed that only
bounced once - it could have been a mail setup error or something
else; I'd say wait for 3 failures in a 7 day period at least. If you
get 3 bounces by that point, the address is probably safely dead.
You can use PHP's IMAP functions to check the mailbox (even for POP3)
or a million classes or your own functions directly on the socket
(POP3 is a simple protocol) - it also helps if you parse the bounced
email message to process the return address and the mail code; perhaps
build something better than just 3 failures = invalid, but actually
determine if they're full out failures, or if they're just temporary
bounces, etc.
Another method: you could just parse mail logs, if you have access to them.
> Chetan Rane wrote:
> > Hi All
> >
> > I am using a PHP Mailer to send mass mails.
> > How can I Identify how mails have bounced.
attached mail follows:
Chetan Rane wrote:
> Hi All
>
> I am using a PHP Mailer to send mass mails.
> How can I Identify how mails have bounced.
>
You send them with a bounce-address that uniquely identifies the
recipient - when the email bounces, you know exactly which recipient it
was. I typically have my mailserver do a quick database update to set
a status for such bounces.
/Per Jessen, Zürich
attached mail follows:
tedd wrote:
> At 3:11 PM -0400 5/12/08, Eric Butera wrote:
>>
>> NoScript is a FireFox extension to protect users from malicious
>> scripts.
>
> NoScript is also a tag for browsers to read and react to IF they do not
> accept javascript.
>
> http://www.w3schools.com/TAGS/tag_noscript.asp
>
> That's an unfortunate naming convention from FireFox.
>
> https://addons.mozilla.org/en-US/firefox/addon/722
>
>> JS is indeed very dangerous right now especially as mashups
>> continue to gain popularity and all of that personal information
>> floating around. Subscribe to planet websecurity and see the truth.
>>
>> The way I deal with urchin is by /etc/hosts'ing out google's
>> adservers. Then we all win, right? ;)
>>
>> Here is a fairly current rant:
>> http://blog.360.yahoo.com/blog-TBPekxc1dLNy5DOloPfzVvFIVOWMB0li?p=819
>
>
> Okay, I read that -- but what does that have to do with urchin?
>
> Urchin is not an ad delivery system, but rather a way to keep track of
> visitors to your web site.
>
> Now, how is that a security threat? Or is the claim that any site that
> uses js is a security threat?
>
> Cheers,
>
> tedd
>
tedd,
I don't expect anyone to second-guess pet peeves :)
And, as you say, Urchin is not your code: I think the onus is on the coders of
Urchin to document how to avoid errors when Javascript is disabled, not the site
developer who uses it.
Some of us are extremely cautious about how we expose our systems to unknowns.
As far as I can tell, Urchin does me no favours so I don't need to allow it in.
In addition, I might not want a site to know where I am or where I came from:
that is a (very mild) form of surveillance.
On a more rebellious note, I actively try to confound any attempts to target
advertising at me - I hate all forms of advertising (except the really clever TV
ads that make me laugh) and tend to choose what products I buy based on my own
research, rather than what a marketing droid thinks I need to buy.
Anyway, this is waaaaaaay off-topic: it was right from the start - sorry everyone :(
I'll keep my pet peeves private from now on ...
Cheers
Pete
--
Peter Ford phone: 01580 893333
Developer fax: 01580 893399
Justcroft International Ltd., Staplehurst, Kent
attached mail follows:
On 13 May 2008, at 09:04, Peter Ford wrote:
> I think the onus is on the coders of Urchin to document how to avoid
> errors when Javascript is disabled, not the site developer who uses
> it.
Just to repeat a point I made yesterday which was clearly either
misunderstood or ignored... Urchin *will not* cause Javascript errors
if Javascript is disabled. Odd though it may seem, it's actually not
possible to write Javascript code that will cause Javascript errors if
Javascript is disabled.
If you choose to use an addon that disables some Javascript but not
all of it you need to be willing to live with the errors that may
cause. It's like expecting something to run on Windows after you've
removed user.dll - it's not a reasonable expectation.
-Stut
--
http://stut.net/
attached mail follows:
2008/5/13 Stut <stuttle
gmail.com>:
> On 13 May 2008, at 09:04, Peter Ford wrote:
>
> > I think the onus is on the coders of Urchin to document how to avoid
> errors when Javascript is disabled, not the site developer who uses it.
> >
>
> Just to repeat a point I made yesterday which was clearly either
> misunderstood or ignored... Urchin *will not* cause Javascript errors if
> Javascript is disabled. Odd though it may seem, it's actually not possible
> to write Javascript code that will cause Javascript errors if Javascript is
> disabled.
>
> If you choose to use an addon that disables some Javascript but not all of
> it you need to be willing to live with the errors that may cause.
While I completely agree with everything you say there, I do think there is a
point to the other side side of the argument as well; It *is* sloppy
practice to
assume that some resource has already been initialised without checking,
especially when you're relying on a third-party script.
This is a pretty trivial case, but it is a really good habit to get into.
-robin
attached mail follows:
On 13 May 2008, at 10:32, Robin Vickery wrote:
> 2008/5/13 Stut <stuttle
gmail.com>:
>> On 13 May 2008, at 09:04, Peter Ford wrote:
>>
>>> I think the onus is on the coders of Urchin to document how to avoid
>> errors when Javascript is disabled, not the site developer who uses
>> it.
>>>
>>
>> Just to repeat a point I made yesterday which was clearly either
>> misunderstood or ignored... Urchin *will not* cause Javascript
>> errors if
>> Javascript is disabled. Odd though it may seem, it's actually not
>> possible
>> to write Javascript code that will cause Javascript errors if
>> Javascript is
>> disabled.
>>
>> If you choose to use an addon that disables some Javascript but not
>> all of
>> it you need to be willing to live with the errors that may cause.
>
> While I completely agree with everything you say there, I do think
> there is a
> point to the other side side of the argument as well; It *is* sloppy
> practice to
> assume that some resource has already been initialised without
> checking,
> especially when you're relying on a third-party script.
I agree to a certain extend, but the Javascript spec specifies that
it's executed in the order it's found on the page. So if you include
an external file before calling the code it contains it's perfectly
acceptable to assume that code has already been included, parsed and
is available to you. Given that fact, checking for the existence of
such things is a waste of CPU cycles, something that Javascript
developers should never assume are available in abundance.
-Stut
--
http://stut.net/
attached mail follows:
2008/5/13 Stut <stuttle
gmail.com>:
>
> On 13 May 2008, at 10:32, Robin Vickery wrote:
>
> > 2008/5/13 Stut <stuttle
gmail.com>:
> >
> > > On 13 May 2008, at 09:04, Peter Ford wrote:
> > >
> > >
> > > > I think the onus is on the coders of Urchin to document how to avoid
> > > >
> > > errors when Javascript is disabled, not the site developer who uses it.
> > >
> > > Just to repeat a point I made yesterday which was clearly either
> > > misunderstood or ignored... Urchin *will not* cause Javascript errors if
> > > Javascript is disabled. Odd though it may seem, it's actually not
> possible
> > > to write Javascript code that will cause Javascript errors if Javascript
> is
> > > disabled.
> > >
> > > If you choose to use an addon that disables some Javascript but not all
> of
> > > it you need to be willing to live with the errors that may cause.
> > >
> >
> > While I completely agree with everything you say there, I do think there
> is a
> > point to the other side side of the argument as well; It *is* sloppy
> > practice to
> > assume that some resource has already been initialised without checking,
> > especially when you're relying on a third-party script.
> >
>
> I agree to a certain extend, but the Javascript spec specifies that it's
> executed in the order it's found on the page. So if you include an external
> file before calling the code it contains it's perfectly acceptable to assume
> that code has already been included, parsed and is available to you.
There's so many things that are out of your control when you include a
third-party script that could stop it loading; misconfigured servers
on their end, network outages, corporate firewalls blocking their
server, etc. You can't stop any of that. But you can check for it very
simply.
But hey, we basically agree. So I'm going to stop there, before I
start getting too involved in arguing the point.
-robin
attached mail follows:
At 9:04 AM +0100 5/13/08, Peter Ford wrote:
>I don't expect anyone to second-guess pet peeves :)
Why not? That's the way things change.
I still haven't had anyone address the concerns I posted. Instead, I
feel like a kid watching two others play a game of "keep-a-way" with
me in the middle.
No big deal -- I'll just conclude that urchin isn't a security
problem and there is nothing I can do about the warnings it generates.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
Stut wrote:
> On 12 May 2008, at 09:39, Peter Ford wrote:
>> tedd wrote:
>>> Hi gang:
>>> This is what I did this morning:
>>> http://webbytedd.com/bb/tribute/
>>> It speaks for itself.
>>> Cheers,
>>> tedd
>>
>> tedd,
>>
>> Nothing to do with the subject matter, but I noticed because it is one
>> of your more simple pages: I get a JS "urchinTracker() not defined"
>> error on your site, almost certainly because NoScript is blocking
>> UrchinTracker...
>>
>> Perhaps you should wrap that naked call to urchinTracker() in a
>> conditional - maybe as simple as
>>
>> if (urchinTracker) urchinTracker();
>>
>> <pet-peeve>
>> I really hate seeing JS errors on published sites (i.e. not
>> development sandboxes)
>> </pet-peeve>
>>
>> 'course, there are many sites that make the same call to
>> urchinTracker(), and many many worse errors...
>
> I see your pet peeve and I'll raise you one of mine...
>
> <pet-peeve>
> People who use Javascript blockers, especially Javascript blockers that
> do a half-arsed job which causes errors.
> </pet-peeve>
>
> If you're going to block Javascript, block it. Don't use something that
> tries (and apparently fails) to block it intelligently.
>
> What are you so afraid of?
>
> -Stut
>
My main pet peeve is when my wife leaves empty clothes hangers on door
knobs throughout the house.
-Shawn
attached mail follows:
On Tue, May 13, 2008 at 10:55 AM, Shawn McKenzie <nospam
mckenzies.net> wrote:
> >
> My main pet peeve is when my wife leaves empty clothes hangers on door
> knobs throughout the house.
Mine is when the pre-wife leaves her clothes on. So we're pretty similar.
--
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.
attached mail follows:
At 11:01 AM -0400 5/13/08, Daniel Brown wrote:
>On Tue, May 13, 2008 at 10:55 AM, Shawn McKenzie <nospam
mckenzies.net> wrote:
>> >
>> My main pet peeve is when my wife leaves empty clothes hangers on door
>> knobs throughout the house.
>
> Mine is when the pre-wife leaves her clothes on. So we're pretty similar.
I think I'll name my next pet "Peeve".
That reminds me that my daughter, when she was a teenager, named our
cat "Meow". Our neighbors all thought I had lost my mind when I was
outside calling the cat.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
> Our neighbors all thought I had lost my mind
If they only knew you lost it long ago... ;)
Atenciosamente,
www.softpartech.com.br
Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
thiago.pojda
softpartech.com.br
Excelência em Softwares Financeiros
-----Mensagem original-----
De: tedd [mailto:tedd.sperling
gmail.com]
Enviada em: terça-feira, 13 de maio de 2008 15:03
Para: php-general
lists.php.net
Assunto: Re: [PHP] Re: A Little Something.
At 11:01 AM -0400 5/13/08, Daniel Brown wrote:
>On Tue, May 13, 2008 at 10:55 AM, Shawn McKenzie <nospam
mckenzies.net>
wrote:
>> >
>> My main pet peeve is when my wife leaves empty clothes hangers on door
>> knobs throughout the house.
>
> Mine is when the pre-wife leaves her clothes on. So we're pretty
similar.
I think I'll name my next pet "Peeve".
That reminds me that my daughter, when she was a teenager, named our
cat "Meow". Our neighbors all thought I had lost my mind when I was
outside calling the cat.
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
attached mail follows:
On Tue, 2008-05-13 at 15:22 -0300, Thiago Pojda wrote:
> > Our neighbors all thought I had lost my mind
>
> If they only knew you lost it long ago... ;)
>
> Atenciosamente,
>
> www.softpartech.com.br
I tried to hear your website... my screen reader had a lot of trouble :|
;)
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
attached mail follows:
http://htmlpurifier.org/
--
/James
On Tue, May 13, 2008 at 4:34 AM, Shelley <myphplist
gmail.com> wrote:
> Hi all,
>
> The fact is that I have a site that allow users to post hypertext
> articles.
> However, I saw that sometimes, because of their careless input,
> the articles is not rendered correctly.
>
> I want to know whether there are some good HTML parsers written in PHP.
>
> That is,
> the parser checks whether html tags like table, tr, td, div, dt, dl, dd,
> script, ul,
> li, span, h1, h2, etc. are nested correctly. If any tags not matched, just
> remove them.
>
> Any suggection is greatly appreciated.
>
> --
> Regards,
> Shelley
>
attached mail follows:
Shelley wrote:
> I want to know whether there are some good HTML parsers written in
> PHP.
>
> That is,
> the parser checks whether html tags like table, tr, td, div, dt, dl,
> dd, script, ul, li, span, h1, h2, etc. are nested correctly.
> If any tags not matched, just remove them.
Except for the last part, any XML parser will do. Sablotron, xalan,
libxsl etc.
/Per Jessen, Zürich
attached mail follows:
Hello,
I have a bash script update.sh that contains:
rsync -- delete -avz -e ssh ${files} root
64.XXX:/red
when I use that script ./update.sh as root, it works like a charm as I set up the private/public key properly.
When run from a php script through the apache webserver
<?php
exec("update.sh");
?>
The rsync line is ignored.
I understand that the php script is called under the apache user, when the private/public key is for my root user. How can I set the the keys so that the apache user can run fully the php script?
More generally, how do php users handles the ssh private/public keys when calling rsync?
Thank you
attached mail follows:
On Tue, May 13, 2008 at 4:32 AM, Jean-Christophe Roux <jcxxr
yahoo.com> wrote:
> Hello,
>
> I have a bash script update.sh that contains:
> rsync -- delete -avz -e ssh ${files} root
64.XXX:/red
> when I use that script ./update.sh as root, it works like a charm as I set up the private/public key properly.
> When run from a php script through the apache webserver
> <?php
> exec("update.sh");
> ?>
> The rsync line is ignored.
You could use a combination of BASh and Expect shell code here,
but it wouldn't be very secure, because that would automate the root
login.
> I understand that the php script is called under the apache user, when the private/public key is for my root user. How can I set the the keys so that the apache user can run fully the php script?
> More generally, how do php users handles the ssh private/public keys when calling rsync?
Generate keys for `nobody` or `apache` (whatever user as which
Apache is being executed). Alternatively, install phpSuExec, Suhosin,
or suPHP so that the scripts are run as the user for which they were
called.
--
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.
attached mail follows:
Hi.
I'm running a large website. I have some mailing scripts that take days
to run.
I noticed these scripts slow down with time, sometimes going to an
almost complete stop (no mail sent for several minutes).
The source code is trivial and can't contain a loop. I monitored the
memory usage and couldn't find a memory leak. Using APD, most of the
time is reported to be spent in the fgets() function (script waiting for
a sendmail reply). But sendmail still replies swiftly when this problem
occurs.
Restarting sendmail has no effect on these scripts. Restarting the
scripts makes them run like hell for some hours, until the problem rises
again.
I'm using PHP 5.2.5
I don't know where to look next for the source of this problem...
attached mail follows:
René Leboeuf wrote:
> I'm running a large website. I have some mailing scripts that take
> days to run.
>
> I noticed these scripts slow down with time, sometimes going to an
> almost complete stop (no mail sent for several minutes).
>
> The source code is trivial and can't contain a loop. I monitored the
> memory usage and couldn't find a memory leak. Using APD, most of the
> time is reported to be spent in the fgets() function (script waiting
> for a sendmail reply). But sendmail still replies swiftly when this
> problem occurs.
It sounds like you are using SMTP to talk directly to your sendmail
daemon?
> Restarting sendmail has no effect on these scripts. Restarting the
> scripts makes them run like hell for some hours, until the problem
> rises again.
So, if there is no loop in your script, what _does_ it contain?
/Per Jessen, Zürich
attached mail follows:
René Leboeuf wrote:
> Hi.
>
> I'm running a large website. I have some mailing scripts that take days
> to run.
>
> I noticed these scripts slow down with time, sometimes going to an
> almost complete stop (no mail sent for several minutes).
>
> The source code is trivial and can't contain a loop. I monitored the
> memory usage and couldn't find a memory leak. Using APD, most of the
> time is reported to be spent in the fgets() function (script waiting for
> a sendmail reply). But sendmail still replies swiftly when this problem
> occurs.
By this, I guesss you mean that other connections to sendmail reply swiftly: so
the server is not just jamming up completely and refusing requests ?
It might depend on the exact implementation of 'sendmail': for example, the
Courier mail system which I use replaces the program 'sendmail' with it's own
binary to do the job.
Courier also has a 'tar-pitting' feature which is triggered by behaviour that
looks like a spammer is trying to relay stuff: it atificially slows the response
to the send requests if there is an unreasonably high rate of requests coming
from a given source. At least that's how I understand the feature to work.
Other mail system may implement a similar feature - it might just be that your
mailing script looks like a spam engine to the mail server.
>
> Restarting sendmail has no effect on these scripts. Restarting the
> scripts makes them run like hell for some hours, until the problem rises
> again.
>
> I'm using PHP 5.2.5
>
> I don't know where to look next for the source of this problem...
I think you need to provide some more detail - you could start by explaining
what method you use to send the messages. The next thing to do is to look at the
mail logs and see if there are any messages written around the time that yourt
script runs.
Don't always assume that it is your code that is wrong (that's what managers are
for)
--
Peter Ford phone: 01580 893333
Developer fax: 01580 893399
Justcroft International Ltd., Staplehurst, Kent
attached mail follows:
I don't know... this looks like some mail server is greylisting¹ your
connections and you have to wait to deliver this message and make more
connections to it.
As Peter said, probably your mail server is looking like a spam engine.
1 - Greylisting puts your email in a queue and tells you have to ask again
to send it in X minutes. It's great for blocking spam, as they send only
once and forget about it. The amount of time to wait is configurable,
perhaps a admin set it too high.
Atenciosamente,
www.softpartech.com.br
Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
thiago.pojda
softpartech.com.br
Excelência em Softwares Financeiros
-----Mensagem original-----
De: Peter Ford [mailto:pete
justcroft.com]
Enviada em: terça-feira, 13 de maio de 2008 07:42
Para: php-general
lists.php.net
Assunto: [PHP] Re: Scripts slowing down?
René Leboeuf wrote:
> Hi.
>
> I'm running a large website. I have some mailing scripts that take days
> to run.
>
> I noticed these scripts slow down with time, sometimes going to an
> almost complete stop (no mail sent for several minutes).
>
> The source code is trivial and can't contain a loop. I monitored the
> memory usage and couldn't find a memory leak. Using APD, most of the
> time is reported to be spent in the fgets() function (script waiting for
> a sendmail reply). But sendmail still replies swiftly when this problem
> occurs.
By this, I guesss you mean that other connections to sendmail reply swiftly:
so
the server is not just jamming up completely and refusing requests ?
It might depend on the exact implementation of 'sendmail': for example, the
Courier mail system which I use replaces the program 'sendmail' with it's
own
binary to do the job.
Courier also has a 'tar-pitting' feature which is triggered by behaviour
that
looks like a spammer is trying to relay stuff: it atificially slows the
response
to the send requests if there is an unreasonably high rate of requests
coming
from a given source. At least that's how I understand the feature to work.
Other mail system may implement a similar feature - it might just be that
your
mailing script looks like a spam engine to the mail server.
>
> Restarting sendmail has no effect on these scripts. Restarting the
> scripts makes them run like hell for some hours, until the problem rises
> again.
>
> I'm using PHP 5.2.5
>
> I don't know where to look next for the source of this problem...
I think you need to provide some more detail - you could start by explaining
what method you use to send the messages. The next thing to do is to look at
the
mail logs and see if there are any messages written around the time that
yourt
script runs.
Don't always assume that it is your code that is wrong (that's what managers
are
for)
--
Peter Ford phone: 01580 893333
Developer fax: 01580 893399
Justcroft International Ltd., Staplehurst, Kent
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
fetchAll() works if php version is greater than 5.
As Wang suggested, we should write our own function.
its easy... i have done so many times for larger database.
Store earch rows of the resultset in the array (multidimensional ie. 2). and
then work on the array using the loops & conditions
$query = "select * from tablename";
$result = mysql_query($query);
while($arr = somefunction($result)){
$resultarray[] = $arr;
}
Hope it works!
On 5/13/08, Forcey <forcey
gmail.com> wrote:
>
> I guess PDOStatement::fetchAll() should work?
>
> see http://www.php.net/manual/en/pdostatement.fetchall.php for details.
>
>
> - Forcey
>
>
> On Tue, May 13, 2008 at 9:55 AM, Yi Wang <wangyi6854
gmail.com> wrote:
> > I think flance's meaning is whether there is a build-in function that
> > can convert the result set to an array.
> >
> > The short answer is: do it yourself.
> >
> >
> >
> > On 5/12/08, Stut <stuttle
gmail.com> wrote:
> > > On 12 May 2008, at 15:56, It flance wrote:
> > >
> > > > is there any function that can convert the result of query to an
> > > associative array?
> > > >
> > > > what i want is the following:
> > > >
> > > > $query = "select * from tablename";
> > > > $result = mysql_query($query);
> > > > $arr = somefunction($result);
> > > >
> > > > where $arr should be an assoiative array whose indices have the
> same name
> > > as the fields names of table tablename.
> > > >
> > >
> > > http://php.net/mysql_fetch_assoc
> > >
> > > Please please please read the manual: http://php.net/mysql
> > >
> > > -Stut
> > >
> > > --
> > > http://stut.net/
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
> >
> > --
> > Regards,
> > Wang Yi
> >
> >
> >
> > --
> > 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
>
>
--
Regards,
Sanjeev
http://www.sanchanworld.com | http://webdirectory.sanchanworld.com - submit
your site
attached mail follows:
Yannick Warnier wrote:
> That would probably work out if it wasn't too dependent on the locales
> to work. I'm developing an open-source product which could end up on a
> server without the locales for French but be used by some French
> people, which would make (as far as I can get out of one comment from
> Richie in the PHP manual) the transliteration somewhat wrong.
With the kind of rough conversion/transformation you're doing, is the
locale really very important anyway?
/Per Jessen, Zürich
attached mail follows:
If your web-server is setup to read files with .php extension
through PHP engine (it is I guess)
than no body from outside (using HTTP) can't read content of
original PHP file only the output of that particular script.
The only concern you may have is that somebody else on that server
can read that file.
Eg anybody who can login to server can read all your files with
permission set to read on 'other'
On May 12, 2008, at 11:37 PM, David Jourard wrote:
> Bojan Tesanovic wrote:
>>
>> Heh you are really new to Linux
>>
>> permissions on linux are set per user/group/other bases
>>
>> so for most secure set permissions to read only for web-server user
>> so
>> chown 'webserveruser' file.php
>> chmod 400 file.php
>>
>> make sure you have root access at server so you can change that file
>>
>> or make a group for web-server as your group and set read
>> permissions on group level
>> chmod 440 file.php
>>
> Thank-you
>
> But most web sites are virtually hosted and do not have root access
> to set this up.
>
> Most people just take the package and install with default masks.
>
> So again I ask:
>
> Are there are any security concerns when the read permission
> is set on other. ie Couldn't one write a program to remotely read
> the contents of the file.
>
> Wouldn't it be better if the read permission was set for
> user only and the php engine
> could run the program as user like one can do for cgi using suEXEC.
>
> Again thanks
>
> David J.
>
Bojan Tesanovic
http://www.carster.us/
attached mail follows:
At 2:44 PM -0700 5/12/08, milt wrote:
>I have a form that will be filled in by the user, I want to have access to
>the content of one of the fields in that form, in order to fill in an
>another variable that is not part of the form. this variable is used by a
>routine when the form is "posted". Question - is the $_post[field name]
>availble before the submit button is pushed, or is there another way to get
>the contents of the field?
>thanks, Milt
Use hidden, such as:
<input type="hidden" name="step" value="1">
After the form is posted, $_POST['step'] will = 1.
I use this technique all the time so that I can use the same script
to present different forms based upon which step in the form
processing the user is on (i.e., step=1, step=2, step=3 and so on).
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
hi
i need to validate textarea of a html form using php
<textarea name="comments" cols="26" rows="3" id="comments"><?php
echo($comments);?></textarea>
presently my php code to validate the text area is
if($comments == "" )
{
$error.="<br>Please enter your comments";
}
with this code if a user hits the space bar once or couple of times as a
matter of fact there are no characters entered by the user i do not want
this to happen, if a user simply hits the spacebar and does not type
anything i should be able to display an alert message.
please advice how i can change the above php code.
thanks.
attached mail follows:
Quoting Sudhakar <sudhakararaog
gmail.com>:
> hi
>
> i need to validate textarea of a html form using php
>
> <textarea name="comments" cols="26" rows="3" id="comments"><?php
> echo($comments);?></textarea>
>
> presently my php code to validate the text area is
>
> if($comments == "" )
> {
> $error.="<br>Please enter your comments";
> }
>
> with this code if a user hits the space bar once or couple of times as a
> matter of fact there are no characters entered by the user i do not want
> this to happen, if a user simply hits the spacebar and does not type
> anything i should be able to display an alert message.
>
> please advice how i can change the above php code.
PHP is sevrer sided. So if you want to check if a user provided the
textarea with input. You have to submit the page. and let PHP do the magic.
If the textarea is not filled. You could send the user back to the form.
With an apropriat warning message.
It's probably easier to do it with client side javascript.
Check the contents of the textarea on submit and preform some actions
from there.
attached mail follows:
> i need to validate textarea of a html form using php
>
> <textarea name="comments" cols="26" rows="3" id="comments"><?php
> echo($comments);?></textarea>
You really should use htmlspecialchars before showing any user
stipulated HTML to help prevent security holes. Also you can use short
tags (popular...) to make the HTML more readable. Eg:
<textarea name="comments" cols="26" rows="3" id="comments">
<?=htmlspecialchars($comments)?>
</textarea>
> presently my php code to validate the text area is
>
> if($comments == "" )
You should not rely on register_globals, and use either $_GET or $_POST
instead depending on which methoed to send your form details back to the
server. Eg:
if($_POST['comments'] == '' ) {
...
}
> with this code if a user hits the space bar once or couple of times as a
> matter of fact there are no characters entered by the user i do not want
> this to happen, if a user simply hits the spacebar and does not type
> anything i should be able to display an alert message.
You can use the trim() function to determine whether a variable is just
whitespace.
$comments = trim($_POST['comments']);
if ($comments == '') {
// Show error message
}
--
Richard Heyes
+----------------------------------------+
| Access SSH with a Windows mapped drive |
| http://www.phpguru.org/sftpdrive |
+----------------------------------------+
attached mail follows:
> > with this code if a user hits the space bar once or couple
> of times as
> > a matter of fact there are no characters entered by the
> user i do not
> > want this to happen, if a user simply hits the spacebar and
> does not
> > type anything i should be able to display an alert message.
One thing you might consider is, first of all, there are many characters
which do not print and spaces are one of them, but from a computer
standpoint they are characters, tabs and new lines are some others, the list
goes on.
For this specific case you can trim the results and that often will
eliminate most of these if they appear at either end of what was typed, in
this case the entire thing.
If(trim($_POST["textareaname"]) == "") echo "You didn't type anything
significant!";
HTH,
Warren Vail
attached mail follows:
> You really should use htmlspecialchars before showing any user
> stipulated HTML to help prevent security holes. Also you can use short
> tags (popular...) to make the HTML more readable. Eg:
<snip>
> <?=htmlspecialchars($comments)?>
Just to add, short tags are not recommended for conflicts with XMLs. Use
<?php echo $htmlspecialchars($comments)?> instead.
Atenciosamente,
www.softpartech.com.br
Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
thiago.pojda
softpartech.com.br
Excelência em Softwares Financeiros
-----Mensagem original-----
De: Richard Heyes [mailto:richardh
phpguru.org]
Enviada em: terça-feira, 13 de maio de 2008 11:45
Para: Sudhakar
Cc: php-general
lists.php.net
Assunto: Re: [PHP] validating textarea using php
> i need to validate textarea of a html form using php
>
> <textarea name="comments" cols="26" rows="3" id="comments"><?php
> echo($comments);?></textarea>
You really should use htmlspecialchars before showing any user
stipulated HTML to help prevent security holes. Also you can use short
tags (popular...) to make the HTML more readable. Eg:
<textarea name="comments" cols="26" rows="3" id="comments">
<?=htmlspecialchars($comments)?>
</textarea>
> presently my php code to validate the text area is
>
> if($comments == "" )
You should not rely on register_globals, and use either $_GET or $_POST
instead depending on which methoed to send your form details back to the
server. Eg:
if($_POST['comments'] == '' ) {
...
}
> with this code if a user hits the space bar once or couple of times as a
> matter of fact there are no characters entered by the user i do not want
> this to happen, if a user simply hits the spacebar and does not type
> anything i should be able to display an alert message.
You can use the trim() function to determine whether a variable is just
whitespace.
$comments = trim($_POST['comments']);
if ($comments == '') {
// Show error message
}
--
Richard Heyes
+----------------------------------------+
| Access SSH with a Windows mapped drive |
| http://www.phpguru.org/sftpdrive |
+----------------------------------------+
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
On Tue, 13 May 2008, Sudhakar wrote:
> hi
>
> i need to validate textarea of a html form using php
>
> <textarea name="comments" cols="26" rows="3" id="comments"><?php
> echo($comments);?></textarea>
>
> presently my php code to validate the text area is
>
> if($comments == "" )
> {
> $error.="<br>Please enter your comments";
> }
>
> with this code if a user hits the space bar once or couple of times as a
> matter of fact there are no characters entered by the user i do not want
> this to happen, if a user simply hits the spacebar and does not type
> anything i should be able to display an alert message.
>
> please advice how i can change the above php code.
>
> thanks.
>
if(chop($comments) == "") { ... } //hope that helps.
attached mail follows:
> if(chop($comments) == "") { ... } //hope that helps.
Well, chop() is an alias of rtrim(), so it won't work here for, say,
trimming control characters at the end of the string like line feeds.
trim() is actually the best bit here.
Regards,
Usamah
attached mail follows:
On Tue, May 13, 2008 at 12:02 PM, Usamah al-Amin <usamah1228
gmail.com>
wrote:
> > if(chop($comments) == "") { ... } //hope that helps.
>
> Well, chop() is an alias of rtrim(), so it won't work here for, say,
> trimming control characters at the end of the string like line feeds.
>
> trim() is actually the best bit here.
>
> Regards,
> Usamah
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
There is always using substr to mimic the Perl chomp() function. Look thru
the comments on http://us.php.net/chop and you'll find a few different ways
of doing it.
--
-Dan Joseph
www.canishosting.com - Plans start
$1.99/month. Reseller plans and
Dedicated servers available.
"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."
attached mail follows:
Richard Heyes wrote:
> Also you can use short
> tags (popular...) to make the HTML more readable. Eg:
>
> <textarea name="comments" cols="26" rows="3" id="comments">
> <?=htmlspecialchars($comments)?>
> </textarea>
>
It also makes the code less portable.
--
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
attached mail follows:
On Tue, 2008-05-13 at 19:02 +0300, Usamah al-Amin wrote:
> > if(chop($comments) == "") { ... } //hope that helps.
>
> Well, chop() is an alias of rtrim(), so it won't work here for, say,
> trimming control characters at the end of the string like line feeds.
>
> trim() is actually the best bit here.
Actually trim() is probably less efficient since both ends of the string
will be examined whereas a string containing entirely whitespace
characters will rtrim() (chop() if you will) to an empty string also but
the second side won't need to be examined (even if only to check for 0
length).
But maybe you didn't realize this because your assertion was wrong in
the first place:
> so it won't work here for, say, trimming control characters at the
> end of the string like line feeds.
When clearly looking at the online documentation for rtrim() we see:
This function returns a string with whitespace stripped from
the end of str .
Without the second parameter, rtrim() will strip these characters:
" " (ASCII 32 (0x20)), an ordinary space.
"\t" (ASCII 9 (0x09)), a tab.
"\n" (ASCII 10 (0x0A)), a new line (line feed).
"\r" (ASCII 13 (0x0D)), a carriage return.
"\0" (ASCII 0 (0x00)), the NUL-byte.
"\x0B" (ASCII 11 (0x0B)), a vertical tab.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
attached mail follows:
I am creating a touch-screen kiosk application, using a full-screen version of Safari 3.1, and was wondering if there's a way I can force Safari to cache a large background image JPEG.
What I'm finding is that Safari 3 will sometimes cache my large 1.1 MB background image (1680x1050), and display perfectly fine, but on occassion Safari 3 will "think about the cache" and Flash the screen white for a millisecond and then draw the screen. Firefox doesn't seem to have this problem, so unfortunately this is a Safari 3 only issue.
I really only want to cache this ONE image - - - nothing else. Is that possible?
attached mail follows:
Hi Everyone,
I am taking another stab at this problem, complete with code and an
example...
Here is the issue:
I need to be able to display pounds and ounces of a given number of
pieces, the code I have does this just fine for a single route... But
what I can't seem to get through my head is how to do it for a
variable number of routes?
Here is the code I'm working with...
<?PHP
//Rural Route Weight Calculator by Jason Pruim 2008
$c = "0";
$num= "1";
//$num = $_POST['txtNum'];
$PieceWeight = $_POST['txtPieceWeight'];
$RoutePieces = $_POST['txtRoutePieces'];
$RouteNumber = $_POST['txtRoute'];
//self submitting forms
$self = $_SERVER['PHP_SELF'];
$totalWeight = ($PieceWeight * $RoutePieces) /16;
$weightExplode = explode('.', $totalWeight);
$weightOunces = ((float)('.' . $weightExplode[0])) * 16;
// Use stut's method... Seems cleaner
$explodeOunces = ($totalWeight - intval($totalWeight)) * 16;
if($_POST) {
echo <<<HTML
<div class="weightbox">
<h1>Weight calculator</h1>
<form method ='post' action='{$self}'>
<p>Weight of a single piece:<input type="text" name="txtPieceWeight"
size="5" value="{$PieceWeight}"></p>
HTML;
while ($c != $num) {
echo <<<HTML
Route Number:<input type="text" name="txtRoute" size="5"
value="{$RouteNumber}"> Number of pieces: <input type="text"
name="txtRoutePieces" value="{$RoutePieces}"size="5"><label>Total
weight of route: {$weightExplode[0]}# {$explodeOunces} Ounces</
label><BR>
HTML;
$c++;
}
echo "<BR><input type='submit' value='Calculate'></form></div>";
//DEBUG
dump_debug($RoutePieces);
dump_debug($RouteNumber);
dump_debug($_POST);
print_debug($explodeOunces);
dump_debug($weightExplode);
//END DEBUG
}else{
echo "<form method='post' action='{$self}'>";
echo "Number of routes: <input type='text' name='txtNum' size='2'><BR>
<input type='submit' value='GO'>";
echo "</form>";
}
?>
The website is: HTTP://www.raoset.com/dev/weightcalc/
I need help! My brain is going to die tonight without it :)
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruim
raoset.com
attached mail follows:
Hi everyone,
I'm having a problem moving my code to a linux computer.
I won't post the whole code here, but an accurate example that
reproduces exactly the error.
//************************ 1.php
<?php
session_register('tree');
$_SESSION['tree'] = "This is tree number one";
header("Location: 2.php");
?>
//************************ 2.php
<?php
print_r($_SESSION, false);
?>
//************************ php.ini (incomplete)
session.save_handler = files
session.save_path = /tmp/php/sessions/ o ;C:/temp/php/sessions for Windows
session.use_cookies = 1
session.name = cito
session.auto_start = 1
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 100
session.gc_maxlifetime = 1440
session.bug_compat_42 = 0
session.bug_compat_warn = 0
session.referer_check =
session.entropy_length = 0
session.entropy_file =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 4
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset="
The web server is Apache 2.2 with php 5.24 for both, Linux & Windows.
In Linux the Apache server is run by the 'apache' user, which has
reading, writing and execution grants on /tmp/php/sessions/
The output for 2.php is:
Array ( [tree] => This is tree number one )
is what I get on Windows, but on Linux I get:
Notice: Undefined variable: _SESSION in /var/www/html/2.php on
line 2
I don't know what the error is, but something evident is that on Linux
session.auto_start = 1 is NOT working properly.
On Windows it is not necessary to explicitly start the session to use
the $_SESSION, so no need to session_start().
If on Linux I add session_start() at the top of each script, the script
executes well.
I want to know why session.auto_start does not work on Linux.
If you require the whole php.ini, I'll send it gladly
attached mail follows:
Try adding session_start() at top of the script
Balpo wrote:
> Hi everyone,
> I'm having a problem moving my code to a linux computer.
> I won't post the whole code here, but an accurate example that
> reproduces exactly the error.
>
> //************************ 1.php
> <?php
> session_register('tree');
> $_SESSION['tree'] = "This is tree number one";
> header("Location: 2.php");
> ?>
>
> //************************ 2.php
> <?php
> print_r($_SESSION, false);
> ?>
>
>
> //************************ php.ini (incomplete)
> session.save_handler = files
> session.save_path = /tmp/php/sessions/ o ;C:/temp/php/sessions for
> Windows
> session.use_cookies = 1
> session.name = cito
> session.auto_start = 1
> session.cookie_lifetime = 0
> session.cookie_path = /
> session.cookie_domain =
> session.cookie_httponly =
> session.serialize_handler = php
> session.gc_probability = 1
> session.gc_divisor = 100
> session.gc_maxlifetime = 1440
> session.bug_compat_42 = 0
> session.bug_compat_warn = 0
> session.referer_check =
> session.entropy_length = 0
> session.entropy_file =
> session.cache_limiter = nocache
> session.cache_expire = 180
> session.use_trans_sid = 0
> session.hash_function = 0
> session.hash_bits_per_character = 4
> url_rewriter.tags =
> "a=href,area=href,frame=src,input=src,form=,fieldset="
>
> The web server is Apache 2.2 with php 5.24 for both, Linux & Windows.
> In Linux the Apache server is run by the 'apache' user, which has
> reading, writing and execution grants on /tmp/php/sessions/
>
> The output for 2.php is:
> Array ( [tree] => This is tree number one )
> is what I get on Windows, but on Linux I get:
> Notice: Undefined variable: _SESSION in /var/www/html/2.php on
> line 2
>
> I don't know what the error is, but something evident is that on Linux
> session.auto_start = 1 is NOT working properly.
> On Windows it is not necessary to explicitly start the session to use
> the $_SESSION, so no need to session_start().
> If on Linux I add session_start() at the top of each script, the
> script executes well.
>
> I want to know why session.auto_start does not work on Linux.
>
> If you require the whole php.ini, I'll send it gladly
--
Open Source ALL content management
with streaming video
http://wiki.sharedlog.com
- application/x-pkcs7-signature attachment: S/MIME Cryptographic Signature
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]