[PHP] Re: Form handling

2009-06-11 Thread Manuel Lemos
Hello,

on 06/10/2009 03:10 PM Eddie Drapkin said the following:
 I've been charged with writing a class that handles forms, once they've been
 POSTed to.  The idea of the class is to handle the most common use-cases of
 POST forms, and any special functionality can be handled with a child class
 at a later date, but for our uses, we're going to have mostly pretty typical
 POST forms.  Follows is the list of cases I've determined that are the most
 common, can anyone think of any that are omitted or that are never going to
 be used?
 
 class form_handler {
 public /* bool */ function setRequiredFields(array $fields); //takes a
 simple array that corresponds to a $_POST key, verifying that there is data
 on required fields but not for optional fields, returns true or false on
 error
 public /* bool */ function setRequiredFieldTypes(array $fieldTypes);
 //array of field names = type a la ('username' = array(regex,
 '/a-zA-Z0-9\-_/'))
 //or 'phone_number' = (array('int', 'min_len' = 7,
 'max_len' = 10)) etc, the exact spec is obviously nowhere near done but
 will probably just wrap a lot of filter_ functions, returns true or false on
 error
 public /* string */ function validateAndCaptureError(); //returns error
 or empty string
 public /* void */ function validateAndForwardTo($page); //forwards to
 page on error, or not
 }
 
 each of the globule setters will have a corresponding appendRequired...
 method, so as not to require handling enormous data structures for
 conditional form building.
 ♦
 As you can see, the class looks pretty barren, but I can't think of any more
 functionality than would be required, although I am kickign the idea around
 of having very specific validation type methods ie.
 form_handler::requireInt($field, array $options) or
 form_handler::requireRegex($field, $regex), etc.
 
 Thoughts?

You may want consider not reinventing the wheel.

I use this popular forms generation and validation class since about 10
years now. It can deal with pretty much all you need now and probably later.

http://www.phpclasses.org/formsgeneration

Here are some live examples of the class and its plug-ins.

http://www.meta-language.net/forms-examples.html

-- 

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] dynamic navigation menu

2009-06-11 Thread web
Please can some one help me with a dynamic menu.

I have a 2 tables and I want to display the record from the first one as
parent  and the second one as the child.

My problem is when I query the data I can't place the child at their
appropriate position. 

Please you help will be appreciated. 



Re: [PHP] dynamic navigation menu

2009-06-11 Thread Ashley Sheridan
On Thu, 2009-06-11 at 09:51 +0200, web wrote:
 Please can some one help me with a dynamic menu.
 
 I have a 2 tables and I want to display the record from the first one as
 parent  and the second one as the child.
 
 My problem is when I query the data I can't place the child at their
 appropriate position. 
 
 Please you help will be appreciated. 
 

Do you have a rough data dump of these two tables, as there's little to
go on otherwise?


Thanks
Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] dynamic navigation menu

2009-06-11 Thread viraj
On Thu, Jun 11, 2009 at 1:21 PM, web d...@italghanaweb.com wrote:

 Please can some one help me with a dynamic menu.

you can accomplish this easily. read about 'recursive functions'



 I have a 2 tables and I want to display the record from the first one as
 parent  and the second one as the child.

use a mysql view or a simple join to join those two tables. then loop
through the result using a recursive function.

~viraj


 My problem is when I query the data I can't place the child at their
 appropriate position.

 Please you help will be appreciated.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Jean-Pierre Arneodo
Hi!
I'm stuck.
I don't understand why the php CLI dies after 3 hours in my script.
Any idea to solve?
Thanks


PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7 2009 
20:06:36)
Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47 UTC 2008 x86_64 
GNU/Linux

Conf [php.ini]
max_execution_time=0

?php
while (true) {
sleep(5);
}
?


  

Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Ashley Sheridan
On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
 Hi!
 I'm stuck.
 I don't understand why the php CLI dies after 3 hours in my script.
 Any idea to solve?
 Thanks
 
 
 PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7 2009 
 20:06:36)
 Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47 UTC 2008 x86_64 
 GNU/Linux
 
 Conf [php.ini]
 max_execution_time=0
 
 ?php
 while (true) {
 sleep(5);
 }
 ?
 
 
   
The while loop will continue executing until its condition is false. As
you've got a boolean true as the condition, it will never end.

Thanks
Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Ford, Mike
On 11 June 2009 12:00, Ashley Sheridan advised:

 On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
 Hi!
 I'm stuck.
 I don't understand why the php CLI dies after 3 hours in my script.
Any
 idea to solve? Thanks
 
 
 PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7
2009
 20:06:36) Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47
UTC
 2008 x86_64 GNU/Linux 
 
 Conf [php.ini]
 max_execution_time=0
 
 ?php
 while (true) {
 sleep(5);
 }
 
 
 
 
 The while loop will continue executing until its condition is false.
As
 you've got a boolean true as the condition, it will never end.

I think he realises that. His question is why never equates to 3 hours
in his environment.

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: m.f...@leedsmet.ac.uk
Tel: +44 113 812 4730


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] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Eddie Drapkin
try set_time_limit(0) ?

On Thu, Jun 11, 2009 at 8:05 AM, Ford, Mike m.f...@leedsmet.ac.uk wrote:

 On 11 June 2009 12:00, Ashley Sheridan advised:

  On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
  Hi!
  I'm stuck.
  I don't understand why the php CLI dies after 3 hours in my script.
 Any
  idea to solve? Thanks
 
 
  PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7
 2009
  20:06:36) Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47
 UTC
  2008 x86_64 GNU/Linux
 
  Conf [php.ini]
  max_execution_time=0
 
  ?php
  while (true) {
  sleep(5);
  }
 
 
 
 
  The while loop will continue executing until its condition is false.
 As
  you've got a boolean true as the condition, it will never end.

 I think he realises that. His question is why never equates to 3 hours
 in his environment.

 Cheers!

 Mike

  --
 Mike Ford,  Electronic Information Developer,
 C507, Leeds Metropolitan University, Civic Quarter Campus,
 Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
 Email: m.f...@leedsmet.ac.uk
 Tel: +44 113 812 4730


 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] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Robert Cummings

Ford, Mike wrote:

On 11 June 2009 12:00, Ashley Sheridan advised:


On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:

Hi!
I'm stuck.
I don't understand why the php CLI dies after 3 hours in my script.

Any

idea to solve? Thanks


PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7

2009

20:06:36) Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47

UTC
2008 x86_64 GNU/Linux 


Conf [php.ini]
max_execution_time=0

?php
while (true) {
sleep(5);
}



The while loop will continue executing until its condition is false.

As

you've got a boolean true as the condition, it will never end.


I think he realises that. His question is why never equates to 3 hours
in his environment.


Shouldn't be max execution time issue if he's running the CLI. Maybe 
account limits? Maybe the above snippet isn't what's really happening... 
I mean what purpose would the above script serve for 3 hours? Looks like 
it's been dumbed down for us dummies on the list.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread kyle.smith
One of two things is happening:

- PHP is crashing, maybe a memory leak, etc.

Or

- That while(true) loop is exiting, and the script is completing.

Would be interesting to know which, try adding this after the loop:
$fp = fopen('/tmp/test','w');
fputs($fp, 'My script left the loop and exited cleanly.  True ==
false.');
fclose($fp);
 
Back on my first point, have you kept an eye on the memory usage over
the 3 hours?  If your version of PHP has a memory leak with while() or
sleep() (would be odd), a bazillion iterrations could break the PHP
defined memory limit (8M by default) and cause it to exit abruptly.

Are you capturing the output anywhere?  For example, in Linux is it
being run from cron or another script?  Try redirecting STDOUT and
STDERR somewhere useful, i.e.:

php my_php_script  /tmp/scriptoutput 21

(21 means output stream 2 [stderr] to the same place as stream 1)

Hope any of these crazy ideas are helpful...
- Kyle

 
--
Kyle Smith
Unix Systems Administrator

-Original Message-
From: Robert Cummings [mailto:rob...@interjinn.com] 
Sent: Thursday, June 11, 2009 8:25 AM
To: Ford, Mike
Cc: php-general@lists.php.net
Subject: Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

Ford, Mike wrote:
 On 11 June 2009 12:00, Ashley Sheridan advised:
 
 On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
 Hi!
 I'm stuck.
 I don't understand why the php CLI dies after 3 hours in my script.
 Any
 idea to solve? Thanks


 PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7
 2009
 20:06:36) Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47
 UTC
 2008 x86_64 GNU/Linux

 Conf [php.ini]
 max_execution_time=0

 ?php
 while (true) {
 sleep(5);
 }


 The while loop will continue executing until its condition is false.
 As
 you've got a boolean true as the condition, it will never end.
 
 I think he realises that. His question is why never equates to 3 
 hours in his environment.

Shouldn't be max execution time issue if he's running the CLI. Maybe
account limits? Maybe the above snippet isn't what's really happening...

I mean what purpose would the above script serve for 3 hours? Looks like
it's been dumbed down for us dummies on the list.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Preventing XSS Attacks

2009-06-11 Thread tedd

At 7:08 PM +0100 6/10/09, Ashley Sheridan wrote:


So something like this would be acceptable?:

$searchTerms = (isset($_REQUEST['q']))?$_REQUEST['q']:'';
$searchTerms = htmlentities($searchTerms);
$dbSearchTerms = mysql_real_escape_string($searchTerms);

Giving me two variables, one for display output to user, the other for
use in the database?

Thanks
Ash


Ash:

I wouldn't use $_REQUEST.  If you know the request method then use it.

There can be problems using $_REQUEST.

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



[PHP] order by what?

2009-06-11 Thread PJ
How can order by be forced to order alphabetically and ignore accents
without stripping the accents for printout? This is a problem for both
caps  normal letters.

-- 
Hervé Kempf: Pour sauver la planète, sortez du capitalisme.
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] order by what?

2009-06-11 Thread Jay Blanchard
[snip]
How can order by be forced to order alphabetically and ignore accents
without stripping the accents for printout? This is a problem for both
caps  normal letters.
[/snip]

Definitely an SQL question. What character set are you using in your
database? Is the accent the first character of the string or is this a
multi-byte character? 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Mail function and hotmail

2009-06-11 Thread Fernando G

Hello, Thank you all for your cooperation yesterday.  I tried PEAR Mail_mime as 
follows:

function SendEmail($template, $params){
// Read and open the template file and the image file
$htmlFile = fopen(./templates/$template.html, r);
$txtFile = fopen(./templates/$template.txt, r);
$htmlMsg = fread($htmlFile, filesize(./templates/$template.html));
$textMsg = fread($txtFile, filesize(./templates/$template.txt));

// Replace the template values
foreach($params as $key = $value){
// Template values will always start with two hash marks ##
if(substr($key, 0, 2) == ##){
$htmlMsg = str_replace($key, $value, $htmlMsg);
$textMsg = str_replace($key, $value, $textMsg);
}
}

// Create the appropiate headers
$headers = array(
From = n...@domain.ca,
Reply-To = n...@domain.ca,
Subject = $params[subject],
Organization = Name
);

// Create the mime object
$mime = new Mail_mime();
$mime-setTxtBody($textMsg);
$mime-setHTMLBody($htmlMsg);
$mime-addHTMLImage(templates/emaillogo.jpg, image/jpg, 
templates/emaillogo.jpg);

// Set the variables for the Mail object to send the message
$body = $mime-get();
$headers = $mime-headers($headers);

$mail = Mail::factory(mail);
return $mail-send($params[email], $headers, $body);
}


However, hotmail is still getting blank emails when I sent them from my 
production machine (CentOS 5.3), however, when I send the message from my 
development machine (Visata Ultimate SP1) it does work correctly on hotmail 
address .  Both machines are running php 5.2 and have the same PEAR packages.  
I tried Gmail, Yahoo mail and Thunderbird and they work fine.

Your help will be much appreciated.

Thank you,

Fernando.

 Date: Wed, 10 Jun 2009 23:14:11 +0530
 From: sudhee...@binaryvibes.co.in
 To: phps...@gmail.com
 CC: jfer...@hotmail.com; rich...@php.net; php-general@lists.php.net
 Subject: Re: [PHP] Mail function and hotmail
 
 
 
  Richard was likely suggestion his mail example as listed in his signature
 
  Other options include
 
  phpmailer
  pear's mime mail
 
  various other classes available www.phpclasses.org

 Fernando,
 
 I recommend you check out the various PHP frameworks out there. Instead 
 of randomly searching for classes for common functionality like sending 
 an email from your script, you could use the framework's classes. I am 
 sure all of the frameworks provide classes to send emails.  The next 
 time you need a  class to read email from your scripts, you can simply 
 look for classes your framework of choice provides.
 
 I personally use Zend Framework. But there are many available - Cake, 
 CI, Symphony, etc.
 
 Also take a look at PEAR like Bastien said.
 -- 
 
 With warm regards,
 Sudheer. S
 Business: http://binaryvibes.co.in, Tech stuff: http://techchorus.net, 
 Personal: http://sudheer.net
 

_
Attention all humans. We are your photos. Free us.
http://go.microsoft.com/?linkid=9666046

Re: [PHP] order by what?

2009-06-11 Thread PJ
Jay Blanchard wrote:
 [snip]
 How can order by be forced to order alphabetically and ignore accents
 without stripping the accents for printout? This is a problem for both
 caps  normal letters.
 [/snip]

 Definitely an SQL question. What character set are you using in your
 database? Is the accent the first character of the string or is this a
 multi-byte character? 
   
utf8 general
the accents are French - including first character and others in the
words...
e.g. Érable comes up before Autres; and Céréales appears before Café...
I imagine it's a collation (character set) problem. I don't know what to
use to eliminate this problem. Should the collation be latin1 swedish_ci
? I have never received a definitive response even on this list. :-(
And this is an ever recurring problem as I work with several languages
which all have accents...


-- 
Hervé Kempf: Pour sauver la planète, sortez du capitalisme.
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Preventing XSS Attacks

2009-06-11 Thread HallMarc Websites


 -Original Message-
 From: tedd [mailto:tedd.sperl...@gmail.com]
 Sent: Thursday, June 11, 2009 9:28 AM
 To: PHP-General List
 Subject: Re: [PHP] Preventing XSS Attacks
 
 At 7:08 PM +0100 6/10/09, Ashley Sheridan wrote:
 
 So something like this would be acceptable?:
 
 $searchTerms = (isset($_REQUEST['q']))?$_REQUEST['q']:'';
 $searchTerms = htmlentities($searchTerms);
 $dbSearchTerms = mysql_real_escape_string($searchTerms);
 
 Giving me two variables, one for display output to user, the other for
 use in the database?
 
 Thanks
 Ash
 
 Ash:
 
 I wouldn't use $_REQUEST.  If you know the request method then use it.
 
 There can be problems using $_REQUEST.
 
 Cheers,
 
 tedd
 
 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com
 

I agree with tedd whole heartedly and I want to repeat the importance of
protecting the data coming back from the db as well by using
safeEscapeString in your queries and again the reason for this is to prevent
malicious code from being executed. 

As far as CSRF/XSRF take a read here
http://shiflett.org/articles/cross-site-request-forgeries

[Marc Hall - HallMarc Websites - http://www.hallmarcwebsites.com
610.446.3346]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] order by what?

2009-06-11 Thread Jay Blanchard
[snip]
 [snip]
 How can order by be forced to order alphabetically and ignore accents
 without stripping the accents for printout? This is a problem for both
 caps  normal letters.
 [/snip]

 Definitely an SQL question. What character set are you using in your
 database? Is the accent the first character of the string or is this a
 multi-byte character? 
   
utf8 general
the accents are French - including first character and others in the
words...
e.g. Érable comes up before Autres; and Céréales appears before Café...
I imagine it's a collation (character set) problem. I don't know what to
use to eliminate this problem. Should the collation be latin1 swedish_ci
? I have never received a definitive response even on this list. :-(
And this is an ever recurring problem as I work with several languages
which all have accents...
[/snip]

Have you considered asking on the list of the database of your choice? Like the 
MySQL list? 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by what?

2009-06-11 Thread Robin Vickery
2009/6/11 PJ af.gour...@videotron.ca

 How can order by be forced to order alphabetically and ignore accents
 without stripping the accents for printout? This is a problem for both
 caps  normal letters.


Depends on the database.

If you're using mysql, the order is governed by the collation used. To get
the order you want, you need a case-insensitive and accent-insensitive
collation. Exactly which one you use will depend on the character set that
you're using, but if you're character set is utf8, then the utf8_general_ci
collation should work:

SELECT fieldname FROM tablename ORDER BY fieldname COLLATE utf8_general_ci;

-robin


Re: [PHP] order by what?

2009-06-11 Thread PJ
PJ wrote:
 Jay Blanchard wrote:
   
 [snip]
 How can order by be forced to order alphabetically and ignore accents
 without stripping the accents for printout? This is a problem for both
 caps  normal letters.
 [/snip]

 Definitely an SQL question. What character set are you using in your
 database? Is the accent the first character of the string or is this a
 multi-byte character? 
   
 
 utf8 general
 the accents are French - including first character and others in the
 words...
 e.g. Érable comes up before Autres; and Céréales appears before Café...
 I imagine it's a collation (character set) problem. I don't know what to
 use to eliminate this problem. Should the collation be latin1 swedish_ci
 ? I have never received a definitive response even on this list. :-(
 And this is an ever recurring problem as I work with several languages
 which all have accents...
   
There are some options which all need some sort of adjustment.
If , e.g. É is used in the db instead of Eacute; the output onscreen is
a little black diamond with a quesion mark inside. The order is correct,
but the diamond is not acceptable... obviously, one cannot expect people
to change their browser or whatever adjustments just for my little diamonds.
Again, it probably means changing the collation - but where, in my database?
TIA

-- 
Hervé Kempf: Pour sauver la planète, sortez du capitalisme.
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by what?

2009-06-11 Thread PJ
Jay Blanchard wrote:
 [snip]
   
 [snip]
 How can order by be forced to order alphabetically and ignore accents
 without stripping the accents for printout? This is a problem for both
 caps  normal letters.
 [/snip]

 Definitely an SQL question. What character set are you using in your
 database? Is the accent the first character of the string or is this a
 multi-byte character? 
   
 
 utf8 general
 the accents are French - including first character and others in the
 words...
 e.g. Érable comes up before Autres; and Céréales appears before Café...
 I imagine it's a collation (character set) problem. I don't know what to
 use to eliminate this problem. Should the collation be latin1 swedish_ci
 ? I have never received a definitive response even on this list. :-(
 And this is an ever recurring problem as I work with several languages
 which all have accents...
 [/snip]

 Have you considered asking on the list of the database of your choice? Like 
 the MySQL list? 

   
They're not as nice as the guys on this list... usually ;-)

-- 
Hervé Kempf: Pour sauver la planète, sortez du capitalisme.
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Same Page, Fundamentally Different Behavior OR is Firefox broken?

2009-06-11 Thread Matt Neimeyer
I'm at a complete loss... So I'm hoping someone can point me in the
right direction to even start looking.

We have an application written in PHP that lets users send out emails.
The basic process is as follows.

1. Go to start screen. (This resets anything currently in process
for the current logged in user)
2. Upload email addresses and other info (Names, etc)
3. Build Email
4. Send

In Step 3 the user can click a Live Preview button to see what the
email will look like with the merged data.

Here's the problem,  this works fine in all versions of IE, versions
1.5 or less of FireFox and versions 3 or less of Safari. However,
starting in FireFox 2, and now Safari 4, when you get to step four OR
click the live preview button in step three there is no more data in
the merge. In those browsers the system is acting like the end user
went BACK to the start page (in another window?) and reinitialized all
the data.

I immediately thought it might be pre-fetching so I tried using the
system before and after toggling the network.prefetch-next setting in
about:config with FireFox 2.0.0.20 and restarting the browser. No
luck. So I added code to my reset function to email me the output of
phpinfo() when the reset function is called. Using IE I get 1
notification. Using FF I get two notifications. This reinforces my
theory that FireFox is prefetching the menu item to start a new
mailing (just an a link...) from the top of the composer page. Even
still... I've disabled prefetch so it SHOULDN'T even be considering
those links right? I've also tried adding artificial
?now=timestamp fakes to the end of all menu links since I read
somewhere (don't remember where) that FireFox only prefetches pages
with no query section in the address.

Has anyone run into this behavior before? Any recommendations on how
to stop it? Preferably from the server with code of some sort...

Thanks in advance.

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by what?

2009-06-11 Thread PJ
Robin Vickery wrote:


 2009/6/11 PJ af.gour...@videotron.ca mailto:af.gour...@videotron.ca

 How can order by be forced to order alphabetically and ignore accents
 without stripping the accents for printout? This is a problem for both
 caps  normal letters.


 Depends on the database.

 If you're using mysql, the order is governed by the collation used. To
 get the order you want, you need a case-insensitive and
 accent-insensitive collation. Exactly which one you use will depend on
 the character set that you're using, but if you're character set is
 utf8, then the utf8_general_ci collation should work:

 SELECT fieldname FROM tablename ORDER BY fieldname COLLATE
 utf8_general_ci;

 -robin
Nice thought, Robin. My collation is already uft8_general_ci.
Adding that condition to the query changes nothing; and specifying
another collation return a blank or null and the list is not echoed.
Even changing the collation in the db does not change anything. Same
wrong results.
Thanks anyway.

-- 
Hervé Kempf: Pour sauver la planète, sortez du capitalisme.
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by what?

2009-06-11 Thread Andrew Ballard
On Thu, Jun 11, 2009 at 11:27 AM, PJaf.gour...@videotron.ca wrote:
 Robin Vickery wrote:


 2009/6/11 PJ af.gour...@videotron.ca mailto:af.gour...@videotron.ca

     How can order by be forced to order alphabetically and ignore accents
     without stripping the accents for printout? This is a problem for both
     caps  normal letters.


 Depends on the database.

 If you're using mysql, the order is governed by the collation used. To
 get the order you want, you need a case-insensitive and
 accent-insensitive collation. Exactly which one you use will depend on
 the character set that you're using, but if you're character set is
 utf8, then the utf8_general_ci collation should work:

 SELECT fieldname FROM tablename ORDER BY fieldname COLLATE
 utf8_general_ci;

 -robin
 Nice thought, Robin. My collation is already uft8_general_ci.
 Adding that condition to the query changes nothing; and specifying
 another collation return a blank or null and the list is not echoed.
 Even changing the collation in the db does not change anything. Same
 wrong results.
 Thanks anyway.

 --
 Hervé Kempf: Pour sauver la plančte, sortez du capitalisme.
 -
 Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php



Are you storing the actual characters in the database or are you
storing the HTML entities? It WON'T sort correctly if you are storing
the entities.

Make sure you are storing the actual characters in your database, and
then make sure that you are sending the correct content-type header
when you serve the page. If you try to serve UTF-8 characters but your
server is sending a Content-Type: ISO-8859-1; header, you will get
placeholders in FF for characters that aren't recognized.

Andrew

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by what?

2009-06-11 Thread PJ
Robin Vickery wrote:


 2009/6/11 PJ af.gour...@videotron.ca mailto:af.gour...@videotron.ca

 How can order by be forced to order alphabetically and ignore accents
 without stripping the accents for printout? This is a problem for both
 caps  normal letters.


 Depends on the database.

 If you're using mysql, the order is governed by the collation used. To
 get the order you want, you need a case-insensitive and
 accent-insensitive collation. Exactly which one you use will depend on
 the character set that you're using, but if you're character set is
 utf8, then the utf8_general_ci collation should work:

 SELECT fieldname FROM tablename ORDER BY fieldname COLLATE
 utf8_general_ci;

 -robin
Obviously there is another solution, albeit rather silly: re-enter all
the fields in alphabetical order with corresponding id fields in
numerical order... great, if you're not going to change the list and if
it's quite short... not too clever, though is it?

-- 
Hervé Kempf: Pour sauver la planète, sortez du capitalisme.
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by what?

2009-06-11 Thread Per Jessen
PJ wrote:

 PJ wrote:
 There are some options which all need some sort of adjustment.
 If , e.g. É is used in the db instead of Eacute; the output onscreen
 is a little black diamond with a quesion mark inside. The order is
 correct, but the diamond is not acceptable... obviously, one cannot
 expect people to change their browser or whatever adjustments just for
 my little diamonds. 

Set the correct character set for your output.  It's in the HTTP header. 


/Per

-- 
Per Jessen, Zürich (20.2°C)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by what?

2009-06-11 Thread Eddie Drapkin
On Thu, Jun 11, 2009 at 11:35 AM, PJ af.gour...@videotron.ca wrote:

 Robin Vickery wrote:
 
 
  2009/6/11 PJ af.gour...@videotron.ca mailto:af.gour...@videotron.ca
 
  How can order by be forced to order alphabetically and ignore accents
  without stripping the accents for printout? This is a problem for
 both
  caps  normal letters.
 
 
  Depends on the database.
 
  If you're using mysql, the order is governed by the collation used. To
  get the order you want, you need a case-insensitive and
  accent-insensitive collation. Exactly which one you use will depend on
  the character set that you're using, but if you're character set is
  utf8, then the utf8_general_ci collation should work:
 
  SELECT fieldname FROM tablename ORDER BY fieldname COLLATE
  utf8_general_ci;
 
  -robin
 Obviously there is another solution, albeit rather silly: re-enter all
 the fields in alphabetical order with corresponding id fields in
 numerical order... great, if you're not going to change the list and if
 it's quite short... not too clever, though is it?

 --
 Hervé Kempf: Pour sauver la plančte, sortez du capitalisme.
 -
 Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


PFT just run a cron job to re--order the table every two minutes.
Easily the best solution.


RE: [PHP] Mail function and hotmail

2009-06-11 Thread Fernando G

I decided to change the call to send to:

$mail = Mail::factory(smtp, array(host = localhost));
return $mail-send($params[email], $headers, $body);

and now hotmail wokrs.  Maybe qmail changes something when the mail() function 
is used.

Thank you for all your help.

Fernando.

 From: jfer...@hotmail.com
 To: sudhee...@binaryvibes.co.in; phps...@gmail.com
 CC: rich...@php.net; php-general@lists.php.net
 Date: Thu, 11 Jun 2009 10:34:13 -0400
 Subject: RE: [PHP] Mail function and hotmail
 
 
 Hello, Thank you all for your cooperation yesterday.  I tried PEAR Mail_mime 
 as follows:
 
 function SendEmail($template, $params){
 // Read and open the template file and the image file
 $htmlFile = fopen(./templates/$template.html, r);
 $txtFile = fopen(./templates/$template.txt, r);
 $htmlMsg = fread($htmlFile, filesize(./templates/$template.html));
 $textMsg = fread($txtFile, filesize(./templates/$template.txt));
 
 // Replace the template values
 foreach($params as $key = $value){
 // Template values will always start with two hash marks ##
 if(substr($key, 0, 2) == ##){
 $htmlMsg = str_replace($key, $value, $htmlMsg);
 $textMsg = str_replace($key, $value, $textMsg);
 }
 }
 
 // Create the appropiate headers
 $headers = array(
 From = n...@domain.ca,
 Reply-To = n...@domain.ca,
 Subject = $params[subject],
 Organization = Name
 );
 
 // Create the mime object
 $mime = new Mail_mime();
 $mime-setTxtBody($textMsg);
 $mime-setHTMLBody($htmlMsg);
 $mime-addHTMLImage(templates/emaillogo.jpg, image/jpg, 
 templates/emaillogo.jpg);
 
 // Set the variables for the Mail object to send the message
 $body = $mime-get();
 $headers = $mime-headers($headers);
 
 $mail = Mail::factory(mail);
 return $mail-send($params[email], $headers, $body);
 }
 
 
 However, hotmail is still getting blank emails when I sent them from my 
 production machine (CentOS 5.3), however, when I send the message from my 
 development machine (Visata Ultimate SP1) it does work correctly on hotmail 
 address .  Both machines are running php 5.2 and have the same PEAR packages. 
  I tried Gmail, Yahoo mail and Thunderbird and they work fine.
 
 Your help will be much appreciated.
 
 Thank you,
 
 Fernando.
 
  Date: Wed, 10 Jun 2009 23:14:11 +0530
  From: sudhee...@binaryvibes.co.in
  To: phps...@gmail.com
  CC: jfer...@hotmail.com; rich...@php.net; php-general@lists.php.net
  Subject: Re: [PHP] Mail function and hotmail
  
  
  
   Richard was likely suggestion his mail example as listed in his signature
  
   Other options include
  
   phpmailer
   pear's mime mail
  
   various other classes available www.phpclasses.org
 
  Fernando,
  
  I recommend you check out the various PHP frameworks out there. Instead 
  of randomly searching for classes for common functionality like sending 
  an email from your script, you could use the framework's classes. I am 
  sure all of the frameworks provide classes to send emails.  The next 
  time you need a  class to read email from your scripts, you can simply 
  look for classes your framework of choice provides.
  
  I personally use Zend Framework. But there are many available - Cake, 
  CI, Symphony, etc.
  
  Also take a look at PEAR like Bastien said.
  -- 
  
  With warm regards,
  Sudheer. S
  Business: http://binaryvibes.co.in, Tech stuff: http://techchorus.net, 
  Personal: http://sudheer.net
  
 
 _
 Attention all humans. We are your photos. Free us.
 http://go.microsoft.com/?linkid=9666046

_
We are your photos. Share us now with Windows Live Photos.
http://go.microsoft.com/?linkid=9666047

Re: [PHP] Re: SHOULD I NOT USE ELSE IN IF STATEMENTS....?

2009-06-11 Thread Jan G.B.
2009/6/10 Clancy clanc...@cybec.com.au

 On Tue, 09 Jun 2009 12:22:22 -0400, rob...@interjinn.com (Robert Cummings)
 wrote:

 Craige Leeder wrote:
  I'm not sure I agree with NEVER using else. Sometimes else is a very
  logical way to organize code. However, it should not be used for data
  validation IE:
 
 
  function myValidatorFunc($data) {
 if (empty(data)) {
return false;
 } else {
if (!is_numeric($data)) {
   return false;
} else {
 
}
 }
  }
 


Sure - these control structure doesn't make sense - but who would write it
*like that*?
Guess 99% would rather write smth like that:

 if (empty($data) || !is_numeric($data)) {
return false;
}


Whis is good.


:-)




 
  It's all about how deep you nest your code, and keeping the flow clean.
  That code would be much more readable as such:
 
  function myValidatorFunc($data) {
 if (empty(data)) {
throw new BadMethodCallException(Paramater data missing);
 }
 if (!is_numeric($data)) {
throw new InvalidArgumentException(Paramater data should be an
  integer.);
 }
  }
 
  See the difference?
 
 I believe the article was suggesting not ending a function that returns
 a value with no return. So rather than return in the else, return
 outside the else as the last expression of the function. This way it is
 clear that the function returns a value.
 
 Contrast:
 
 ?php
 
 function foo( $foo )
 {
  if( $foo )
  {
  return true;
  }
  else
  {
  return false;
  }
 }
 
 ?
 
 Versus:
 
 ?php
 
 function foo( $foo )
 {
  if( $foo )
  {
  return true;
  }
 
  return false;
 }
 
 ?
 
 Personally, I also prefer the latter style.

 I don't particularly like scattered returns, and prefer

 Function foo;
{
result = false;
if (  ) { $result = 'yellow'; }
elseif (  ) { $result = 'blue'; }
return $result;
 }


Well, I like the fact that the process is out of code, when you return
early. On the other hand, a single return is handy...  Guess it depends on
the subject.


The discussion ... well.. sounds a bit like
  Use a red shoe, your blue ones are crap


Regards


Re: [PHP] Preventing XSS Attacks

2009-06-11 Thread Jan G.B.
2009/6/11 HallMarc Websites m...@hallmarcwebsites.com



  -Original Message-
  From: tedd [mailto:tedd.sperl...@gmail.com]
  Sent: Thursday, June 11, 2009 9:28 AM
  To: PHP-General List
  Subject: Re: [PHP] Preventing XSS Attacks
 
  At 7:08 PM +0100 6/10/09, Ashley Sheridan wrote:
  
  So something like this would be acceptable?:
  
  $searchTerms = (isset($_REQUEST['q']))?$_REQUEST['q']:'';
  $searchTerms = htmlentities($searchTerms);
  $dbSearchTerms = mysql_real_escape_string($searchTerms);
  
  Giving me two variables, one for display output to user, the other for
  use in the database?
  
  Thanks
  Ash
 
  Ash:
 
  I wouldn't use $_REQUEST.  If you know the request method then use it.
 
  There can be problems using $_REQUEST.
 
  Cheers,
 
  tedd
 
  --
  ---
  http://sperling.com  http://ancientstones.com  http://earthstones.com
 

 I agree with tedd whole heartedly and I want to repeat the importance of
 protecting the data coming back from the db as well by using
 safeEscapeString in your queries and again the reason for this is to
 prevent
 malicious code from being executed.

 As far as CSRF/XSRF take a read here
 http://shiflett.org/articles/cross-site-request-forgeries

 [Marc Hall - HallMarc Websites - http://www.hallmarcwebsites.com
 610.446.3346]



I'd recommend that you *always* use ENT_QUOTES as the second parameter on
htmlentities or htmlspecialchars. Otherwise a single ' will not be escaped,
which may be evil.

Also be sure that you don't code a possibility to include local or even
remote files: It's so easy to Inject code into logfiles.
include('whatever'.$_REQUEST['var'].'.whatever') is not a sufficient
protection.

Also, like someone already mentioned, *always* prefer _POST over _REQUEST,
when dealing with a FORM with method POST!

Regards


Re: [PHP] order by what?

2009-06-11 Thread Robin Vickery
2009/6/11 PJ af.gour...@videotron.ca

 Robin Vickery wrote:
 
 
  2009/6/11 PJ af.gour...@videotron.ca mailto:af.gour...@videotron.ca
 
  How can order by be forced to order alphabetically and ignore accents
  without stripping the accents for printout? This is a problem for
 both
  caps  normal letters.
 
 
  Depends on the database.
 
  If you're using mysql, the order is governed by the collation used. To
  get the order you want, you need a case-insensitive and
  accent-insensitive collation. Exactly which one you use will depend on
  the character set that you're using, but if you're character set is
  utf8, then the utf8_general_ci collation should work:
 
  SELECT fieldname FROM tablename ORDER BY fieldname COLLATE
  utf8_general_ci;
 
  -robin
 Nice thought, Robin. My collation is already uft8_general_ci.
 Adding that condition to the query changes nothing; and specifying
 another collation return a blank or null and the list is not echoed.
 Even changing the collation in the db does not change anything. Same
 wrong results.
 Thanks anyway.


Hiyah,

Well the mysql docs confirm that utf8_general_ci is accent-insensitive and
case-insensitive (
http://dev.mysql.com/doc/refman/5.4/en/charset-collation-implementations.html).
Which implies that maybe you don't actually have utf8 text in that field.

If you do a SHOW VARIABLES LIKE 'character_set%'; what do you get for
character_set_client, character_set_results and character_set_connection?

-robin


[PHP] Re: ezmlm response

2009-06-11 Thread Mika Pohjola
It could be arti...@bluemusicgroup.com or m...@bluemusicgroup.com

Please, remove. Thanks.


Re: [PHP] Re: ezmlm response

2009-06-11 Thread Daniel Brown
On Thu, Jun 11, 2009 at 13:24, Mika Pohjolapohjola.m...@gmail.com wrote:
 It could be arti...@bluemusicgroup.com or m...@bluemusicgroup.com

 Please, remove. Thanks.

Mika,

You will need to do this yourself at http://php.net/mailinglists.
If it's a different address forwarding to your primary that is
subscribed to the list, you will have to enter that address in the
(un)subscribe field.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHP 5.3.0RC3

2009-06-11 Thread Johannes Schlüter
Hello!

we have packaged PHP 5.3.0RC3, which you can find here:
http://downloads.php.net/johannes/

Windows binaries are available here:
http://windows.php.net/qa/

This third release candidate focused on bug fixes and stability
improvements and we hope to only require minimal changes ahead
of the next release. Many, but not all,  of the new features are
already integrated in the official documentation on php.net.

Please not that we are aware of a few minor issues including that we
still want to fix for the final release. We are aiming for an RC4 next
week followed by the final release in the week after. For most users 
there will not be a noticeable change meaning that now is the time 
to really do the final testing of PHP 5.3.0 before it gets released 
with any unnecessary incompatibilities with your project.

Some additional links to get started:
http://cvs.php.net/viewvc.cgi/php-src/NEWS?view=markuppathrev=PHP_5_3
http://wiki.php.net/doc/scratchpad/upgrade/53

Best Regards,
Lukas and Johannes
PHP 5.3 Release Managers



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: [Bulk] Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Jean-Pierre Arneodo

Ashley Sheridan a écrit :

On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
  

Hi!
I'm stuck.
I don't understand why the php CLI dies after 3 hours in my script.
Any idea to solve?
Thanks


PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7 2009 
20:06:36)
Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47 UTC 2008 x86_64 
GNU/Linux

Conf [php.ini]
max_execution_time=0

?php
while (true) {
sleep(5);
}
?


  


The while loop will continue executing until its condition is false. As
you've got a boolean true as the condition, it will never end.

Thanks
Ash
www.ashleysheridan.co.uk
  

I don't want to stop, but the process dies.

I've tried the same loop with bash interpretor.
Same result, it seems to be a ubuntu problem, not a php problem.

Thanks



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: [Bulk] Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Robert Cummings

Jean-Pierre Arneodo wrote:

Ashley Sheridan a écrit :

On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
 

Hi!
I'm stuck.
I don't understand why the php CLI dies after 3 hours in my script.
Any idea to solve?
Thanks


PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7 
2009 20:06:36)
Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47 UTC 2008 
x86_64 GNU/Linux


Conf [php.ini]
max_execution_time=0

?php
while (true) {
sleep(5);
}
?


  

The while loop will continue executing until its condition is false. As
you've got a boolean true as the condition, it will never end.

Thanks
Ash
www.ashleysheridan.co.uk
  

I don't want to stop, but the process dies.

I've tried the same loop with bash interpretor.
Same result, it seems to be a ubuntu problem, not a php problem.


Open up a shell... type the following into it:

ulimit -a

What do you see?

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Field type for american money

2009-06-11 Thread revDAVE
Php - MySQL - newbie question

- Field type for american money - int(11) seems to work fine

- but also I tried decimal(10,2)

Is one a better choice than another for american money usage?


--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists 09]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Field type for american money

2009-06-11 Thread Daniel Brown
On Thu, Jun 11, 2009 at 16:08, revDAVEc...@hosting4days.com wrote:
 Php - MySQL - newbie question

 - Field type for american money - int(11) seems to work fine

 - but also I tried decimal(10,2)

 Is one a better choice than another for american money usage?

For PHP, check out money_format(), number_format(), and sprintf()
with `%0.2f` or similar.  For MySQL, ask on the MySQL list.  ;-P

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Field type for american money

2009-06-11 Thread Shawn McKenzie
revDAVE wrote:
 Php - MySQL - newbie question
 
 - Field type for american money - int(11) seems to work fine
 
 - but also I tried decimal(10,2)
 
 Is one a better choice than another for american money usage?
 
 
 --
 Thanks - RevDave
 Cool @ hosting4days . com
 [db-lists 09]
 
 
 

If you are only interested in round dollar amounts then int should work
fine ;-)  If you expect any fractions of a dollar (as I suspect you
will), such as 19.95 then use decimal.

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Field type for american money

2009-06-11 Thread Waynn Lue
For mysql, it's better to use int and then store it in cents (or
micros) so you can use all integer operations instead of float ones.

On 6/11/09, Shawn McKenzie nos...@mckenzies.net wrote:
 revDAVE wrote:
 Php - MySQL - newbie question

 - Field type for american money - int(11) seems to work fine

 - but also I tried decimal(10,2)

 Is one a better choice than another for american money usage?


 --
 Thanks - RevDave
 Cool @ hosting4days . com
 [db-lists 09]




 If you are only interested in round dollar amounts then int should work
 fine ;-)  If you expect any fractions of a dollar (as I suspect you
 will), such as 19.95 then use decimal.

 --
 Thanks!
 -Shawn
 http://www.spidean.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Field type for american money

2009-06-11 Thread Shawn McKenzie
Waynn Lue wrote:
 For mysql, it's better to use int and then store it in cents (or
 micros) so you can use all integer operations instead of float ones.
 

To each his own.  Speed or otherwise I don't see a difference between:

$total = 19.95 + 3.99; //shipping

and

$total = 1995 + 399; //shipping

Except with the ints you have to format them for display.


-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] CURL intermittant problem

2009-06-11 Thread ioan...@btinternet.com
I have been having problems with a curl script which works normally with 
many different URLs but had a particular intermittant problem with a url 
in the following format:
http://10.20.30.40/0001/032/023112/filename.phtml?param1=paramvalue1param2=paramvalue2 
etc etc.


The unusual thing about this URL is that is starts with an IP address.  
I got a lot of failures to connect, so tried a different way to connect 
as all I need is the page as a string:


According to php.net, the function 'file_get_contents()' should work if 
allow_url_fopen is set to TRUE for the PHP installation.  
'allow_url_fopen' is set to 1 in my php.ini file.


http://php.net/file_get_contents
http://php.net/allow_url_fopen

However, 'file_get_contents' also fails to connect to this particular 
URL.  It gives:


failed to open stream: Connection timed out in 
*/home/shortsta/public_html/live48_test.php* on line *75*


*Warning*: feof(): supplied argument is not a valid stream resource in 
*/home/mysite/public_html/testpage.php* on line *79*


The target URL works perfectly and quicly if put directly into the 
browser URL line.


Do you know of any other reasons for problems with such a connection?

John

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Field type for american money

2009-06-11 Thread Robert Cummings

Shawn McKenzie wrote:

Waynn Lue wrote:

For mysql, it's better to use int and then store it in cents (or
micros) so you can use all integer operations instead of float ones.



To each his own.  Speed or otherwise I don't see a difference between:

$total = 19.95 + 3.99; //shipping

and

$total = 1995 + 399; //shipping

Except with the ints you have to format them for display.


You have to format the floats too:

?php

$total = 5.55 + 9.35;
echo $total.\n;

?

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] CURL intermittant problem

2009-06-11 Thread Daniel Brown
On Thu, Jun 11, 2009 at 19:07,
ioan...@btinternet.comioan...@btinternet.com wrote:

 The target URL works perfectly and quicly if put directly into the browser
 URL line.

 Do you know of any other reasons for problems with such a connection?

Is the script being run located on the same system as which you're
using the browser to (successfully) connect to the target host?  If
not, check to see if there's a network issue - a downed or improperly
bound interface, SELinux restrictions, blacklisted by the remote
machine, etc. - on the server on which the script it hosted.  In
addition, as simple and obvious as it is, if it's a private network,
make sure the machine on which the script is hosted is within the same
network as the target machine.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Field type for american money

2009-06-11 Thread Waynn Lue

 Shawn McKenzie wrote:

 Waynn Lue wrote:

 For mysql, it's better to use int and then store it in cents (or
 micros) so you can use all integer operations instead of float ones.


 To each his own.  Speed or otherwise I don't see a difference between:

 $total = 19.95 + 3.99; //shipping

 and

 $total = 1995 + 399; //shipping

 Except with the ints you have to format them for display.


 You have to format the floats too:

 ?php

$total = 5.55 + 9.35;
echo $total.\n;

 ?


Oh, I didn't mean speed within PHP, I meant for mysql operations.  I'm not
sure how PHP handles int vs. float operations (though int is usually faster
than float for other languages, isn't it?).


Re: [PHP] Field type for american money

2009-06-11 Thread Shawn McKenzie
Robert Cummings wrote:
 Shawn McKenzie wrote:
 Waynn Lue wrote:
 For mysql, it's better to use int and then store it in cents (or
 micros) so you can use all integer operations instead of float ones.


 To each his own.  Speed or otherwise I don't see a difference between:

 $total = 19.95 + 3.99; //shipping

 and

 $total = 1995 + 399; //shipping

 Except with the ints you have to format them for display.
 
 You have to format the floats too:
 
 ?php
 
 $total = 5.55 + 9.35;
 echo $total.\n;
 
 ?
 
 Cheers,
 Rob.

Yeah, yeah, yeah...

I guess what I meant to say was that I had never really considered using
ints :-)

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] CURL intermittant problem

2009-06-11 Thread Martin Scotta
It looks like a connection problem,

You has to make sure php can connect to the IP

?php
   echo exec( 'ping 10.20.30.40' );
?

You can remove the IP from the source, just add an entry in the /etc/hosts
file

Mrtn

On Thu, Jun 11, 2009 at 8:14 PM, Daniel Brown danbr...@php.net wrote:

 On Thu, Jun 11, 2009 at 19:07,
 ioan...@btinternet.comioan...@btinternet.com wrote:
 
  The target URL works perfectly and quicly if put directly into the
 browser
  URL line.
 
  Do you know of any other reasons for problems with such a connection?

 Is the script being run located on the same system as which you're
 using the browser to (successfully) connect to the target host?  If
 not, check to see if there's a network issue - a downed or improperly
 bound interface, SELinux restrictions, blacklisted by the remote
 machine, etc. - on the server on which the script it hosted.  In
 addition, as simple and obvious as it is, if it's a private network,
 make sure the machine on which the script is hosted is within the same
 network as the target machine.

 --
 /Daniel P. Brown
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/
 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Martin Scotta


[PHP] Beginner at writting a PHP Wrapper for C++ libraries

2009-06-11 Thread Eric A. Boney
I am just beginning my foray into writing my own wrapper for a C++ library 
that maintained by someone else. I have ordered Sara Golemon's book Extending 
and Embedding PHP which should arrive in the next week or so, but until then 
I had a couple of questions that I was hoping might be able to be answered 
here. If this is the incorrect list to post this to, please let me know.

Is it possible to use an object file from the C++ library directly in the 
config.m4 file? I attempted to create a symlink to the cpp file that I needed 
for 
my extension but I get a ton of errors when I try to make the extension and I 
am guessing it is because this one cpp file that I need requires a ton of other 
header files.

Second question is, I thought I read somewhere that it was possible to create 
a stand alone extension that did not require the end user to install the .so 
file and then modify the php.ini file and restart the apache server. How can I 
do this with my extension and just call/load the .so file in my script(s) that 
need it?

Thanks in advance.

-Eric Bonney

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Dynamic Titles

2009-06-11 Thread Austin Caudill
Hello, im trying to make the CMS system im using more SEO friendly by giving 
each page it's own title. Right now, the system assigns all pages the same 
general title. I would like to use PHP to discertain which page is being viewed 
and in turn, which title should be used.

I have put in the title tags the variable $title. As for the PHP im using, I 
scripted the following:

$url = http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']';
switch ( $url )
{
    default:
        $title = Photoshop tutorials, Flash tutorials, and more! Newtuts 
Tutorial Search;
        break;

    case $config[HTTP_SERVER]help.php :
        $title = Newtuts Help;
        break;
}
 
Right now, im getting this error:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting 
T_STRING or T_VARIABLE or T_NUM_STRING in 
/home/a7201901/public_html/includes/classes/tutorial.php on line 803 
 
Can someone please help me with this?



Thanks!