php-general Digest 16 Oct 2006 12:41:42 -0000 Issue 4404
Topics (messages 243167 through 243181):
Re: A no brainer...
243167 by: Tony Di Croce
243169 by: Ed Lazor
Month in a numeric form
243168 by: Ron Piggott (PHP)
243170 by: Travis Doherty
243171 by: J R
Re: php - mysql question
243172 by: Chris
Re: PHP causing seg fault
243173 by: Glenn Richmond
Date calculation
243174 by: Ron Piggott (PHP)
243175 by: Travis Doherty
Re: [PEAR] array on addElement, does not work => QuickForm
243176 by: Louie Miranda
Setting PHP to use SMTP
243177 by: Dave M G
243178 by: David Robley
243179 by: Dave M G
243180 by: Chris
connecting host.
243181 by: João Cândido de Souza Neto
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 ---
Wow... well, I was certainly not speaking from direct experience, only from
what seemed to make sense to me. This tells me that their is some serious
room for improvement in PHP de-serialization code...
td
Sorry Tony, I should have been more clear. I already know that
storing session data in MySQL is faster than storing it in files. I
know that goes against what you're saying, but there are some
examples if you Google "PHP MySQL session performance". One of the
more interesting examples is http://shiflett.org/articles/guru-speak-
jan2005. PHP session management defaults to files because it's more
portable and the performance difference doesn't matter for small
sites with few concurrent users. MySQL also provides better
scaleability and security for session data.
On Oct 14, 2006, at 2:51 PM, Larry Garfield wrote:
> It depends on what your data is.
>
> Is your data basic (a few elements in a linear array) or complex (a
> deeply
> nested multi-dimensional array or complex object?) Deserializing a
> complex
> data structure can get expensive.
>
> Is your data built by a single simple query against the database, a
> single but
> very complex query with lots of joins and subqueries, or a bunch of
> separate
> queries over the course of the program? A single SQL query for
> cached data
> is likely faster than lots of little queries.
>
> Is your data something that's going to change every few seconds,
> every few
> minutes, or every few days? Caching something that will change by
> your next
> page request anyway is a waste of cycles.
>
> Is your data needed on every page load? Putting a complex data
> structure into
> the session if you only need it occasionally is a waste of cycles.
> You're
> better off rebuilding it each time or implementing your own caching
> mechanism
> that only loads on demand.
>
> There is no general answer here.
Good points Larry. I have to look back, but I think we were
originally talking about basic user data. ie. the user logs into the
site and we store their login information and access rights in a
session. That seems like basic enough information that it's better
to just store the user id in session data and grab the rest of their
information from the db - not much of a difference in performance,
plus you end up avoiding stale data. Anyway, I like your distinction
between simple and complex objects.
-Ed
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
Publish technical articles @ skilledwords.com and get 100% of the
ad-revenue!
http://www.skilledwords.com
--- End Message ---
--- Begin Message ---
On Oct 15, 2006, at 3:27 PM, Tony Di Croce wrote:
Wow... well, I was certainly not speaking from direct experience,
only from what seemed to make sense to me. This tells me that their
is some serious room for improvement in PHP de-serialization code...
Well, kinda. Hard disks are a lot slower than ram and that gives
file storage a disadvantage. You can setup disk caching to help, but
the OS still starts to lag when you have a lot of files in one
directory, which is what happens with session data files. MySQL
tries to cache data in memory as much as possible. It still uses
files, but hopefully you don't hit them very often, especially when
you're dealing with the same table records. Also, having raw data is
always faster than having to process it before you can use it. Make
sense?
-Ed
--- End Message ---
--- Begin Message ---
Is there a way I am able to use the DATE command to convert January to
1, February to 2, etc.
--- End Message ---
--- Begin Message ---
Ron Piggott (PHP) wrote:
>Is there a way I am able to use the DATE command to convert January to
>1, February to 2, etc.
>
>
>
What is wrong with date()?
www.php.net/date
$month = 'Jan';
$numericMonth = date('m', strtotime("$month 01 2000");
Travis Doherty
--- End Message ---
--- Begin Message ---
http://www.php.net/manual/en/function.strtotime.php
http://www.php.net/manual/en/function.date.php
On 10/16/06, Ron Piggott (PHP) <[EMAIL PROTECTED]> wrote:
Is there a way I am able to use the DATE command to convert January to
1, February to 2, etc.
--
GMail Rocks!!!
--- End Message ---
--- Begin Message ---
Dave Goodchild wrote:
Hi all. I am writing a web app with a mysql back end and there is every
chance one of the tables may have to handle 56+ million records. I am no
mysql expert but has anyone else here ever handled that volume of data, and
if so, any suggestions or caveats? The tables will of course be correctly
indexed and the database normalised.
There's no reason why it can't but the mysql list will be better to ask
(because they could tell you what to do.. eg how much memory, what disks
you should look to get etc to get decent performance).
Even with indexes and normalized data (which in some cases makes
performance worse with all the joins you have to do) you'll need to
tweak your server / settings to get something resembling "reasonable"
performance.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Hi guys,
I'm running Fedora Core 5 - so yes, a red hat system. I'm told it
doesn't happen on FC4 and PHP5.04 though.
I'm definitely not causing an infinite loop directly in the PHP code,
though I agree that it sounds like that. I think that maybe PHP is
getting into a loop internally though as a result of the return call.
Any ideas?
Glenn.
Richard Lynch wrote:
> On Thu, October 12, 2006 3:44 am, Glenn Richmond wrote:
>
>> I'm attempting to run a SugarCRM variant that uses SOAP to access
>> information from the database. The code is causing a seg fault when
>> executing a particular line of code. The code executes properly until
>> it
>> calls a generic function in the parent class that causes a seg fault
>> on
>> the return command. The line of code is:
>>
>> return $this;
>>
>> I've found this to be a problem in PHP version 5.1.4 and 5.2.0rc4. Is
>> this statement illegal in PHP5? When I set a memory limit for the
>> script, the error changes to indicating that it has exceeded its
>> memory
>> allocation, so it seems to be allocating memory over and over.
>>
>> Note that this code runs fine on most other combinations of functions
>> calling this same parent method. Any suggestions are appreciated.
>>
>
> Are you sure you are not causing an infinite loop or a circular data
> reference that PHP is attempting to iterate through?
>
> It sure *sounds* like that might be the case, from the symptoms
> presented.
>
>
--- End Message ---
--- Begin Message ---
I have one more date based question.
I have a month field ( $month ) and a day field ( $day ) being submitted
by a form.
I have a third field to be used as a date reminder for the information
which was submitted as part of the form. It is a reminder to complete a
task for the date was which was submitted as part of the form.
How do I calculate the $reminder date based on $month and $day and have
it output in the YYYY-MM-DD format? $reminder is the number of days
before $month $day (I want to use $reminder in a date format to SELECT
records from a mySQL table) This is why I am wanting put $reminder into
a date format
If $month was 6 and $day was 7 and $reminder was 6 then I would want the
output to be 2007-06-01 --- We have already passed June 1st in 2006.
However if $month was 11 then I would want the output to use this years
date --- 2006-11-01
Any suggestions?
Ron
--- End Message ---
--- Begin Message ---
Ron Piggott (PHP) wrote:
>I have one more date based question.
>
>I have a month field ( $month ) and a day field ( $day ) being submitted
>by a form.
>
>I have a third field to be used as a date reminder for the information
>which was submitted as part of the form. It is a reminder to complete a
>task for the date was which was submitted as part of the form.
>
>How do I calculate the $reminder date based on $month and $day and have
>it output in the YYYY-MM-DD format? $reminder is the number of days
>before $month $day (I want to use $reminder in a date format to SELECT
>records from a mySQL table) This is why I am wanting put $reminder into
>a date format
>
>If $month was 6 and $day was 7 and $reminder was 6 then I would want the
>output to be 2007-06-01 --- We have already passed June 1st in 2006.
>However if $month was 11 then I would want the output to use this years
>date --- 2006-11-01
>
>Any suggestions?
>
>Ron
>
>
>
I think it would be easier to ask the user to enter his reminder in the
standard date format of yyyy-mm-dd and use a JavaScript date picker box
to prompt for it. Anyway, you could do something like this:
$reminderStamp = strtotime("+{$addMonths} months",time());
$reminderStamp = strtoTime("+{$addDays} days",$reminderStamp);
$date = date("Y-m-d",$reminderStamp);
$date should have a string like yyyy-mm-dd that is $addMonths and
$addDays into the future. I didn't test this.
Travis Doherty
--- End Message ---
--- Begin Message ---
Ok thanks a bunch.
On 10/13/06, Ian Warner <[EMAIL PROTECTED]> wrote:
Louie Miranda wrote:
> Now i know. Wow, this is really a great tool.
>
> Can i filter CCexpiry for month and year.. lets say if today is
> october 2006
> and user selected may 2006 (where it should had been expired already).
> Can a
> rule be processed on that directly on quickform?
>
> So far the only rule i got was..
>
> $form->addRule('CCexpiry', 'Please select credit card expiration',
> 'required', null);
Probably I am not too hot on JavaScript. But basically you are saying if
anything is below 200610 then error, that should be quite simple for a
javascript guru to do, I looked at the Compare command but cant see how
that would be used .
http://pear.php.net/manual/en/package.html.html-quickform.intro-validation.php
read here and see
>
> Louie
>
> On 10/13/06, Ian Warner <[EMAIL PROTECTED]> wrote:
>>
>> Louie Miranda wrote:
>> > Whooa!? HAHA, it worked. Wow, thanks a lot. My brains started to
twist
>> on
>> > this awhile ago.
>> > Yeah, that was my problem. I need to add the arrays together.
>> >
>> > Louie
>> Its a good example actually of the power of quickform - now if you
didnt
>> know the date functions then you probably have the month field a little
>> different - combine these into one
>>
>> view the example here:
>>
>> http://wiki.triangle-solutions.com/index.php/PEAR_HTML_QuickForm#Date
>>
>> code for clarity - this will produce month and year select boxes, the
>> key is the format - try and add Y-m-d H:i:s to this - very cool.
>>
>> $defaults['CCexpiry'] =
>> array('m' => date('m')
>> );
>>
>> $form->addElement('date', 'CCexpiry', 'Credit Card Expiration',
>> array('format' => 'F-Y',
>> 'minYear' => date('Y'),
>> 'maxYear' => date('Y') + 10));
>>
>>
>>
>> >
>> > On 10/13/06, Ian Warner <[EMAIL PROTECTED]> wrote:
>> >>
>> >> Louie Miranda wrote:
>> >> > Im trying to add an array of year from addElement, but couldnt get
>> >> what
>> >> i
>> >> > wanted.
>> >> >
>> >> > My code below gets the current year and adds +10 to it and i
>> loop it
>> >> > over an
>> >> > array of $numbers.
>> >> >
>> >> > // Get current year and add +10 more and display on the cc screen.
>> >> >> $date_year = date('Y');
>> >> >> $date_year_nx_7years = ($date_year + 10);
>> >> >>
>> >> >> foreach (range($date_year, $date_year_nx_7years) as $number) {
>> >> >> $num_array = array($number=>$number);
>> >> >> //$num_array++;
>> >> >> }
>> >> No need for all of that: QuickForm has it all:
>> >>
>> >> $form->addElement('date', 'cc_expy', 'Card Expiry (Year)',
>> >> array('format' => 'Y', 'minYear' => date('Y'), 'maxYear' =>
>> date('Y')
>> >> + 10));
>> >>
>> >> You problem was that you were overwriting you array each time
anyway,
>> >> you just had to add the arrays together. But use the above.
>> >> >>
>> >> >> $form->addElement('select', 'cc_expy', 'Card Expiry (Year)',
>> >> >> $num_array);
>> >> >> ..
>> >> >> $form->toHtml()
>> >> >>
>> >> >
>> >> > But when i try to display it over to addElement, i ony see the
last
>> >> year
>> >> > which is "2016". Not the full loop.
>> >> > Does anybody know, how can i get this to work?
>> >> >
>> >> > Thanks a lot.
>> >>
>> >>
>> >
>> >
>>
>>
>
>
--
Louie Miranda ([EMAIL PROTECTED])
http://www.axishift.com
//JSM-W
--- End Message ---
--- Begin Message ---
PHP List,
In an effort to make emails that I send through PHP scripts not be
mistaken for spam, it seems that one thing I need to do is make sure
that the emails are sent via SMTP.
Right now, if I check my PHP generated emails with Spamassassin, it says:
-0.0 NO_RELAYS Informational: message was not relayed via SMTP
It's not deducting points, but I think the fact that it mentions it
indicates I might be better off using SMTP.
Looking at phpinfo, it says this about my PHP/SMTP settings:
sendmail_from no value no value
sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
SMTP localhost localhost
I take this to mean that I don't have a default "from" address, but that
it knows where my SMTP server is.
However, the last variable, where it's set to "localhost", is not so
clear to me. Does this mean PHP is using the SMTP server on localhost?
Does this need to be changed in order for PHP to actually send via SMTP
since it doesn't seem to be doing so now?
Beyond that, I have some follow up questions:
My virtual hosting service is the kind where I have two IP addresses,
and I can add as many domain names as I want to my account. Does that
mean that if I set a default email address in "sendmail_from" that it
will apply to all my domains? Is there a way to localize the setting on
a domain by domain basis? Or is this a question I need to take to my
hosting service provider?
And last... how exactly do I set the variables? Do I have to manually
edit php.ini and then restart Apache? Is there a command I should be
running?
Thank you for any and all advice.
--
Dave M G
Ubuntu 6.06 LTS
Kernel 2.6.17.7
Pentium D Dual Core Processor
PHP 5, MySQL 5, Apache 2
--- End Message ---
--- Begin Message ---
Dave M G wrote:
> PHP List,
>
> In an effort to make emails that I send through PHP scripts not be
> mistaken for spam, it seems that one thing I need to do is make sure
> that the emails are sent via SMTP.
>
> Right now, if I check my PHP generated emails with Spamassassin, it says:
>
> -0.0 NO_RELAYS Informational: message was not relayed via SMTP
>
> It's not deducting points, but I think the fact that it mentions it
> indicates I might be better off using SMTP.
>
> Looking at phpinfo, it says this about my PHP/SMTP settings:
>
> sendmail_from no value no value
> sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
> SMTP localhost localhost
This last item is only applicable under Windows; if you are using *nix
mail() will use whatever sendmail (or sendmail gateway, eg to qmail) is
found when php is compiled. The fact that you have a sendmail_path sortof
suggests you are probably on *nix :-)
The sendmail-from is also a Windows only setting.
>
> I take this to mean that I don't have a default "from" address, but that
> it knows where my SMTP server is.
Again, SMTP server only if you are running Wndows and have an MTA, such as
Mercury, installed. As far as the sender address is concerned, see the
fifth argument to mail() in the docs - this is only relevant under *nix as
there is the Windows sendmail-from setting.
>
> However, the last variable, where it's set to "localhost", is not so
> clear to me. Does this mean PHP is using the SMTP server on localhost?
> Does this need to be changed in order for PHP to actually send via SMTP
> since it doesn't seem to be doing so now?
If you are on *nix and want to send mail via SMTP, you need something like
http://phpmailer.sourceforge.net/ It has provision to set all the sender
type information, send mails with attachments, HTML mail if you wish to
inflict such on others, andd more.
>
> Beyond that, I have some follow up questions:
>
> My virtual hosting service is the kind where I have two IP addresses,
> and I can add as many domain names as I want to my account. Does that
> mean that if I set a default email address in "sendmail_from" that it
> will apply to all my domains? Is there a way to localize the setting on
> a domain by domain basis? Or is this a question I need to take to my
> hosting service provider?
If you are going to use an SMTP class such as phpMailer, you can set this
info on a per-script basis if you so desire, or have a different parent
class with different info for each domain.
> And last... how exactly do I set the variables? Do I have to manually
> edit php.ini and then restart Apache? Is there a command I should be
> running?
>
> Thank you for any and all advice.
Cheers
--
David Robley
IBM: I Buy Macinstosh
Today is Prickle-Prickle, the 70th day of Bureaucracy in the YOLD 3172.
--- End Message ---
--- Begin Message ---
David,
Thank you for your response.
If you are on *nix and want to send mail via SMTP, you need something like
http://phpmailer.sourceforge.net/
I have looked at phpmailer, but it's way over featured for what I want
to accomplish. The tutorial they link to on their site, 11 pages long
and full of settings I don't need, really turns me off.
Is there no way to simply force my PHP emails through SMTP? I'm happy
about everything else with my email set up, so surely there's a way to
handle this one thing.
--
Dave M G
Ubuntu 6.06 LTS
Kernel 2.6.17.7
Pentium D Dual Core Processor
PHP 5, MySQL 5, Apache 2
--- End Message ---
--- Begin Message ---
Dave M G wrote:
David,
Thank you for your response.
If you are on *nix and want to send mail via SMTP, you need something
like
http://phpmailer.sourceforge.net/
I have looked at phpmailer, but it's way over featured for what I want
to accomplish. The tutorial they link to on their site, 11 pages long
and full of settings I don't need, really turns me off.
Is there no way to simply force my PHP emails through SMTP? I'm happy
about everything else with my email set up, so surely there's a way to
handle this one thing.
It's not simple.
Basically you need to:
- open a socket
- send commands through
- check that worked
- check *each* response that comes back
- make sure it's a valid response (from the smtp server)
- send more data
rinse, repeat.
There are tons of checks you need to do at each step and getting the
format of the email, headers and commands right is painful (and even
then it can break depending on the type of server you're going to send
through - windows servers are slightly different to *nix servers even
though they are both supposed to be rfc compliant).
If you really want to do it yourself, the easiest way would be to look
at how phpmailer or something like it handles the process - turn debug
on (I'm sure the docs mention how to do this) and watch the commands fly
(and there are a lot of commands).
My code to do all of that is over 400 lines (but does include debug
statements) - and that's just to send a message through the smtp server
(connect, send the necessary commands, check return codes and so on).
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
I want to know if only i have connection problem with the server.
I cant count how many timnes a dey i get the message cannot connect to host
news.php.net.
It happens to everyone ou just for me?
Thanks.
--
João Cândido de Souza Neto
Curitiba Online
[EMAIL PROTECTED]
(41) 3324-2294 (41) 9985-6894
http://www.curitibaonline.com.br
--- End Message ---