Re: [PHP] Should I go with the Singleton Pattern or wait for 5.3?

2008-07-15 Thread Luigi Perroti
On Tue, Jul 15, 2008 at 2:10 AM, Chris wrote:

 Is this a decision for the whole project or just one particular part of
 it? Can that one part be put off until later or does it need to be done
 first?


This decision will impact the whole project.

I think that maybe I should go with the Singleton pattern approach
since it should allow for easier/quicker refactoring in case I have to
switch to another object oriented pattern.

BTW, thanks for your other reply on the php-db list.

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



Re: [PHP] mkdir permission errors

2008-07-15 Thread Peter Ford

Wei, Alice J. wrote:

Hi, Rob:

  I forgot to mention that I have been using yum install.
  I have reinstalled the entire thing, put back all the packages, and then I 
went to /var and did a chmod -R 777 var, and then did a

   [EMAIL PROTECTED] var]# chown -R apache:apache .

Interestingly, I do not see anything different, and I still get this error that 
says my permission is denied. Here is my

[EMAIL PROTECTED] var]#  ps awxu | grep -E 'apache|httpd'
root 31547  0.0  0.3  21268  6584 ?Ss   16:12   0:00 /usr/sbin/httpd
apache   31549  0.0  0.2  21400  5572 ?S16:12   0:00 /usr/sbin/httpd
apache   31550  0.0  0.2  21400  4908 ?S16:12   0:00 /usr/sbin/httpd
apache   31551  0.0  0.2  21400  4908 ?S16:12   0:00 /usr/sbin/httpd
apache   31552  0.0  0.2  21400  4896 ?S16:12   0:00 /usr/sbin/httpd
apache   31553  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31554  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31555  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31556  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
root 31708  0.0  0.0   4120   728 pts/1R+   16:30   0:00 grep -E 
apache|httpd

Obviously, my last one has already changed the owner to apache 
already.Nevertheless, I am still denied even when I am now logged in as root. 
Is this anything with firewalls?



Hang on a minute: you're original message said the error was:

Warning: chmod() [function.chmod]: Permission denied in 
/usr/local/apache/htdocs/file_linux.php on line 27


But you say you've re-installed, and done chmod -R 777 var and chown -R 
apache:apache . in /var


A few things there:
When you are changing permissions and ownerships on such a large scale, you 
should always use absolute paths to be sure you are doing the right thing - like 
chmod -R 777 /var and chown -R apache:apache /var


Next, changing permission and ownership recursively on something like /var is 
likely to wreck your system in weird and wonderful ways, and is pretty difficult 
to undo - you might be looking at a total OS reinstall here (once you've solved 
your Apache problems)


Finally, the error message refers to a file in /usr/local/apache/htdocs, but you 
then are changing permissions in /var - where is your web root?! It looks like 
your PHP code has the /usr/local/apache/htdocs path hard-coded, when your web 
files are actually in /var/something...


--
Peter Ford  phone: 01580 89
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



Re: [PHP] Math Weirdness - Can it be done with integers alone??

2008-07-15 Thread Waynn Lue
There's an algorithm known as banker's rounding that I thought all US
banks used. I'm on blackberry right now so I don't have a pointer, but
essentially you round to the nearest even cent. 1.5 goes to 2, as does
2.5.

Waynn



On 7/15/08, tedd [EMAIL PROTECTED] wrote:
 At 4:15 PM -0400 7/14/08, Robert Cummings wrote:


Nope, banks can't round like that when calculating your daily
interest :)

Cheers,
Rob.

 I do know that when it comes to interest you pay them, they round up.
 When it comes to interest they pay you, they round down -- and why
 not? A decision has to be made -- you can't pay someone less than a
 penny.

 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Advice on a radar chart

2008-07-15 Thread Richard Heyes

Hey,

Can anyone suggest an efficient method for plotting the marks on a radar 
chart? I have the background done 
(http://www.phpguru.org/downloads/HTML5_radar/ - FF required), but that 
not exactly difficult.


Cheers.

--
Richard Heyes

Employ me:
http://www.phpguru.org/cv

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



Re: [PHP] case and accent - insensitive regular expression?

2008-07-15 Thread Yeti
I dont think using all these regular expressions is a very efficient way to
do so. As i previously pointed out there are many users who had a similar
problem, which can be viewed at:

http://it.php.net/manual/en/function.strtr.php

One of my favourites is what derernst at gmx dot ch used.

derernst at gmx dot ch
wrote on 20-Sep-2005 07:29
This works for me to remove accents for some characters of Latin-1, Latin-2
and Turkish in a UTF-8 environment, where the htmlentities-based solutions
fail:

?php

function remove_accents($string, $german=false) {

  // Single letters

  $single_fr = explode( , � � � � � � #260; #258; � #262; #268;
#270; #272; � � � � � #280; #282; #286; � � � � #304; #321; #317;
#313; � #323; #327; � � � � � � #336; #340; #344; � #346; #350;
#356; #354; � � � � #366; #368; � � #377; #379; � � � � � � #261;
#259; � #263; #269; #271; #273; � � � � #281; #283; #287; � � � �
#305; #322; #318; #314; � #324; #328; � � � � � � � #337; #341;
#345; #347; � #351; #357; #355; � � � � #367; #369; � � � #378;
#380;);

  $single_to = explode( , A A A A A A A A C C C D D D E E E E E E G I I I
I I L L L N N N O O O O O O O R R S S S T T U U U U U U Y Z Z Z a a a a a a
a a c c c d d e e e e e e g i i i i i l l l n n n o o o o o o o o r r s s s
t t u u u u u u y y z z z);

  $single = array();

  for ($i=0; $icount($single_fr); $i++) {

  $single[$single_fr[$i]] = $single_to[$i];

  }

  // Ligatures

  $ligatures = array(�=Ae, �=ae, �=Oe, �=oe, �=ss);

  // German umlauts

  $umlauts = array(�=Ae, �=ae, �=Oe, �=oe, �=Ue,
�=ue);

  // Replace

  $replacements = array_merge($single, $ligatures);

  if ($german) $replacements = array_merge($replacements, $umlauts);

  $string = strtr($string, $replacements);

  return $string;

}

?

I would change this function a bit ...

?php
//echo rawurlencode(áàéèíìóòúùÁÀÉÈÍÌÓÒÚÙ); // RFC 1738 codes; NOTE: One
might use UTF-8 as this documents encoding
function remove_accents($string) {
 $string = rawurlencode($string);
 $replacements = array(
 '%C3%A1' = 'a',
 '%C3%A0' = 'a',
 '%C3%A9' = 'e',
 '%C3%A8' = 'e',
 '%C3%AD' = 'i',
 '%C3%AC' = 'i',
 '%C3%B3' = 'o',
 '%C3%B2' = 'o',
 '%C3%BA' = 'u',
 '%C3%B9' = 'u',
 '%C3%81' = 'A',
 '%C3%80' = 'A',
 '%C3%89' = 'E',
 '%C3%88' = 'E',
 '%C3%8D' = 'I',
 '%C3%8C' = 'I',
 '%C3%93' = 'O',
 '%C3%92' = 'O',
 '%C3%9A' = 'U',
 '%C3%99' = 'U'
 );
 return strtr($string, $replacements);
}
//echo remove_accents(CÀfé); // I know it's not spelled right
echo remove_accents(áàéèíìóòúùÁÀÉÈÍÌÓÒÚÙ); //OUTPUT (again: i used UTF-8
for document): aaeeiioouuAAEEIIOOUU
?

Ciao

Yeti
On Mon, Jul 14, 2008 at 8:20 PM, Andrew Ballard [EMAIL PROTECTED] wrote:

 On Mon, Jul 14, 2008 at 1:35 PM, Giulio Mastrosanti
 [EMAIL PROTECTED] wrote:
 
 
  Brilliant !!!
 
  so you replace every occurence of every accent variation with all the
 accent
  variations...
 
  OK, that's it!
 
  only some more doubts ( regex are still an headhache for me... )
 
  preg_replace('/[iìíîïĩīĭįı]/iu',...  -- what's the meaning of iu after
 the
  match string?

 This page explains them both.
 http://us.php.net/manual/en/reference.pcre.pattern.modifiers.php

  preg_replace('/[aàáâãäåǻāăą](?!e)/iu',... whats (?!e)  for? -- every
  occurence of aàáâãäåǻāăą NOT followed by e?

 Yes. It matches any character based on the latin 'a' that is not
 followed by an 'e'. It keeps the pattern from matching the 'a' when it
 immediately precedes an 'e' for the character 'ae' for words like
 these:

 http://en.wikipedia.org/wiki/List_of_words_that_may_be_spelled_with_a_ligature
 (However, that may cause problems with words that have other variants
 of 'ae' in them. I'll leave that to you to resolve.)
 http://us.php.net/manual/en/regexp.reference.php



  Many thanks again for your effort,
 
  I'm definitely on the good way
 
   Giulio
 
 
 
  I was intrigued by your example, so I played around with it some more
  this morning. My own quick web search yielded a lot of results for
  highlighting search terms, but none that I found did what you're
  after. (I admit I didn't look very deep.) I was up to something like
  this before your reply came in. It's still by no means complete. It
  even handles simple English plurals (words ending in 's' or 'es'), but
  not variations that require changing the word base (like 'daisy' to
  'daisies').
 
  ?php
  function highlight_search_terms($phrase, $string) {
$non_letter_chars = '/[^\pL]/iu';
$words = preg_split($non_letter_chars, $phrase);
 
$search_words = array();
foreach ($words as $word) {
if (strlen($word)  2  !preg_match($non_letter_chars, $word)) {
$search_words[] = $word;
}
}
 
$search_words = array_unique($search_words);
 
foreach ($search_words as $word) {
$search = preg_quote($word);
 
/* repeat for each possible accented character */
$search = preg_replace('/(ae|æ|ǽ)/iu', '(ae|æ|ǽ)', $search);
$search = preg_replace('/(oe|œ)/iu', '(oe|œ)', $search);
  

Re: [PHP] case and accent - insensitive regular expression?

2008-07-15 Thread Yeti
Oh, and i forgot about this one ...

jorge at seisbits dot com
wrote on 11-Jul-2008 09:04
If you try to make a strtr of not usual charafters when you are in a utf8
enviroment, you can do that:

function normaliza ($string){
  $string = utf8_decode($string);
  $string = strtr($string, utf8_decode( ÂÊÎÔÛÀ), -AEIOU);
  $string = strtolower($string);
  return $string;
}


On Tue, Jul 15, 2008 at 11:38 AM, Yeti [EMAIL PROTECTED] wrote:

 I dont think using all these regular expressions is a very efficient way to
 do so. As i previously pointed out there are many users who had a similar
 problem, which can be viewed at:

 http://it.php.net/manual/en/function.strtr.php

 One of my favourites is what derernst at gmx dot ch used.

 derernst at gmx dot ch
 wrote on 20-Sep-2005 07:29
 This works for me to remove accents for some characters of Latin-1, Latin-2
 and Turkish in a UTF-8 environment, where the htmlentities-based solutions
 fail:

 ?php

 function remove_accents($string, $german=false) {

   // Single letters

   $single_fr = explode( , � � � � � � #260; #258; � #262; #268;
 #270; #272; � � � � � #280; #282; #286; � � � � #304; #321; #317;
 #313; � #323; #327; � � � � � � #336; #340; #344; � #346; #350;
 #356; #354; � � � � #366; #368; � � #377; #379; � � � � � � #261;
 #259; � #263; #269; #271; #273; � � � � #281; #283; #287; � � � �
 #305; #322; #318; #314; � #324; #328; � � � � � � � #337; #341;
 #345; #347; � #351; #357; #355; � � � � #367; #369; � � � #378;
 #380;);

   $single_to = explode( , A A A A A A A A C C C D D D E E E E E E G I I
 I I I L L L N N N O O O O O O O R R S S S T T U U U U U U Y Z Z Z a a a a a
 a a a c c c d d e e e e e e g i i i i i l l l n n n o o o o o o o o r r s s
 s t t u u u u u u y y z z z);

   $single = array();

   for ($i=0; $icount($single_fr); $i++) {

   $single[$single_fr[$i]] = $single_to[$i];

   }

   // Ligatures

   $ligatures = array(�=Ae, �=ae, �=Oe, �=oe,
 �=ss);

   // German umlauts

   $umlauts = array(�=Ae, �=ae, �=Oe, �=oe, �=Ue,
 �=ue);

   // Replace

   $replacements = array_merge($single, $ligatures);

   if ($german) $replacements = array_merge($replacements, $umlauts);

   $string = strtr($string, $replacements);

   return $string;

 }

 ?

 I would change this function a bit ...

 ?php
 //echo rawurlencode(áàéèíìóòúùÁÀÉÈÍÌÓÒÚÙ); // RFC 1738 codes; NOTE: One
 might use UTF-8 as this documents encoding
 function remove_accents($string) {
  $string = rawurlencode($string);
  $replacements = array(
  '%C3%A1' = 'a',
  '%C3%A0' = 'a',
  '%C3%A9' = 'e',
  '%C3%A8' = 'e',
  '%C3%AD' = 'i',
  '%C3%AC' = 'i',
  '%C3%B3' = 'o',
  '%C3%B2' = 'o',
  '%C3%BA' = 'u',
  '%C3%B9' = 'u',
  '%C3%81' = 'A',
  '%C3%80' = 'A',
  '%C3%89' = 'E',
  '%C3%88' = 'E',
  '%C3%8D' = 'I',
  '%C3%8C' = 'I',
  '%C3%93' = 'O',
  '%C3%92' = 'O',
  '%C3%9A' = 'U',
  '%C3%99' = 'U'
  );
  return strtr($string, $replacements);
 }
 //echo remove_accents(CÀfé); // I know it's not spelled right
 echo remove_accents(áàéèíìóòúùÁÀÉÈÍÌÓÒÚÙ); //OUTPUT (again: i used UTF-8
 for document): aaeeiioouuAAEEIIOOUU
 ?

 Ciao

 Yeti
 On Mon, Jul 14, 2008 at 8:20 PM, Andrew Ballard [EMAIL PROTECTED]
 wrote:

 On Mon, Jul 14, 2008 at 1:35 PM, Giulio Mastrosanti
 [EMAIL PROTECTED] wrote:
 
 
  Brilliant !!!
 
  so you replace every occurence of every accent variation with all the
 accent
  variations...
 
  OK, that's it!
 
  only some more doubts ( regex are still an headhache for me... )
 
  preg_replace('/[iìíîïĩīĭįı]/iu',...  -- what's the meaning of iu after
 the
  match string?

 This page explains them both.
 http://us.php.net/manual/en/reference.pcre.pattern.modifiers.php

  preg_replace('/[aàáâãäåǻāăą](?!e)/iu',... whats (?!e)  for? -- every
  occurence of aàáâãäåǻāăą NOT followed by e?

 Yes. It matches any character based on the latin 'a' that is not
 followed by an 'e'. It keeps the pattern from matching the 'a' when it
 immediately precedes an 'e' for the character 'ae' for words like
 these:

 http://en.wikipedia.org/wiki/List_of_words_that_may_be_spelled_with_a_ligature
 (However, that may cause problems with words that have other variants
 of 'ae' in them. I'll leave that to you to resolve.)
 http://us.php.net/manual/en/regexp.reference.php



  Many thanks again for your effort,
 
  I'm definitely on the good way
 
   Giulio
 
 
 
  I was intrigued by your example, so I played around with it some more
  this morning. My own quick web search yielded a lot of results for
  highlighting search terms, but none that I found did what you're
  after. (I admit I didn't look very deep.) I was up to something like
  this before your reply came in. It's still by no means complete. It
  even handles simple English plurals (words ending in 's' or 'es'), but
  not variations that require changing the word base (like 'daisy' to
  'daisies').
 
  ?php
  function highlight_search_terms($phrase, $string) {
$non_letter_chars = '/[^\pL]/iu';
$words = preg_split($non_letter_chars, $phrase);

Re: [PHP] Advice on a radar chart

2008-07-15 Thread Bernhard Kohl
If you are willing to use googles chart api ..

http://code.google.com/apis/chart/#radar

Yeti

On Tue, Jul 15, 2008 at 11:35 AM, Richard Heyes [EMAIL PROTECTED]
wrote:

 Hey,

 Can anyone suggest an efficient method for plotting the marks on a radar
 chart? I have the background done (
 http://www.phpguru.org/downloads/HTML5_radar/ - FF required), but that not
 exactly difficult.

 Cheers.

 --
 Richard Heyes

 Employ me:
 http://www.phpguru.org/cv

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




[PHP] Login without cookies enabled help

2008-07-15 Thread Shelley
Hi all,

What is your way to organize user login without Client Cookies being
disabled?

Sample code will be appreciated.

Waiting for your reply...

-- 
Regards,
Shelley


RE: [PHP] Math Weirdness

2008-07-15 Thread Ford, Mike
On 14 July 2008 20:47, tedd advised:

 Round-off errors normally don't enter into things unless your doing
 multiplication and division operations. At that point, what you get
 back from the operation is an approximation and not the actual
 number.

Bull! Nearly all computer floating point numbers are approximations
because of being held in binary rather than decimal. Any number with a
(decimal) fractional part that doesn't end with the digit 5 is
necessarily an approximation, and that's only half the story. So as soon
as you involve numbers like 0.1 or 0.2, you've already got minor
inaccuracies which will propagate through any kind of arithmetic -- it's
just worse with multiplication or division because these tend to result
in inaccuracy in more significant digits!

Bottom line: a floating point value should *always* be treated with an
appropriate degree of suspicion.

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
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



[PHP] Re: Login without cookies enabled help

2008-07-15 Thread Shelley
Sorry, should be with Client Cookies being disabled :)

On Tue, Jul 15, 2008 at 6:24 PM, Shelley [EMAIL PROTECTED] wrote:

 Hi all,

 What is your way to organize user login without Client Cookies being
 disabled?

 Sample code will be appreciated.

 Waiting for your reply...

 --
 Regards,
 Shelley




-- 
Regards,
Shelley


RE: [PHP] Math Weirdness

2008-07-15 Thread Ford, Mike
On 14 July 2008 21:44, Jay Blanchard advised:

 [snip]
 So does that mean your problem is solved?
 [/snip]
 
 It would appear so. I just need to remember to check for absolute
values
 when working with floats.

Yeah, that's Computer Science 101 stuff.  (Well, it was when I did my
degree 30+ years ago, so it's probably nearer primary school level by
now ;)

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
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] mkdir permission errors

2008-07-15 Thread Wei, Alice J.


-Original Message-
From: Peter Ford [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2008 4:06 AM
To: php-general@lists.php.net
Subject: Re: [PHP] mkdir permission errors

Wei, Alice J. wrote:
 Hi, Rob:

   I forgot to mention that I have been using yum install.
   I have reinstalled the entire thing, put back all the packages, and then I 
 went to /var and did a chmod -R 777 var, and then did a

[EMAIL PROTECTED] var]# chown -R apache:apache .

 Interestingly, I do not see anything different, and I still get this error 
 that says my permission is denied. Here is my

 [EMAIL PROTECTED] var]#  ps awxu | grep -E 'apache|httpd'
 root 31547  0.0  0.3  21268  6584 ?Ss   16:12   0:00 
 /usr/sbin/httpd
 apache   31549  0.0  0.2  21400  5572 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31550  0.0  0.2  21400  4908 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31551  0.0  0.2  21400  4908 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31552  0.0  0.2  21400  4896 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31553  0.0  0.2  21268  4860 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31554  0.0  0.2  21268  4860 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31555  0.0  0.2  21268  4860 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31556  0.0  0.2  21268  4860 ?S16:12   0:00 
 /usr/sbin/httpd
 root 31708  0.0  0.0   4120   728 pts/1R+   16:30   0:00 grep -E 
 apache|httpd

 Obviously, my last one has already changed the owner to apache 
 already.Nevertheless, I am still denied even when I am now logged in as root. 
 Is this anything with firewalls?


Hang on a minute: you're original message said the error was:

Warning: chmod() [function.chmod]: Permission denied in
/usr/local/apache/htdocs/file_linux.php on line 27

But you say you've re-installed, and done chmod -R 777 var and chown -R
apache:apache . in /var

A few things there:
When you are changing permissions and ownerships on such a large scale, you
should always use absolute paths to be sure you are doing the right thing - like
chmod -R 777 /var and chown -R apache:apache /var

Next, changing permission and ownership recursively on something like /var is
likely to wreck your system in weird and wonderful ways, and is pretty difficult
to undo - you might be looking at a total OS reinstall here (once you've solved
your Apache problems)

Finally, the error message refers to a file in /usr/local/apache/htdocs, but you
then are changing permissions in /var - where is your web root?! It looks like
your PHP code has the /usr/local/apache/htdocs path hard-coded, when your web
files are actually in /var/something...

I forgot to mention that I use Fedora on a Linux machine. I used yum install 
apache and yum install php to install my packages. Therefore, I don't have a 
/usr/local/apache/htdocs folder. The web root is now /var/www/html, which 
originally I do have /usr/local/apache/htdocs that I configured during previous 
installations. This is not there anymore after my reinstallations since 
yesterday.

Do I really have to reinstall the entire Fedora? I hate to say that my scripts 
worked fine BEFORE yesterday until the power went out and nothing went right 
after I have restarted the entire system.

Alice

--
Peter Ford  phone: 01580 89
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


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



Re: [PHP] Login without cookies enabled help

2008-07-15 Thread Thijs Lensselink

Quoting Shelley [EMAIL PROTECTED]:


Hi all,

What is your way to organize user login without Client Cookies being
disabled?

Sample code will be appreciated.

Waiting for your reply...

--
Regards,
Shelley



You can use sessions to store data on the server instead of the client.

http://nl2.php.net/manual/en/ref.session.php

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



Re: [PHP] mkdir permission errors

2008-07-15 Thread Peter Ford

Wei, Alice J. wrote:


-Original Message-
From: Peter Ford [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2008 4:06 AM
To: php-general@lists.php.net
Subject: Re: [PHP] mkdir permission errors

Wei, Alice J. wrote:

Hi, Rob:

  I forgot to mention that I have been using yum install.
  I have reinstalled the entire thing, put back all the packages, and then I 
went to /var and did a chmod -R 777 var, and then did a

   [EMAIL PROTECTED] var]# chown -R apache:apache .

Interestingly, I do not see anything different, and I still get this error that 
says my permission is denied. Here is my

[EMAIL PROTECTED] var]#  ps awxu | grep -E 'apache|httpd'
root 31547  0.0  0.3  21268  6584 ?Ss   16:12   0:00 /usr/sbin/httpd
apache   31549  0.0  0.2  21400  5572 ?S16:12   0:00 /usr/sbin/httpd
apache   31550  0.0  0.2  21400  4908 ?S16:12   0:00 /usr/sbin/httpd
apache   31551  0.0  0.2  21400  4908 ?S16:12   0:00 /usr/sbin/httpd
apache   31552  0.0  0.2  21400  4896 ?S16:12   0:00 /usr/sbin/httpd
apache   31553  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31554  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31555  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31556  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
root 31708  0.0  0.0   4120   728 pts/1R+   16:30   0:00 grep -E 
apache|httpd

Obviously, my last one has already changed the owner to apache 
already.Nevertheless, I am still denied even when I am now logged in as root. 
Is this anything with firewalls?



Hang on a minute: you're original message said the error was:

Warning: chmod() [function.chmod]: Permission denied in
/usr/local/apache/htdocs/file_linux.php on line 27

But you say you've re-installed, and done chmod -R 777 var and chown -R
apache:apache . in /var

A few things there:
When you are changing permissions and ownerships on such a large scale, you
should always use absolute paths to be sure you are doing the right thing - like
chmod -R 777 /var and chown -R apache:apache /var

Next, changing permission and ownership recursively on something like /var is
likely to wreck your system in weird and wonderful ways, and is pretty difficult
to undo - you might be looking at a total OS reinstall here (once you've solved
your Apache problems)

Finally, the error message refers to a file in /usr/local/apache/htdocs, but you
then are changing permissions in /var - where is your web root?! It looks like
your PHP code has the /usr/local/apache/htdocs path hard-coded, when your web
files are actually in /var/something...

I forgot to mention that I use Fedora on a Linux machine. I used yum install 
apache and yum install php to install my packages. Therefore, I don't have a 
/usr/local/apache/htdocs folder. The web root is now /var/www/html, which 
originally I do have /usr/local/apache/htdocs that I configured during previous 
installations. This is not there anymore after my reinstallations since 
yesterday.

Do I really have to reinstall the entire Fedora? I hate to say that my scripts 
worked fine BEFORE yesterday until the power went out and nothing went right 
after I have restarted the entire system.

Alice



You don't *have* to reinstall Fedora (yet) - that was just a warning that 
changing ownership and permissions on /var might cause some problems later...


So the question is, does the error message say that it cannot change 
permissions on
/usr/local/apache/htdocs/file_linux.php
or
 /var/www/html/file_linux.php
?

And does your PHP script have the correct path?

The original problem may just have been that the /usr/local file system was 
mounted read-only after the power outage (perhaps due to some disk corruption 
caused by the failure?). Since then you have reinstalled apache, but possibly 
not in the place your PHP script expects it to be. That would be my first thing 
to check...


--
Peter Ford, Developer phone: 01580 89 fax: 01580 893399
Justcroft International Ltd.  www.justcroft.com
Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United Kingdom
Registered in England and Wales: 2297906
Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS

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



Re: [PHP] Login without cookies enabled help

2008-07-15 Thread php
[quote] 
On Tue , Thijs Lensselink [EMAIL PROTECTED] sent: 

Quoting Shelley [EMAIL PROTECTED]: 

 Hi all, 
 
 What is your way to organize user login without Client Cookies being 
 disabled? 
 
 Sample code will be appreciated. 
 
 Waiting for your reply... 
 
 -- 
 Regards, 
 Shelley 
 

You can use sessions to store data on the server instead of the client. 

http://nl2.php.net/manual/en/ref.session.php 
[/quote] 

Just be careful as sessions default to using cookies. Otherwise, pass the 
session id with the query 
string of links!! 

Alex


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



RE: [PHP] mkdir permission errors

2008-07-15 Thread Wei, Alice J.

From: Peter Ford [EMAIL PROTECTED]
Sent: Tuesday, July 15, 2008 7:28 AM
To: Wei, Alice J.
Cc: php-general@lists.php.net
Subject: Re: [PHP] mkdir permission errors

Wei, Alice J. wrote:

 -Original Message-
 From: Peter Ford [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, July 15, 2008 4:06 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] mkdir permission errors

 Wei, Alice J. wrote:
 Hi, Rob:

   I forgot to mention that I have been using yum install.
   I have reinstalled the entire thing, put back all the packages, and then I 
 went to /var and did a chmod -R 777 var, and then did a

[EMAIL PROTECTED] var]# chown -R apache:apache .

 Interestingly, I do not see anything different, and I still get this error 
 that says my permission is denied. Here is my

 [EMAIL PROTECTED] var]#  ps awxu | grep -E 'apache|httpd'
 root 31547  0.0  0.3  21268  6584 ?Ss   16:12   0:00 
 /usr/sbin/httpd
 apache   31549  0.0  0.2  21400  5572 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31550  0.0  0.2  21400  4908 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31551  0.0  0.2  21400  4908 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31552  0.0  0.2  21400  4896 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31553  0.0  0.2  21268  4860 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31554  0.0  0.2  21268  4860 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31555  0.0  0.2  21268  4860 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31556  0.0  0.2  21268  4860 ?S16:12   0:00 
 /usr/sbin/httpd
 root 31708  0.0  0.0   4120   728 pts/1R+   16:30   0:00 grep -E 
 apache|httpd

 Obviously, my last one has already changed the owner to apache 
 already.Nevertheless, I am still denied even when I am now logged in as 
 root. Is this anything with firewalls?


 Hang on a minute: you're original message said the error was:

 Warning: chmod() [function.chmod]: Permission denied in
 /usr/local/apache/htdocs/file_linux.php on line 27

 But you say you've re-installed, and done chmod -R 777 var and chown -R
 apache:apache . in /var

 A few things there:
 When you are changing permissions and ownerships on such a large scale, you
 should always use absolute paths to be sure you are doing the right thing - 
 like
 chmod -R 777 /var and chown -R apache:apache /var

 Next, changing permission and ownership recursively on something like /var is
 likely to wreck your system in weird and wonderful ways, and is pretty 
 difficult
 to undo - you might be looking at a total OS reinstall here (once you've 
 solved
 your Apache problems)

 Finally, the error message refers to a file in /usr/local/apache/htdocs, but 
 you
 then are changing permissions in /var - where is your web root?! It looks like
 your PHP code has the /usr/local/apache/htdocs path hard-coded, when your web
 files are actually in /var/something...

 I forgot to mention that I use Fedora on a Linux machine. I used yum install 
 apache and yum install php to install my packages. Therefore, I don't have a 
 /usr/local/apache/htdocs folder. The web root is now /var/www/html, which 
 originally I do have /usr/local/apache/htdocs that I configured during 
 previous installations. This is not there anymore after my reinstallations 
 since yesterday.

 Do I really have to reinstall the entire Fedora? I hate to say that my 
 scripts worked fine BEFORE yesterday until the power went out and nothing 
 went right after I have restarted the entire system.

 Alice


You don't *have* to reinstall Fedora (yet) - that was just a warning that
changing ownership and permissions on /var might cause some problems later...

So the question is, does the error message say that it cannot change 
permissions on
/usr/local/apache/htdocs/file_linux.php
or
 /var/www/html/file_linux.php
?

This portion is to answer Rob's question:

[EMAIL PROTECTED] var]# ls -la
total 92
drwxrwxrwx 22 root root 4096 2008-06-24 08:34 .
drwxr-xr-x 21 root root 4096 2008-07-14 08:17 ..
drwxrwxrwx  2 root root 4096 2008-06-24 08:25 account
drwxrwxrwx 13 root root 4096 2008-07-14 16:07 cache
drwxrwxrwx  2 root root 4096 2008-02-19 20:47 cvs
drwxrwxrwx  3 root root 4096 2008-06-24 08:25 db
drwxrwxrwx  3 root root 4096 2008-06-24 08:29 empty
drwxrwxrwx  2 root root 4096 2008-04-07 17:44 games
drwxrwxrwx  2 root root 4096 2008-05-01 22:45 gdm
drwxrwxrwx 35 root root 4096 2008-07-14 16:07 lib
drwxrwxrwx  2 root root 4096 2008-04-07 17:44 local
drwxrwxrwx  5 root root 4096 2008-07-15 04:10 lock
drwxrwxrwx 17 root root 4096 2008-07-15 04:10 log
lrwxrwxrwx  1 root root   10 2008-06-24 08:24 mail - spool/mail
drwxrwxrwx  6 root root 4096 2008-06-24 08:26 named
drwxrwxrwx  2 root root 4096 2008-04-07 17:44 nis
drwxrwxrwx  2 root root 4096 2008-04-07 17:44 opt
drwxrwxrwx  2 root root 4096 2008-04-07 17:44 preserve
drwxrwxrwx 27 root root 4096 2008-07-14 16:12 run
drwxrwxrwx 13 root root 4096 2008-06-24 08:35 spool

Re: [PHP] mkdir permission errors

2008-07-15 Thread Peter Ford

Wei, Alice J. wrote:

From: Peter Ford [EMAIL PROTECTED]
Sent: Tuesday, July 15, 2008 7:28 AM
To: Wei, Alice J.
Cc: php-general@lists.php.net
Subject: Re: [PHP] mkdir permission errors

Wei, Alice J. wrote:

-Original Message-
From: Peter Ford [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2008 4:06 AM
To: php-general@lists.php.net
Subject: Re: [PHP] mkdir permission errors

Wei, Alice J. wrote:

Hi, Rob:

  I forgot to mention that I have been using yum install.
  I have reinstalled the entire thing, put back all the packages, and then I 
went to /var and did a chmod -R 777 var, and then did a

   [EMAIL PROTECTED] var]# chown -R apache:apache .

Interestingly, I do not see anything different, and I still get this error that 
says my permission is denied. Here is my

[EMAIL PROTECTED] var]#  ps awxu | grep -E 'apache|httpd'
root 31547  0.0  0.3  21268  6584 ?Ss   16:12   0:00 /usr/sbin/httpd
apache   31549  0.0  0.2  21400  5572 ?S16:12   0:00 /usr/sbin/httpd
apache   31550  0.0  0.2  21400  4908 ?S16:12   0:00 /usr/sbin/httpd
apache   31551  0.0  0.2  21400  4908 ?S16:12   0:00 /usr/sbin/httpd
apache   31552  0.0  0.2  21400  4896 ?S16:12   0:00 /usr/sbin/httpd
apache   31553  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31554  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31555  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31556  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
root 31708  0.0  0.0   4120   728 pts/1R+   16:30   0:00 grep -E 
apache|httpd

Obviously, my last one has already changed the owner to apache 
already.Nevertheless, I am still denied even when I am now logged in as root. 
Is this anything with firewalls?


Hang on a minute: you're original message said the error was:

Warning: chmod() [function.chmod]: Permission denied in
/usr/local/apache/htdocs/file_linux.php on line 27

But you say you've re-installed, and done chmod -R 777 var and chown -R
apache:apache . in /var

A few things there:
When you are changing permissions and ownerships on such a large scale, you
should always use absolute paths to be sure you are doing the right thing - like
chmod -R 777 /var and chown -R apache:apache /var

Next, changing permission and ownership recursively on something like /var is
likely to wreck your system in weird and wonderful ways, and is pretty difficult
to undo - you might be looking at a total OS reinstall here (once you've solved
your Apache problems)

Finally, the error message refers to a file in /usr/local/apache/htdocs, but you
then are changing permissions in /var - where is your web root?! It looks like
your PHP code has the /usr/local/apache/htdocs path hard-coded, when your web
files are actually in /var/something...

I forgot to mention that I use Fedora on a Linux machine. I used yum install 
apache and yum install php to install my packages. Therefore, I don't have a 
/usr/local/apache/htdocs folder. The web root is now /var/www/html, which 
originally I do have /usr/local/apache/htdocs that I configured during previous 
installations. This is not there anymore after my reinstallations since 
yesterday.

Do I really have to reinstall the entire Fedora? I hate to say that my scripts 
worked fine BEFORE yesterday until the power went out and nothing went right 
after I have restarted the entire system.

Alice



You don't *have* to reinstall Fedora (yet) - that was just a warning that
changing ownership and permissions on /var might cause some problems later...

So the question is, does the error message say that it cannot change 
permissions on
/usr/local/apache/htdocs/file_linux.php
or
 /var/www/html/file_linux.php
?

This portion is to answer Rob's question:

[EMAIL PROTECTED] var]# ls -la
total 92
drwxrwxrwx 22 root root 4096 2008-06-24 08:34 .
drwxr-xr-x 21 root root 4096 2008-07-14 08:17 ..
drwxrwxrwx  2 root root 4096 2008-06-24 08:25 account
drwxrwxrwx 13 root root 4096 2008-07-14 16:07 cache
drwxrwxrwx  2 root root 4096 2008-02-19 20:47 cvs
drwxrwxrwx  3 root root 4096 2008-06-24 08:25 db
drwxrwxrwx  3 root root 4096 2008-06-24 08:29 empty
drwxrwxrwx  2 root root 4096 2008-04-07 17:44 games
drwxrwxrwx  2 root root 4096 2008-05-01 22:45 gdm
drwxrwxrwx 35 root root 4096 2008-07-14 16:07 lib
drwxrwxrwx  2 root root 4096 2008-04-07 17:44 local
drwxrwxrwx  5 root root 4096 2008-07-15 04:10 lock
drwxrwxrwx 17 root root 4096 2008-07-15 04:10 log
lrwxrwxrwx  1 root root   10 2008-06-24 08:24 mail - spool/mail
drwxrwxrwx  6 root root 4096 2008-06-24 08:26 named
drwxrwxrwx  2 root root 4096 2008-04-07 17:44 nis
drwxrwxrwx  2 root root 4096 2008-04-07 17:44 opt
drwxrwxrwx  2 root root 4096 2008-04-07 17:44 preserve
drwxrwxrwx 27 root root 4096 2008-07-14 16:12 run
drwxrwxrwx 13 root root 4096 2008-06-24 08:35 spool
drwxrwxrwx  2 root root 4096 2008-07-14 16:10 tmp
drwxrwxrwx  8 

RE: [PHP] mkdir permission errors

2008-07-15 Thread Wei, Alice J.

From: Peter Ford [EMAIL PROTECTED]
Sent: Tuesday, July 15, 2008 7:28 AM
To: Wei, Alice J.
Cc: php-general@lists.php.net
Subject: Re: [PHP] mkdir permission errors

Wei, Alice J. wrote:

 -Original Message-
 From: Peter Ford [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, July 15, 2008 4:06 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] mkdir permission errors

 Wei, Alice J. wrote:
 Hi, Rob:

   I forgot to mention that I have been using yum install.
   I have reinstalled the entire thing, put back all the packages, and then I 
 went to /var and did a chmod -R 777 var, and then did a

[EMAIL PROTECTED] var]# chown -R apache:apache .

 Interestingly, I do not see anything different, and I still get this error 
 that says my permission is denied. Here is my

 [EMAIL PROTECTED] var]#  ps awxu | grep -E 'apache|httpd'
 root 31547  0.0  0.3  21268  6584 ?Ss   16:12   0:00 
 /usr/sbin/httpd
 apache   31549  0.0  0.2  21400  5572 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31550  0.0  0.2  21400  4908 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31551  0.0  0.2  21400  4908 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31552  0.0  0.2  21400  4896 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31553  0.0  0.2  21268  4860 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31554  0.0  0.2  21268  4860 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31555  0.0  0.2  21268  4860 ?S16:12   0:00 
 /usr/sbin/httpd
 apache   31556  0.0  0.2  21268  4860 ?S16:12   0:00 
 /usr/sbin/httpd
 root 31708  0.0  0.0   4120   728 pts/1R+   16:30   0:00 grep -E 
 apache|httpd

 Obviously, my last one has already changed the owner to apache 
 already.Nevertheless, I am still denied even when I am now logged in as 
 root. Is this anything with firewalls?


 Hang on a minute: you're original message said the error was:

 Warning: chmod() [function.chmod]: Permission denied in
 /usr/local/apache/htdocs/file_linux.php on line 27

 But you say you've re-installed, and done chmod -R 777 var and chown -R
 apache:apache . in /var

 A few things there:
 When you are changing permissions and ownerships on such a large scale, you
 should always use absolute paths to be sure you are doing the right thing - 
 like
 chmod -R 777 /var and chown -R apache:apache /var

 Next, changing permission and ownership recursively on something like /var is
 likely to wreck your system in weird and wonderful ways, and is pretty 
 difficult
 to undo - you might be looking at a total OS reinstall here (once you've 
 solved
 your Apache problems)

 Finally, the error message refers to a file in /usr/local/apache/htdocs, but 
 you
 then are changing permissions in /var - where is your web root?! It looks like
 your PHP code has the /usr/local/apache/htdocs path hard-coded, when your web
 files are actually in /var/something...

 I forgot to mention that I use Fedora on a Linux machine. I used yum install 
 apache and yum install php to install my packages. Therefore, I don't have a 
 /usr/local/apache/htdocs folder. The web root is now /var/www/html, which 
 originally I do have /usr/local/apache/htdocs that I configured during 
 previous installations. This is not there anymore after my reinstallations 
 since yesterday.

 Do I really have to reinstall the entire Fedora? I hate to say that my 
 scripts worked fine BEFORE yesterday until the power went out and nothing 
 went right after I have restarted the entire system.

 Alice


You don't *have* to reinstall Fedora (yet) - that was just a warning that
changing ownership and permissions on /var might cause some problems later...

So the question is, does the error message say that it cannot change 
permissions on
/usr/local/apache/htdocs/file_linux.php
or
 /var/www/html/file_linux.php
?

And does your PHP script have the correct path?

The original problem may just have been that the /usr/local file system was
mounted read-only after the power outage (perhaps due to some disk corruption
caused by the failure?). Since then you have reinstalled apache, but possibly
not in the place your PHP script expects it to be. That would be my first thing
to check...

This sounds really dumb, but it turned out that I have some inconsistencies 
going on in my httpd.conf file. Now I have changed both groups to daemon, and 
changed to owners as Rob suggested. Now it is finally working fine. Would I 
still need to change everything back to 0755? Or, should I ask, what is the 
appropriate permission I should be using here?

Alice
--
Peter Ford, Developer phone: 01580 89 fax: 01580 893399
Justcroft International Ltd.  www.justcroft.com
Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United Kingdom
Registered in England and Wales: 2297906
Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 

RE: [PHP] Math Weirdness

2008-07-15 Thread Jay Blanchard
[snip]
 It would appear so. I just need to remember to check for absolute
values
 when working with floats.

Yeah, that's Computer Science 101 stuff.  (Well, it was when I did my
degree 30+ years ago, so it's probably nearer primary school level by
now ;)
[/snip]

This is what happens when you spend a lot of time managing projects and
then have a need to step in and write some quick little application. The
rust has frozen all of the things you should remember to do! :)

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



Re: [PHP] mkdir permission errors

2008-07-15 Thread Peter Ford

Wei, Alice J. wrote:


From: Peter Ford [EMAIL PROTECTED]
Sent: Tuesday, July 15, 2008 7:28 AM
To: Wei, Alice J.
Cc: php-general@lists.php.net
Subject: Re: [PHP] mkdir permission errors

Wei, Alice J. wrote:

-Original Message-
From: Peter Ford [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2008 4:06 AM
To: php-general@lists.php.net
Subject: Re: [PHP] mkdir permission errors

Wei, Alice J. wrote:

Hi, Rob:

  I forgot to mention that I have been using yum install.
  I have reinstalled the entire thing, put back all the packages, and then I 
went to /var and did a chmod -R 777 var, and then did a

   [EMAIL PROTECTED] var]# chown -R apache:apache .

Interestingly, I do not see anything different, and I still get this error that 
says my permission is denied. Here is my

[EMAIL PROTECTED] var]#  ps awxu | grep -E 'apache|httpd'
root 31547  0.0  0.3  21268  6584 ?Ss   16:12   0:00 /usr/sbin/httpd
apache   31549  0.0  0.2  21400  5572 ?S16:12   0:00 /usr/sbin/httpd
apache   31550  0.0  0.2  21400  4908 ?S16:12   0:00 /usr/sbin/httpd
apache   31551  0.0  0.2  21400  4908 ?S16:12   0:00 /usr/sbin/httpd
apache   31552  0.0  0.2  21400  4896 ?S16:12   0:00 /usr/sbin/httpd
apache   31553  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31554  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31555  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31556  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
root 31708  0.0  0.0   4120   728 pts/1R+   16:30   0:00 grep -E 
apache|httpd

Obviously, my last one has already changed the owner to apache 
already.Nevertheless, I am still denied even when I am now logged in as root. 
Is this anything with firewalls?


Hang on a minute: you're original message said the error was:

Warning: chmod() [function.chmod]: Permission denied in
/usr/local/apache/htdocs/file_linux.php on line 27

But you say you've re-installed, and done chmod -R 777 var and chown -R
apache:apache . in /var

A few things there:
When you are changing permissions and ownerships on such a large scale, you
should always use absolute paths to be sure you are doing the right thing - like
chmod -R 777 /var and chown -R apache:apache /var

Next, changing permission and ownership recursively on something like /var is
likely to wreck your system in weird and wonderful ways, and is pretty difficult
to undo - you might be looking at a total OS reinstall here (once you've solved
your Apache problems)

Finally, the error message refers to a file in /usr/local/apache/htdocs, but you
then are changing permissions in /var - where is your web root?! It looks like
your PHP code has the /usr/local/apache/htdocs path hard-coded, when your web
files are actually in /var/something...

I forgot to mention that I use Fedora on a Linux machine. I used yum install 
apache and yum install php to install my packages. Therefore, I don't have a 
/usr/local/apache/htdocs folder. The web root is now /var/www/html, which 
originally I do have /usr/local/apache/htdocs that I configured during previous 
installations. This is not there anymore after my reinstallations since 
yesterday.

Do I really have to reinstall the entire Fedora? I hate to say that my scripts 
worked fine BEFORE yesterday until the power went out and nothing went right 
after I have restarted the entire system.

Alice



You don't *have* to reinstall Fedora (yet) - that was just a warning that
changing ownership and permissions on /var might cause some problems later...

So the question is, does the error message say that it cannot change 
permissions on
/usr/local/apache/htdocs/file_linux.php
or
 /var/www/html/file_linux.php
?

And does your PHP script have the correct path?

The original problem may just have been that the /usr/local file system was
mounted read-only after the power outage (perhaps due to some disk corruption
caused by the failure?). Since then you have reinstalled apache, but possibly
not in the place your PHP script expects it to be. That would be my first thing
to check...

This sounds really dumb, but it turned out that I have some inconsistencies 
going on in my httpd.conf file. Now I have changed both groups to daemon, and 
changed to owners as Rob suggested. Now it is finally working fine. Would I 
still need to change everything back to 0755? Or, should I ask, what is the 
appropriate permission I should be using here?

Alice


At least that explains why the problem arose from a power failure: you had some 
new settings in the configuration which needed an apache restart to make them 
happen, and when the server rebooted, apache picked up the new settings...


The problem is that if you did chmod -R 777 /var, you changed every file /var 
and ALL of its subdirectories to have 777 permissions, and there's not an easy 
way 

RE: [PHP] Math Weirdness

2008-07-15 Thread tedd

At 11:24 AM +0100 7/15/08, Ford, Mike wrote:

On 14 July 2008 20:47, tedd advised:

  Round-off errors normally don't enter into things unless your doing
  multiplication and division operations. At that point, what you get

 back from the operation is an approximation and not the actual
 number.


Bull! Nearly all computer floating point numbers are approximations
because of being held in binary rather than decimal. Any number with a
(decimal) fractional part that doesn't end with the digit 5 is
necessarily an approximation, and that's only half the story. So as soon
as you involve numbers like 0.1 or 0.2, you've already got minor
inaccuracies which will propagate through any kind of arithmetic -- it's
just worse with multiplication or division because these tend to result
in inaccuracy in more significant digits!

Bottom line: a floating point value should *always* be treated with an
appropriate degree of suspicion.

Cheers!

Mike


Mike:

No reason to be rude.

I said:

Round-off errors normally don't enter into things unless your doing 
multiplication and division operations.


And that is not Bull -- it's true. You can add and subtract all the 
floating point numbers (the one's we are talking about here) you want 
without any rounding errors whatsoever.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] case and accent - insensitive regular expression?

2008-07-15 Thread Andrew Ballard
On Tue, Jul 15, 2008 at 5:38 AM, Yeti [EMAIL PROTECTED] wrote:
 I dont think using all these regular expressions is a very efficient way to
 do so. As i previously pointed out there are many users who had a similar
 problem, which can be viewed at:

 http://it.php.net/manual/en/function.strtr.php

 One of my favourites is what derernst at gmx dot ch used.

 derernst at gmx dot ch
 wrote on 20-Sep-2005 07:29
 This works for me to remove accents for some characters of Latin-1, Latin-2
 and Turkish in a UTF-8 environment, where the htmlentities-based solutions
 fail:

 ?php

 function remove_accents($string, $german=false) {

   // Single letters

   $single_fr = explode( , � � � � � � #260; #258; � #262; #268;
 #270; #272; � � � � � #280; #282; #286; � � � � #304; #321; #317;
 #313; � #323; #327; � � � � � � #336; #340; #344; � #346; #350;
 #356; #354; � � � � #366; #368; � � #377; #379; � � � � � � #261;
 #259; � #263; #269; #271; #273; � � � � #281; #283; #287; � � � �
 #305; #322; #318; #314; � #324; #328; � � � � � � � #337; #341;
 #345; #347; � #351; #357; #355; � � � � #367; #369; � � � #378;
 #380;);

   $single_to = explode( , A A A A A A A A C C C D D D E E E E E E G I I I
 I I L L L N N N O O O O O O O R R S S S T T U U U U U U Y Z Z Z a a a a a a
 a a c c c d d e e e e e e g i i i i i l l l n n n o o o o o o o o r r s s s
 t t u u u u u u y y z z z);

   $single = array();

   for ($i=0; $icount($single_fr); $i++) {

   $single[$single_fr[$i]] = $single_to[$i];

   }

   // Ligatures

   $ligatures = array(�=Ae, �=ae, �=Oe, �=oe, �=ss);

   // German umlauts

   $umlauts = array(�=Ae, �=ae, �=Oe, �=oe, �=Ue,
 �=ue);

   // Replace

   $replacements = array_merge($single, $ligatures);

   if ($german) $replacements = array_merge($replacements, $umlauts);

   $string = strtr($string, $replacements);

   return $string;

 }

 ?

 I would change this function a bit ...

 ?php
 //echo rawurlencode(áàéèíìóòúùÁÀÉÈÍÌÓÒÚÙ); // RFC 1738 codes; NOTE: One
 might use UTF-8 as this documents encoding
 function remove_accents($string) {
  $string = rawurlencode($string);
  $replacements = array(
  '%C3%A1' = 'a',
  '%C3%A0' = 'a',
  '%C3%A9' = 'e',
  '%C3%A8' = 'e',
  '%C3%AD' = 'i',
  '%C3%AC' = 'i',
  '%C3%B3' = 'o',
  '%C3%B2' = 'o',
  '%C3%BA' = 'u',
  '%C3%B9' = 'u',
  '%C3%81' = 'A',
  '%C3%80' = 'A',
  '%C3%89' = 'E',
  '%C3%88' = 'E',
  '%C3%8D' = 'I',
  '%C3%8C' = 'I',
  '%C3%93' = 'O',
  '%C3%92' = 'O',
  '%C3%9A' = 'U',
  '%C3%99' = 'U'
  );
  return strtr($string, $replacements);
 }
 //echo remove_accents(CÀfé); // I know it's not spelled right
 echo remove_accents(áàéèíìóòúùÁÀÉÈÍÌÓÒÚÙ); //OUTPUT (again: i used UTF-8
 for document): aaeeiioouuAAEEIIOOUU
 ?

 Ciao

 Yeti

 On Mon, Jul 14, 2008 at 8:20 PM, Andrew Ballard [EMAIL PROTECTED] wrote:

 On Mon, Jul 14, 2008 at 1:35 PM, Giulio Mastrosanti
 [EMAIL PROTECTED] wrote:
 
 
  Brilliant !!!
 
  so you replace every occurence of every accent variation with all the
  accent
  variations...
 
  OK, that's it!
 
  only some more doubts ( regex are still an headhache for me... )
 
  preg_replace('/[iìíîïĩīĭįı]/iu',...  -- what's the meaning of iu after
  the
  match string?

 This page explains them both.
 http://us.php.net/manual/en/reference.pcre.pattern.modifiers.php

  preg_replace('/[aàáâãäåǻāăą](?!e)/iu',... whats (?!e)  for? -- every
  occurence of aàáâãäåǻāăą NOT followed by e?

 Yes. It matches any character based on the latin 'a' that is not
 followed by an 'e'. It keeps the pattern from matching the 'a' when it
 immediately precedes an 'e' for the character 'ae' for words like
 these:

 http://en.wikipedia.org/wiki/List_of_words_that_may_be_spelled_with_a_ligature
 (However, that may cause problems with words that have other variants
 of 'ae' in them. I'll leave that to you to resolve.)
 http://us.php.net/manual/en/regexp.reference.php



  Many thanks again for your effort,
 
  I'm definitely on the good way
 
   Giulio
 
 
 
  I was intrigued by your example, so I played around with it some more
  this morning. My own quick web search yielded a lot of results for
  highlighting search terms, but none that I found did what you're
  after. (I admit I didn't look very deep.) I was up to something like
  this before your reply came in. It's still by no means complete. It
  even handles simple English plurals (words ending in 's' or 'es'), but
  not variations that require changing the word base (like 'daisy' to
  'daisies').
 
  ?php
  function highlight_search_terms($phrase, $string) {
$non_letter_chars = '/[^\pL]/iu';
$words = preg_split($non_letter_chars, $phrase);
 
$search_words = array();
foreach ($words as $word) {
if (strlen($word)  2  !preg_match($non_letter_chars, $word)) {
$search_words[] = $word;
}
}
 
$search_words = array_unique($search_words);
 
foreach ($search_words as $word) {
$search = preg_quote($word);
 
/* repeat for each possible accented 

Re: [PHP] Math Weirdness

2008-07-15 Thread Robin Vickery
2008/7/15 tedd [EMAIL PROTECTED]:

 I said:

 Round-off errors normally don't enter into things unless your doing
 multiplication and division operations.

 And that is not Bull -- it's true. You can add and subtract all the
 floating point numbers (the one's we are talking about here) you want
 without any rounding errors whatsoever.

$ php -r 'echo 0.7 - 0.2 == 0.5 ? true\n : false\n;'
false

The operation you do isn't important. You just can't represent certain
numbers exactly in binary, just as you can't represent 1/3 exactly in
decimal. They have to be rounded internally.

-robin

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



[PHP] Byte range support

2008-07-15 Thread Manuel Vacelet
Hello all,

How can I make my php apps aware of byte range HTTP request ?

I have a script that output data to user if she's granted to do so.
But as of today, if download fails, she must restart the download from
the beginning because my server (my php script) doesn't support range
byte requests (actually, this is what curl and wget claims!)

-- Manuel

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



[PHP] DB search and case sensitive comparison

2008-07-15 Thread Angelo Zanetti
Hi all, 

I have a question and I can't seem to get around the problem or finding a
total solution.

I have a DB with a list of entries, one of the tables has fields and one of
the fields is called the lookup_string field.

This field is used to checkup values when users enter the site (explained
below).


So basically what happens is that the user will enter the site and I will
get their user agent from the $_SERVER variable.

What I want to do is to find out which entries in the DB are present in the
useragent string.

Eg: 

lookup_string (in db): Mozilla

useragent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15)
Gecko/20080623 Firefox/2.0.0.15'

So what I did was I used the locate function in my mysql query which gives
me the correct result set.

Now what I need to do is to ensure that the lookup_string is in the
useragent string and the CASE is the same: IE: Mozilla and not MOZILLA or
mozilla etc...

I am using the following If (however it fails because its part of the
useragent string and not the whole complete string therefore providing a
mismatch).

if(strcmp($userAgent, $lookup_string)==0){

//matches
}
Else
{

//doesn't match
}

Which way could I accomplish searching for the lookup_string in the
useragent and that it's the correct case?

Thanks in advance.

Angelo





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



Re: [PHP] Freelance PHP development in India

2008-07-15 Thread Thiago Melo de Paula
Hello Denis,

normally Mr. Manuel Lemos would send this message, but, here is the hint:
you can search for professionals at the following link:
http://www.phpclasses.org/professionals/

I've take a look and in India had 333 PHP professionals!

Regards,

Thiago Melo de Paula

On Mon, Jul 14, 2008 at 4:12 PM, tedd wrote:

 At 12:20 PM +0800 7/14/08, Denis L. Menezes wrote:

 Dear friends.

 I am looking for freelance web developers in India.

 Can contact me?

 Thanks
 Denis


 Good luck.

 tedd




Re: [PHP] Login without cookies enabled help

2008-07-15 Thread Shelley
Well, as I said the cookies are disabled at the clients.

Anybody any opinions?

On Tue, Jul 15, 2008 at 7:23 PM, Thijs Lensselink [EMAIL PROTECTED] wrote:

 Quoting Shelley [EMAIL PROTECTED]:

  Hi all,

 What is your way to organize user login without Client Cookies being
 disabled?

 Sample code will be appreciated.

 Waiting for your reply...

 --
 Regards,
 Shelley


 You can use sessions to store data on the server instead of the client.

 http://nl2.php.net/manual/en/ref.session.php

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




-- 
Regards,
Shelley


Re: [PHP] case and accent - insensitive regular expression?

2008-07-15 Thread Andrew Ballard
On Tue, Jul 15, 2008 at 9:46 AM, Andrew Ballard [EMAIL PROTECTED] wrote:
 On Tue, Jul 15, 2008 at 5:38 AM, Yeti [EMAIL PROTECTED] wrote:
 I dont think using all these regular expressions is a very efficient way to
 do so. As i previously pointed out there are many users who had a similar
 problem, which can be viewed at:

 http://it.php.net/manual/en/function.strtr.php

 One of my favourites is what derernst at gmx dot ch used.

 derernst at gmx dot ch
 wrote on 20-Sep-2005 07:29
 This works for me to remove accents for some characters of Latin-1, Latin-2
 and Turkish in a UTF-8 environment, where the htmlentities-based solutions
 fail:

 ?php

 function remove_accents($string, $german=false) {

   // Single letters

   $single_fr = explode( , � � � � � � #260; #258; � #262; #268;
 #270; #272; � � � � � #280; #282; #286; � � � � #304; #321; #317;
 #313; � #323; #327; � � � � � � #336; #340; #344; � #346; #350;
 #356; #354; � � � � #366; #368; � � #377; #379; � � � � � � #261;
 #259; � #263; #269; #271; #273; � � � � #281; #283; #287; � � � �
 #305; #322; #318; #314; � #324; #328; � � � � � � � #337; #341;
 #345; #347; � #351; #357; #355; � � � � #367; #369; � � � #378;
 #380;);

   $single_to = explode( , A A A A A A A A C C C D D D E E E E E E G I I I
 I I L L L N N N O O O O O O O R R S S S T T U U U U U U Y Z Z Z a a a a a a
 a a c c c d d e e e e e e g i i i i i l l l n n n o o o o o o o o r r s s s
 t t u u u u u u y y z z z);

   $single = array();

   for ($i=0; $icount($single_fr); $i++) {

   $single[$single_fr[$i]] = $single_to[$i];

   }

   // Ligatures

   $ligatures = array(�=Ae, �=ae, �=Oe, �=oe, �=ss);

   // German umlauts

   $umlauts = array(�=Ae, �=ae, �=Oe, �=oe, �=Ue,
 �=ue);

   // Replace

   $replacements = array_merge($single, $ligatures);

   if ($german) $replacements = array_merge($replacements, $umlauts);

   $string = strtr($string, $replacements);

   return $string;

 }

 ?

 I would change this function a bit ...

 ?php
 //echo rawurlencode(áàéèíìóòúùÁÀÉÈÍÌÓÒÚÙ); // RFC 1738 codes; NOTE: One
 might use UTF-8 as this documents encoding
 function remove_accents($string) {
  $string = rawurlencode($string);
  $replacements = array(
  '%C3%A1' = 'a',
  '%C3%A0' = 'a',
  '%C3%A9' = 'e',
  '%C3%A8' = 'e',
  '%C3%AD' = 'i',
  '%C3%AC' = 'i',
  '%C3%B3' = 'o',
  '%C3%B2' = 'o',
  '%C3%BA' = 'u',
  '%C3%B9' = 'u',
  '%C3%81' = 'A',
  '%C3%80' = 'A',
  '%C3%89' = 'E',
  '%C3%88' = 'E',
  '%C3%8D' = 'I',
  '%C3%8C' = 'I',
  '%C3%93' = 'O',
  '%C3%92' = 'O',
  '%C3%9A' = 'U',
  '%C3%99' = 'U'
  );
  return strtr($string, $replacements);
 }
 //echo remove_accents(CÀfé); // I know it's not spelled right
 echo remove_accents(áàéèíìóòúùÁÀÉÈÍÌÓÒÚÙ); //OUTPUT (again: i used UTF-8
 for document): aaeeiioouuAAEEIIOOUU
 ?

 Ciao

 Yeti

 On Mon, Jul 14, 2008 at 8:20 PM, Andrew Ballard [EMAIL PROTECTED] wrote:

 On Mon, Jul 14, 2008 at 1:35 PM, Giulio Mastrosanti
 [EMAIL PROTECTED] wrote:
 
 
  Brilliant !!!
 
  so you replace every occurence of every accent variation with all the
  accent
  variations...
 
  OK, that's it!
 
  only some more doubts ( regex are still an headhache for me... )
 
  preg_replace('/[iìíîïĩīĭįı]/iu',...  -- what's the meaning of iu after
  the
  match string?

 This page explains them both.
 http://us.php.net/manual/en/reference.pcre.pattern.modifiers.php

  preg_replace('/[aàáâãäåǻāăą](?!e)/iu',... whats (?!e)  for? -- every
  occurence of aàáâãäåǻāăą NOT followed by e?

 Yes. It matches any character based on the latin 'a' that is not
 followed by an 'e'. It keeps the pattern from matching the 'a' when it
 immediately precedes an 'e' for the character 'ae' for words like
 these:

 http://en.wikipedia.org/wiki/List_of_words_that_may_be_spelled_with_a_ligature
 (However, that may cause problems with words that have other variants
 of 'ae' in them. I'll leave that to you to resolve.)
 http://us.php.net/manual/en/regexp.reference.php



  Many thanks again for your effort,
 
  I'm definitely on the good way
 
   Giulio
 
 
 
  I was intrigued by your example, so I played around with it some more
  this morning. My own quick web search yielded a lot of results for
  highlighting search terms, but none that I found did what you're
  after. (I admit I didn't look very deep.) I was up to something like
  this before your reply came in. It's still by no means complete. It
  even handles simple English plurals (words ending in 's' or 'es'), but
  not variations that require changing the word base (like 'daisy' to
  'daisies').
 
  ?php
  function highlight_search_terms($phrase, $string) {
$non_letter_chars = '/[^\pL]/iu';
$words = preg_split($non_letter_chars, $phrase);
 
$search_words = array();
foreach ($words as $word) {
if (strlen($word)  2  !preg_match($non_letter_chars, $word)) {
$search_words[] = $word;
}
}
 
$search_words = array_unique($search_words);
 
foreach ($search_words as $word) {
$search = 

Re: [PHP] Login without cookies enabled help

2008-07-15 Thread Daniel Brown
On Tue, Jul 15, 2008 at 10:15 AM, Shelley [EMAIL PROTECTED] wrote:
 Well, as I said the cookies are disabled at the clients.

 Anybody any opinions?

Yes, again, STFW before posting here.

Google PHPSESSID.

-- 
/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.

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



Re: [PHP] mkdir permission errors

2008-07-15 Thread Daniel Brown
On Tue, Jul 15, 2008 at 7:05 AM, Wei, Alice J. [EMAIL PROTECTED] wrote:

 Do I really have to reinstall the entire Fedora?

You may be a prime candidate for Windows.

-- 
/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.

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



Re: [PHP] mkdir permission errors

2008-07-15 Thread Wolf
 Daniel Brown [EMAIL PROTECTED] wrote: 
 On Tue, Jul 15, 2008 at 7:05 AM, Wei, Alice J. [EMAIL PROTECTED] wrote:
 
  Do I really have to reinstall the entire Fedora?
 
 You may be a prime candidate for Windows.

Well, you *could* load Fedora on another machine, fully update it, and then go 
into / and do an ls -alF.
THEN, on the machine that you have completely messed up the permissions on, you 
would go to / and do an ls -alF

Then traverse the directory structures simultaneously on both machines and make 
sure the one you messed up matches the pristine installed one.

Once you have done that, you should be OK.

Wolf

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



[PHP] Re: DB search and case sensitive comparison

2008-07-15 Thread Shawn McKenzie

Angelo Zanetti wrote:
Hi all, 


I have a question and I can't seem to get around the problem or finding a
total solution.

I have a DB with a list of entries, one of the tables has fields and one of
the fields is called the lookup_string field.

This field is used to checkup values when users enter the site (explained
below).


So basically what happens is that the user will enter the site and I will
get their user agent from the $_SERVER variable.

What I want to do is to find out which entries in the DB are present in the
useragent string.

Eg: 


lookup_string (in db): Mozilla

useragent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15)
Gecko/20080623 Firefox/2.0.0.15'

So what I did was I used the locate function in my mysql query which gives
me the correct result set.

Now what I need to do is to ensure that the lookup_string is in the
useragent string and the CASE is the same: IE: Mozilla and not MOZILLA or
mozilla etc...

I am using the following If (however it fails because its part of the
useragent string and not the whole complete string therefore providing a
mismatch).

if(strcmp($userAgent, $lookup_string)==0){

//matches
}
Else
{

//doesn't match
}

Which way could I accomplish searching for the lookup_string in the
useragent and that it's the correct case?

Thanks in advance.

Angelo




strpos(), ereg() or preg_match() should work, take your pick.  strpos() 
most likely faster for this simple match.


if (strpos($userAgent, $lookup_string) !== false) {
//matches
} else {
//no matchy matchy
}

-Shawn

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



RE: [PHP] Math Weirdness

2008-07-15 Thread bruce
hi..


in all seriousness, when you talk about mathmetical operations, you need to
really clearly define what the parameters of the conversation are. are you
just restricting the conversation to ints, or floats as well.. you should
also restrict the range of the number you're discussing.

for most of what the majority of php/script apps deal with, it's probably
safe to assume that addition/subtraction will be safe, but i can think of
numerous examples where this isn't true...

the internal representation of a number/value is really complex when you get
into the guts of the cpu/fpu... and it can be hairy as hell to get it right,
depending on what you're doing... that said, the vast majority of php will
never think about this, and the world will still keep spinning!!

anyone remember the intel debacle in the 1990's.. when they ate a couple
hundred million when they had a math err in one of their coprocessors!

peace..


-Original Message-
From: tedd [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2008 6:33 AM
To: php php
Subject: RE: [PHP] Math Weirdness


At 11:24 AM +0100 7/15/08, Ford, Mike wrote:
On 14 July 2008 20:47, tedd advised:

   Round-off errors normally don't enter into things unless your doing
   multiplication and division operations. At that point, what you get
  back from the operation is an approximation and not the actual
  number.

Bull! Nearly all computer floating point numbers are approximations
because of being held in binary rather than decimal. Any number with a
(decimal) fractional part that doesn't end with the digit 5 is
necessarily an approximation, and that's only half the story. So as soon
as you involve numbers like 0.1 or 0.2, you've already got minor
inaccuracies which will propagate through any kind of arithmetic -- it's
just worse with multiplication or division because these tend to result
in inaccuracy in more significant digits!

Bottom line: a floating point value should *always* be treated with an
appropriate degree of suspicion.

Cheers!

Mike

Mike:

No reason to be rude.

I said:

Round-off errors normally don't enter into things unless your doing
multiplication and division operations.

And that is not Bull -- it's true. You can add and subtract all the
floating point numbers (the one's we are talking about here) you want
without any rounding errors whatsoever.

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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Math Weirdness

2008-07-15 Thread Jay Blanchard
[snip]
for most of what the majority of php/script apps deal with, it's
probably
safe to assume that addition/subtraction will be safe, but i can think
of
numerous examples where this isn't true...
[/snip]

As demonstrated by the example I provided, just checking the difference
(or lack thereof) between two floats brought the issue to light.

I think that this falls into the same category that cleaning input data
does in the fact that it should always be done. While there is a joke
about skimming the diffs it just demonstrates that the mathematical
constructs we use based on a digital platform leaves room for
error...and the errors add up really quickly because the platforms are
so darn much quicker than we are.

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



Re: [PHP] Math Weirdness

2008-07-15 Thread Daniel Brown
On Tue, Jul 15, 2008 at 11:16 AM, Jay Blanchard [EMAIL PROTECTED] wrote:

 the errors add up really quickly because the platforms are
 so darn much quicker than we are.

All I need to prove you wrong is an abacus and an old man with Parkinson's.





;-P

-- 
/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.

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



RE: [PHP] Math Weirdness

2008-07-15 Thread Ford, Mike
On 15 July 2008 14:33, tedd advised:

 At 11:24 AM +0100 7/15/08, Ford, Mike wrote:
 On 14 July 2008 20:47, tedd advised:
 
   Round-off errors normally don't enter into things unless your
doing
   multiplication and division operations. At that point,
 what you get
  back from the operation is an approximation and not the actual
  number.
 
 Bull! Nearly all computer floating point numbers are approximations
 because of being held in binary rather than decimal. Any number with
a
 (decimal) fractional part that doesn't end with the digit 5 is
 necessarily an approximation, and that's only half the story. So as
soon
 as you involve numbers like 0.1 or 0.2, you've already got minor
 inaccuracies which will propagate through any kind of arithmetic --
it's
 just worse with multiplication or division because these tend to
result
 in inaccuracy in more significant digits!
 
 Bottom line: a floating point value should *always* be treated with
an
 appropriate degree of suspicion.
 
 Cheers!
 
 Mike
 
 Mike:
 
 No reason to be rude.
 
 I said:
 
 Round-off errors normally don't enter into things unless your doing
 multiplication and division operations.
 
 And that is not Bull -- it's true. You can add and subtract all the
 floating point numbers (the one's we are talking about here) you want
 without any rounding errors whatsoever.

Sorry, I do apologise if I came over too strongly -- there was no
intention to offend.

However, you really can't dismiss the effects of round-off errors on
addition and subtraction as lightly as that.  It's simply not true that
approximations only occur at the point of doing multiplication and
division -- there *are* approximations involved in addition and
subtraction, and it is necessary to be aware that this is the case -- as
Jay proved, 0.1+0.2 is hardly ever exactly 0.3. In this sort of case, it
may well be that an appropriate degree of suspicion is simply to round
to 2 decimal places at every stage, or compare the absolute difference
to .001, but nonetheless one has to *know* that this is necessary.

Ummm -- sorry, better /rant, now!!!

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
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



[PHP] Warning:Cannot modify header information - Error

2008-07-15 Thread Tiji varghese
Hi All !
I am having some problem with the code below. Everytime I run it it gives me 
the following error:
Warning: Cannot modify header information - headers already sent
by (output started at
C:\xampp\htdocs\practice.com\displayUserData.php:7) in 
C:\xampp\htdocs\practice.com\displayUserData.php on line 12

The source code of the page is as follows:

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml;
head
title new document /title
/head
body
?php $textColor = $_POST[TextColor];
$boldText = $_POST[boldText];
$userComments = stripslashes($_POST['userComments']);
if(isset($_POST[saveInfo]))
{
setcookie(userData,$userComments,time()+60*60*24*30);
}
if(isset($_POST['boldText']))
{
echo b;
}
echo font color='$textColor';
echo $userComments;
echo /font;
if (isset($_POST[boldText]))
{
    echo /b;
}
?/body
/html

If I comment the setcookie() part, it works fine.. I looked up for some online 
help n most of them say I might have a whitespace near the line number 
mentioned in the warning message. But I don't find any.. Please help !



  Did you know? You can CHAT without downloading messenger. Go to 
http://in.messenger.yahoo.com/webmessengerpromo.php/ 

Re: [PHP] Warning:Cannot modify header information - Error

2008-07-15 Thread Dan Joseph
On Tue, Jul 15, 2008 at 11:51 AM, Tiji varghese [EMAIL PROTECTED]
wrote:

 Hi All !
 I am having some problem with the code below. Everytime I run it it gives
 me the following error:
 Warning: Cannot modify header information - headers already sent
 by (output started at
 C:\xampp\htdocs\practice.com\displayUserData.php:7) in C:\xampp\htdocs\
 practice.com\displayUserData.php on line 12

 The source code of the page is as follows:

 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
 html xmlns=http://www.w3.org/1999/xhtml;
 head
 title new document /title
 /head
 body
 ?php $textColor = $_POST[TextColor];
 $boldText = $_POST[boldText];
 $userComments = stripslashes($_POST['userComments']);
 if(isset($_POST[saveInfo]))
 {
 setcookie(userData,$userComments,time()+60*60*24*30);
 }
 if(isset($_POST['boldText']))
 {
 echo b;
 }
 echo font color='$textColor';
 echo $userComments;
 echo /font;
 if (isset($_POST[boldText]))
 {
 echo /b;
 }
 ?/body
 /html

 If I comment the setcookie() part, it works fine.. I looked up for some
 online help n most of them say I might have a whitespace near the line
 number mentioned in the warning message. But I don't find any.. Please help
 !



  Did you know? You can CHAT without downloading messenger. Go to
 http://in.messenger.yahoo.com/webmessengerpromo.php/


The setcookie line needs to come before you output anything.  Move your html
output at the top past it, and you should be good.

-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

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.


RE: [PHP] Math Weirdness

2008-07-15 Thread Ford, Mike
On 15 July 2008 16:07, bruce advised:

 anyone remember the intel debacle in the 1990's.. when they
 ate a couple
 hundred million when they had a math err in one of their coprocessors!

Oh, yes!

And then, back in the day, there was the DEC arithmetic processor which
hung if you happened to divide the most negative possible integer by
zero (instead of returning a divide-by-zero error as it did for any
other dividend!).

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
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] Math Weirdness

2008-07-15 Thread Robert Cummings
On Tue, 2008-07-15 at 11:32 +0100, Ford, Mike wrote:
 On 14 July 2008 21:44, Jay Blanchard advised:
 
  [snip]
  So does that mean your problem is solved?
  [/snip]
  
  It would appear so. I just need to remember to check for absolute
 values
  when working with floats.
 
 Yeah, that's Computer Science 101 stuff.  (Well, it was when I did my
 degree 30+ years ago, so it's probably nearer primary school level by
 now ;)

You didn't get the alumni memo did you? Supposedly they teach less now
than 30 years ago ;) Well... less theory I've heard.

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] mkdir permission errors

2008-07-15 Thread Robert Cummings
On Tue, 2008-07-15 at 09:06 +0100, Peter Ford wrote:
 Wei, Alice J. wrote:
  Hi, Rob:
  
I forgot to mention that I have been using yum install.
I have reinstalled the entire thing, put back all the packages, and then 
  I went to /var and did a chmod -R 777 var, and then did a
  
 [EMAIL PROTECTED] var]# chown -R apache:apache .
  
  Interestingly, I do not see anything different, and I still get this error 
  that says my permission is denied. Here is my
  
  [EMAIL PROTECTED] var]#  ps awxu | grep -E 'apache|httpd'
  root 31547  0.0  0.3  21268  6584 ?Ss   16:12   0:00 
  /usr/sbin/httpd
  apache   31549  0.0  0.2  21400  5572 ?S16:12   0:00 
  /usr/sbin/httpd
  apache   31550  0.0  0.2  21400  4908 ?S16:12   0:00 
  /usr/sbin/httpd
  apache   31551  0.0  0.2  21400  4908 ?S16:12   0:00 
  /usr/sbin/httpd
  apache   31552  0.0  0.2  21400  4896 ?S16:12   0:00 
  /usr/sbin/httpd
  apache   31553  0.0  0.2  21268  4860 ?S16:12   0:00 
  /usr/sbin/httpd
  apache   31554  0.0  0.2  21268  4860 ?S16:12   0:00 
  /usr/sbin/httpd
  apache   31555  0.0  0.2  21268  4860 ?S16:12   0:00 
  /usr/sbin/httpd
  apache   31556  0.0  0.2  21268  4860 ?S16:12   0:00 
  /usr/sbin/httpd
  root 31708  0.0  0.0   4120   728 pts/1R+   16:30   0:00 grep -E 
  apache|httpd
  
  Obviously, my last one has already changed the owner to apache 
  already.Nevertheless, I am still denied even when I am now logged in as 
  root. Is this anything with firewalls?
  
 
 Hang on a minute: you're original message said the error was:
 
 Warning: chmod() [function.chmod]: Permission denied in 
 /usr/local/apache/htdocs/file_linux.php on line 27
 
 But you say you've re-installed, and done chmod -R 777 var and chown -R 
 apache:apache . in /var

As Scooby would say... Ruh, Roh!.

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] mkdir permission errors

2008-07-15 Thread Robert Cummings
On Tue, 2008-07-15 at 08:16 -0400, Wei, Alice J. wrote:
 This portion is to answer Rob's question:
 
 [EMAIL PROTECTED] var]# ls -la
 total 92
 drwxrwxrwx 22 root root 4096 2008-06-24 08:34 .
 drwxr-xr-x 21 root root 4096 2008-07-14 08:17 ..
 drwxrwxrwx  2 root root 4096 2008-06-24 08:25 account
 drwxrwxrwx 13 root root 4096 2008-07-14 16:07 cache
 drwxrwxrwx  2 root root 4096 2008-02-19 20:47 cvs
 drwxrwxrwx  3 root root 4096 2008-06-24 08:25 db
 drwxrwxrwx  3 root root 4096 2008-06-24 08:29 empty
 drwxrwxrwx  2 root root 4096 2008-04-07 17:44 games
 drwxrwxrwx  2 root root 4096 2008-05-01 22:45 gdm
 drwxrwxrwx 35 root root 4096 2008-07-14 16:07 lib
 drwxrwxrwx  2 root root 4096 2008-04-07 17:44 local
 drwxrwxrwx  5 root root 4096 2008-07-15 04:10 lock
 drwxrwxrwx 17 root root 4096 2008-07-15 04:10 log
 lrwxrwxrwx  1 root root   10 2008-06-24 08:24 mail - spool/mail
 drwxrwxrwx  6 root root 4096 2008-06-24 08:26 named
 drwxrwxrwx  2 root root 4096 2008-04-07 17:44 nis
 drwxrwxrwx  2 root root 4096 2008-04-07 17:44 opt
 drwxrwxrwx  2 root root 4096 2008-04-07 17:44 preserve
 drwxrwxrwx 27 root root 4096 2008-07-14 16:12 run
 drwxrwxrwx 13 root root 4096 2008-06-24 08:35 spool
 drwxrwxrwx  2 root root 4096 2008-07-14 16:10 tmp
 drwxrwxrwx  8 root root 4096 2008-07-14 16:07 www
 drwxrwxrwx  3 root root 4096 2008-06-24 08:29 yp

Umm... all your base are bel^H^H^H^H^H^H^H^H^H^H^H^H

Umm, you've made your entire system world readable/writeable? That's not
good. And the ownership of www is root, not apache. Change directory to
www and do ls -al again. Maybe your html directory is ok for ownerships.

 And does your PHP script have the correct path?
 
 This is the latest error I got:
 
 Warning: mkdir() [function.mkdir]: Permission denied in 
 /var/www/html/file_linux.php on line 15
 Cannot create directory

The error indicates what script is generating the error. Not the path to
the directory you want to create. Maybe echo the name of the directory
you are trying to create when you get a failure for mkdir().

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] Math Weirdness

2008-07-15 Thread Robert Cummings
On Tue, 2008-07-15 at 10:16 -0500, Jay Blanchard wrote:
 [snip]
 for most of what the majority of php/script apps deal with, it's
 probably
 safe to assume that addition/subtraction will be safe, but i can think
 of
 numerous examples where this isn't true...
 [/snip]
 
 As demonstrated by the example I provided, just checking the difference
 (or lack thereof) between two floats brought the issue to light.
 
 I think that this falls into the same category that cleaning input data
 does in the fact that it should always be done. While there is a joke
 about skimming the diffs it just demonstrates that the mathematical
 constructs we use based on a digital platform leaves room for
 error...and the errors add up really quickly because the platforms are
 so darn much quicker than we are.

So what you're saying is that you've been skimming for a while and the
fruits of your mislabour are adding up?

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] mkdir permission errors

2008-07-15 Thread Wei, Alice J.

From: Robert Cummings [EMAIL PROTECTED]
Sent: Tuesday, July 15, 2008 12:16 PM
To: Wei, Alice J.
Cc: Peter Ford; php-general@lists.php.net
Subject: RE: [PHP] mkdir permission errors

On Tue, 2008-07-15 at 08:16 -0400, Wei, Alice J. wrote:
 This portion is to answer Rob's question:

 [EMAIL PROTECTED] var]# ls -la
 total 92
 drwxrwxrwx 22 root root 4096 2008-06-24 08:34 .
 drwxr-xr-x 21 root root 4096 2008-07-14 08:17 ..
 drwxrwxrwx  2 root root 4096 2008-06-24 08:25 account
 drwxrwxrwx 13 root root 4096 2008-07-14 16:07 cache
 drwxrwxrwx  2 root root 4096 2008-02-19 20:47 cvs
 drwxrwxrwx  3 root root 4096 2008-06-24 08:25 db
 drwxrwxrwx  3 root root 4096 2008-06-24 08:29 empty
 drwxrwxrwx  2 root root 4096 2008-04-07 17:44 games
 drwxrwxrwx  2 root root 4096 2008-05-01 22:45 gdm
 drwxrwxrwx 35 root root 4096 2008-07-14 16:07 lib
 drwxrwxrwx  2 root root 4096 2008-04-07 17:44 local
 drwxrwxrwx  5 root root 4096 2008-07-15 04:10 lock
 drwxrwxrwx 17 root root 4096 2008-07-15 04:10 log
 lrwxrwxrwx  1 root root   10 2008-06-24 08:24 mail - spool/mail
 drwxrwxrwx  6 root root 4096 2008-06-24 08:26 named
 drwxrwxrwx  2 root root 4096 2008-04-07 17:44 nis
 drwxrwxrwx  2 root root 4096 2008-04-07 17:44 opt
 drwxrwxrwx  2 root root 4096 2008-04-07 17:44 preserve
 drwxrwxrwx 27 root root 4096 2008-07-14 16:12 run
 drwxrwxrwx 13 root root 4096 2008-06-24 08:35 spool
 drwxrwxrwx  2 root root 4096 2008-07-14 16:10 tmp
 drwxrwxrwx  8 root root 4096 2008-07-14 16:07 www
 drwxrwxrwx  3 root root 4096 2008-06-24 08:29 yp

Umm... all your base are bel^H^H^H^H^H^H^H^H^H^H^H^H

Umm, you've made your entire system world readable/writeable? That's not
good. And the ownership of www is root, not apache. Change directory to
www and do ls -al again. Maybe your html directory is ok for ownerships.

 And does your PHP script have the correct path?

 This is the latest error I got:

 Warning: mkdir() [function.mkdir]: Permission denied in 
 /var/www/html/file_linux.php on line 15
 Cannot create directory

The error indicates what script is generating the error. Not the path to
the directory you want to create. Maybe echo the name of the directory
you are trying to create when you get a failure for mkdir().

Nope, I have set mine to 755, and it does not seem to be giving me any errors. 
This is the safer way to do it, right?

Alice

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] Math Weirdness

2008-07-15 Thread Jay Blanchard
[snip]
So what you're saying is that you've been skimming for a while and the
fruits of your mislabour are adding up?
[/snip]

Not as far as you know. ;) 

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



RE: [PHP] Math Weirdness

2008-07-15 Thread tedd

At 4:52 PM +0100 7/15/08, Ford, Mike wrote:

On 15 July 2008 14:33, tedd advised:
  Mike:


 No reason to be rude.

 I said:

 Round-off errors normally don't enter into things unless your doing
 multiplication and division operations.

 And that is not Bull -- it's true. You can add and subtract all the
 floating point numbers (the one's we are talking about here) you want
 without any rounding errors whatsoever.


Sorry, I do apologise if I came over too strongly -- there was no
intention to offend.

However, you really can't dismiss the effects of round-off errors on
addition and subtraction as lightly as that.  It's simply not true that
approximations only occur at the point of doing multiplication and
division -- there *are* approximations involved in addition and
subtraction, and it is necessary to be aware that this is the case -- as
Jay proved, 0.1+0.2 is hardly ever exactly 0.3. In this sort of case, it
may well be that an appropriate degree of suspicion is simply to round
to 2 decimal places at every stage, or compare the absolute difference
to .001, but nonetheless one has to *know* that this is necessary.

Ummm -- sorry, better /rant, now!!!


No problem about the rudeness -- email is a terrible form of 
communication. Sometimes we don't realize how we are being perceived.


I know full well about what you speak and why there are problems 
dealing with numbers.


My only point here was that the OP was talking about his 
balance-sheet not balancing at the end of the day.


I said that if all he was doing was adding and subtracting, then he 
wouldn't have any problems -- those operations are not subject to the 
rounding errors that division and multiplication induce. And 
experience has shown me that my claim is true. I can add and subtract 
dollars and cents all day without an error whatsoever.


Now, if you get into more complicated math, such as 
multiplication/division then of course rounding errors come into play 
much more noticeably. It is true that not every number can be 
represented in binary because of the limits of the processor. Take 
for example pi, no computer in the world has capabilities to 
represent that number in it's totality (i.e.,  unlimited precision). 
However, if one defines the precision, then that's a different 
matter. As with the OP's problem, the precision he was dealing with 
was simply 0.00 and addition and subtraction operations don't come 
into play at the precision level (i.e., 0.10 + 0.20 will equal 0.30 
no matter how many times you add it).


In addition, the algorithm that used to round the number also comes 
into play. For example php always round down and that introduces 
bias, as proved here:


http://webbytedd.com/bbb/rounding/

So, all in all, I agree with your statements, but I just don't think 
you fully appreciated what I was trying to communicate to the OP.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



RE: [PHP] mkdir permission errors

2008-07-15 Thread Robert Cummings
On Tue, 2008-07-15 at 12:19 -0400, Wei, Alice J. wrote:
 
 From: Robert Cummings [EMAIL PROTECTED]
 Sent: Tuesday, July 15, 2008 12:16 PM
 To: Wei, Alice J.
 Cc: Peter Ford; php-general@lists.php.net
 Subject: RE: [PHP] mkdir permission errors
 
 On Tue, 2008-07-15 at 08:16 -0400, Wei, Alice J. wrote:
  This portion is to answer Rob's question:
 
  [EMAIL PROTECTED] var]# ls -la
  total 92
  drwxrwxrwx 22 root root 4096 2008-06-24 08:34 .
  drwxr-xr-x 21 root root 4096 2008-07-14 08:17 ..
  drwxrwxrwx  2 root root 4096 2008-06-24 08:25 account
  drwxrwxrwx 13 root root 4096 2008-07-14 16:07 cache
  drwxrwxrwx  2 root root 4096 2008-02-19 20:47 cvs
  drwxrwxrwx  3 root root 4096 2008-06-24 08:25 db
  drwxrwxrwx  3 root root 4096 2008-06-24 08:29 empty
  drwxrwxrwx  2 root root 4096 2008-04-07 17:44 games
  drwxrwxrwx  2 root root 4096 2008-05-01 22:45 gdm
  drwxrwxrwx 35 root root 4096 2008-07-14 16:07 lib
  drwxrwxrwx  2 root root 4096 2008-04-07 17:44 local
  drwxrwxrwx  5 root root 4096 2008-07-15 04:10 lock
  drwxrwxrwx 17 root root 4096 2008-07-15 04:10 log
  lrwxrwxrwx  1 root root   10 2008-06-24 08:24 mail - spool/mail
  drwxrwxrwx  6 root root 4096 2008-06-24 08:26 named
  drwxrwxrwx  2 root root 4096 2008-04-07 17:44 nis
  drwxrwxrwx  2 root root 4096 2008-04-07 17:44 opt
  drwxrwxrwx  2 root root 4096 2008-04-07 17:44 preserve
  drwxrwxrwx 27 root root 4096 2008-07-14 16:12 run
  drwxrwxrwx 13 root root 4096 2008-06-24 08:35 spool
  drwxrwxrwx  2 root root 4096 2008-07-14 16:10 tmp
  drwxrwxrwx  8 root root 4096 2008-07-14 16:07 www
  drwxrwxrwx  3 root root 4096 2008-06-24 08:29 yp
 
 Umm... all your base are bel^H^H^H^H^H^H^H^H^H^H^H^H
 
 Umm, you've made your entire system world readable/writeable? That's not
 good. And the ownership of www is root, not apache. Change directory to
 www and do ls -al again. Maybe your html directory is ok for ownerships.
 
  And does your PHP script have the correct path?
 
  This is the latest error I got:
 
  Warning: mkdir() [function.mkdir]: Permission denied in 
  /var/www/html/file_linux.php on line 15
  Cannot create directory
 
 The error indicates what script is generating the error. Not the path to
 the directory you want to create. Maybe echo the name of the directory
 you are trying to create when you get a failure for mkdir().
 
 Nope, I have set mine to 755, and it does not seem to be giving me any 
 errors. This is the safer way to do it, right?

755 are better permissions in general than 777, but to what does mine
refer in the above context?

Cheers,
Rob.

Ps. what's wrong with your mail client? It doesn't quote content to
which you reply making it difficult to see where the previous person's
post ends and your response begins.
-- 
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] case and accent - insensitive regular expression?

2008-07-15 Thread tedd

At 10:15 AM -0400 7/15/08, Andrew Ballard wrote:

On TueWell, OK, I can think of one optimization. This takes advantage of the
fact that preg_replace can accept arrays as parameters. In a couple
very quick tests this version is roughly 30% faster than my previous
version:


-snip-

Hey, when you finally get finished with that function, please let me 
know I would like to copy it. :-)


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



RE: [PHP] Math Weirdness

2008-07-15 Thread Robert Cummings
On Tue, 2008-07-15 at 12:26 -0400, tedd wrote:
 At 4:52 PM +0100 7/15/08, Ford, Mike wrote:
 On 15 July 2008 14:33, tedd advised:
Mike:
 
   No reason to be rude.
 
   I said:
 
   Round-off errors normally don't enter into things unless your doing
   multiplication and division operations.
 
   And that is not Bull -- it's true. You can add and subtract all the
   floating point numbers (the one's we are talking about here) you want
   without any rounding errors whatsoever.
 
 Sorry, I do apologise if I came over too strongly -- there was no
 intention to offend.
 
 However, you really can't dismiss the effects of round-off errors on
 addition and subtraction as lightly as that.  It's simply not true that
 approximations only occur at the point of doing multiplication and
 division -- there *are* approximations involved in addition and
 subtraction, and it is necessary to be aware that this is the case -- as
 Jay proved, 0.1+0.2 is hardly ever exactly 0.3. In this sort of case, it
 may well be that an appropriate degree of suspicion is simply to round
 to 2 decimal places at every stage, or compare the absolute difference
 to .001, but nonetheless one has to *know* that this is necessary.
 
 Ummm -- sorry, better /rant, now!!!
 
 No problem about the rudeness -- email is a terrible form of 
 communication. Sometimes we don't realize how we are being perceived.
 
 I know full well about what you speak and why there are problems 
 dealing with numbers.
 
 My only point here was that the OP was talking about his 
 balance-sheet not balancing at the end of the day.
 
 I said that if all he was doing was adding and subtracting, then he 
 wouldn't have any problems -- those operations are not subject to the 
 rounding errors that division and multiplication induce. And 
 experience has shown me that my claim is true. I can add and subtract 
 dollars and cents all day without an error whatsoever.
 
 Now, if you get into more complicated math, such as 
 multiplication/division then of course rounding errors come into play 
 much more noticeably. It is true that not every number can be 
 represented in binary because of the limits of the processor. Take 
 for example pi, no computer in the world has capabilities to 
 represent that number in it's totality (i.e.,  unlimited precision).

Umm... here it is to unlimited precision: π

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] mkdir permission errors

2008-07-15 Thread Wei, Alice J.
 
 From: Robert Cummings [EMAIL PROTECTED]
 Sent: Tuesday, July 15, 2008 12:16 PM
 To: Wei, Alice J.
 Cc: Peter Ford; php-general@lists.php.net
 Subject: RE: [PHP] mkdir permission errors

 On Tue, 2008-07-15 at 08:16 -0400, Wei, Alice J. wrote:
  This portion is to answer Rob's question:
 
  [EMAIL PROTECTED] var]# ls -la
  total 92
  drwxrwxrwx 22 root root 4096 2008-06-24 08:34 .
  drwxr-xr-x 21 root root 4096 2008-07-14 08:17 ..
  drwxrwxrwx  2 root root 4096 2008-06-24 08:25 account
  drwxrwxrwx 13 root root 4096 2008-07-14 16:07 cache
  drwxrwxrwx  2 root root 4096 2008-02-19 20:47 cvs
  drwxrwxrwx  3 root root 4096 2008-06-24 08:25 db
  drwxrwxrwx  3 root root 4096 2008-06-24 08:29 empty
  drwxrwxrwx  2 root root 4096 2008-04-07 17:44 games
  drwxrwxrwx  2 root root 4096 2008-05-01 22:45 gdm
  drwxrwxrwx 35 root root 4096 2008-07-14 16:07 lib
  drwxrwxrwx  2 root root 4096 2008-04-07 17:44 local
  drwxrwxrwx  5 root root 4096 2008-07-15 04:10 lock
  drwxrwxrwx 17 root root 4096 2008-07-15 04:10 log
  lrwxrwxrwx  1 root root   10 2008-06-24 08:24 mail - spool/mail
  drwxrwxrwx  6 root root 4096 2008-06-24 08:26 named
  drwxrwxrwx  2 root root 4096 2008-04-07 17:44 nis
  drwxrwxrwx  2 root root 4096 2008-04-07 17:44 opt
  drwxrwxrwx  2 root root 4096 2008-04-07 17:44 preserve
  drwxrwxrwx 27 root root 4096 2008-07-14 16:12 run
  drwxrwxrwx 13 root root 4096 2008-06-24 08:35 spool
  drwxrwxrwx  2 root root 4096 2008-07-14 16:10 tmp
  drwxrwxrwx  8 root root 4096 2008-07-14 16:07 www
  drwxrwxrwx  3 root root 4096 2008-06-24 08:29 yp

 Umm... all your base are bel^H^H^H^H^H^H^H^H^H^H^H^H

 Umm, you've made your entire system world readable/writeable? That's not
 good. And the ownership of www is root, not apache. Change directory to
 www and do ls -al again. Maybe your html directory is ok for ownerships.

  And does your PHP script have the correct path?
 
  This is the latest error I got:
 
  Warning: mkdir() [function.mkdir]: Permission denied in 
  /var/www/html/file_linux.php on line 15
  Cannot create directory

 The error indicates what script is generating the error. Not the path to
 the directory you want to create. Maybe echo the name of the directory
 you are trying to create when you get a failure for mkdir().

 Nope, I have set mine to 755, and it does not seem to be giving me any 
 errors. This is the safer way to do it, right?

755 are better permissions in general than 777, but to what does mine
refer in the above context?

I  meant the permission settings have been set to 755 and no longer 777.
My mail client? All I can think of is when I am reading others posts and try to 
answer what they are asking for, which makes it seem like there is a lag.

Alice

Cheers,
Rob.

Ps. what's wrong with your mail client? It doesn't quote content to
which you reply making it difficult to see where the previous person's
post ends and your response begins.
--
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] mkdir permission errors

2008-07-15 Thread Wolf
 Nope, I have set mine to 755, and it does not seem to be giving me any 
 errors. This is the safer way to do it, right?
 
 Alice

Alice,

At this point, you need to re-install the OS or prepare to get your machine 
completely hacked and trashed.  With your permissions that badly screwed up, it 
is only a matter of time before someone finds it and has their own ghost server.

First, go pick up a System Admin book for Redhat

Second, READ IT, Especially the parts on permissions and changing users

Third, Re-install the OS

Fourth, read the CLI vs. HTTP differences on programming languages you are 
using.  Obviously Perl and PHP are going to give you the same errors when using 
the HTTP and will operate differently from the CLI unless running as the same 
user.

This might even help your schooling.  Hopefully your classroom exercises are 
further along then these basic principles, but if not I have severe doubts in 
anyone graduating with an MIS from Indiana University.

Wolf

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



RE: [PHP] Math Weirdness

2008-07-15 Thread tedd

At 12:31 PM -0400 7/15/08, Robert Cummings wrote:


Umm... here it is to unlimited precision: ¼

Cheers,
Rob.


Yeah and here's ƒ

Like or not, that's all there is to it.

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] Removeing duplicates inside for/foreach loop.

2008-07-15 Thread Niccolo Machiavelli
$array = array(

  1 = array(order_number = 10DA0DDEDAF97DB, order_payment_first_name
=  Mike, order_payment_last_name =  Smith),

  2 = array(order_number = 10DA0DDEDAF97DB, order_payment_first_name
=  Mike, order_payment_last_name =  Smith),

  3 = array(order_number = 45Y3453245T23T5, order_payment_first_name
=  Steve, order_payment_last_name =  Jobs),

  4 = array(order_number = 34RTB345T45T456, order_payment_first_name
=  Frank, order_payment_last_name =  Capra),

  5 = array(order_number = 567U457645645Y6, order_payment_first_name
=  John, order_payment_last_name =  Doe),

  6 = array(order_number = 7698234T456M963, order_payment_first_name
=  Bill, order_payment_last_name =  Williams));

 

echo('pre');

print_r($array);

echo('/pre');

 

My question is I want to remove duplicate order numbers in other words ditch
*one* of the Mike Smith rows there's a duplicate order number there. 

And I need to do it in either a for/foreach loop. Somehow there's got to be
a simple way to check and only output non duplicate order numbers while I'm
looping thru the data. Any help would be greatly appreciated. 

 

 

Thanks

[EMAIL PROTECTED]



Re: [PHP] Login without cookies enabled help

2008-07-15 Thread Thiago H. Pojda
Yes, again, STFW before posting here.

Google PHPSESSID.


Call to undefined function Google();



 --
 /Daniel P. Brown

 :)

-- 
Thiago Henrique Pojda


[Fwd: Re: [PHP] Removeing duplicates inside for/foreach loop.]

2008-07-15 Thread Stephen

Niccolo Machiavelli wrote:


$array = array(

  1 = array(order_number = 10DA0DDEDAF97DB, order_payment_first_name
=  Mike, order_payment_last_name =  Smith),

  2 = array(order_number = 10DA0DDEDAF97DB, order_payment_first_name
=  Mike, order_payment_last_name =  Smith),

  3 = array(order_number = 45Y3453245T23T5, order_payment_first_name
=  Steve, order_payment_last_name =  Jobs),

  4 = array(order_number = 34RTB345T45T456, order_payment_first_name
=  Frank, order_payment_last_name =  Capra),

  5 = array(order_number = 567U457645645Y6, order_payment_first_name
=  John, order_payment_last_name =  Doe),

  6 = array(order_number = 7698234T456M963, order_payment_first_name
=  Bill, order_payment_last_name =  Williams));

 


echo('pre');

print_r($array);

echo('/pre');

 


My question is I want to remove duplicate order numbers in other words ditch
*one* of the Mike Smith rows there's a duplicate order number there. 


And I need to do it in either a for/foreach loop. Somehow there's got to be
a simple way to check and only output non duplicate order numbers while I'm
looping thru the data. Any help would be greatly appreciated. 
  

It looks like the array is sorted.

In pseudo code

for i = 2 to n
 if x[1].order = x[i-1].order then
   unlink x[i-1]

Stephen



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



Re: [PHP] Removeing duplicates inside for/foreach loop.

2008-07-15 Thread tedd

At 11:50 AM -0500 7/15/08, Niccolo Machiavelli wrote:

$array = array(


-snip-


My question is I want to remove duplicate order numbers in other words ditch
*one* of the Mike Smith rows there's a duplicate order number there.

And I need to do it in either a for/foreach loop. Somehow there's got to be
a simple way to check and only output non duplicate order numbers while I'm
looping thru the data. Any help would be greatly appreciated.


Niccolo:

Check out: array_unique

http://www.php.net/array_unique

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] Re: Removeing duplicates inside for/foreach loop.

2008-07-15 Thread Shawn McKenzie

Niccolo Machiavelli wrote:

$array = array(

  1 = array(order_number = 10DA0DDEDAF97DB, order_payment_first_name
=  Mike, order_payment_last_name =  Smith),

  2 = array(order_number = 10DA0DDEDAF97DB, order_payment_first_name
=  Mike, order_payment_last_name =  Smith),

  3 = array(order_number = 45Y3453245T23T5, order_payment_first_name
=  Steve, order_payment_last_name =  Jobs),

  4 = array(order_number = 34RTB345T45T456, order_payment_first_name
=  Frank, order_payment_last_name =  Capra),

  5 = array(order_number = 567U457645645Y6, order_payment_first_name
=  John, order_payment_last_name =  Doe),

  6 = array(order_number = 7698234T456M963, order_payment_first_name
=  Bill, order_payment_last_name =  Williams));

 


echo('pre');

print_r($array);

echo('/pre');

 


My question is I want to remove duplicate order numbers in other words ditch
*one* of the Mike Smith rows there's a duplicate order number there. 


And I need to do it in either a for/foreach loop. Somehow there's got to be
a simple way to check and only output non duplicate order numbers while I'm
looping thru the data. Any help would be greatly appreciated. 

 

 


Thanks

[EMAIL PROTECTED]



foreach ($array as $k = $v) {
$result[$v['order_number']] = $v;
}
//then use $result

-Shawn

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



Re: [PHP] case and accent - insensitive regular expression?

2008-07-15 Thread Andrew Ballard
On Tue, Jul 15, 2008 at 12:30 PM, tedd [EMAIL PROTECTED] wrote:
 At 10:15 AM -0400 7/15/08, Andrew Ballard wrote:

 On TueWell, OK, I can think of one optimization. This takes advantage of
 the
 fact that preg_replace can accept arrays as parameters. In a couple
 very quick tests this version is roughly 30% faster than my previous
 version:

 -snip-

 Hey, when you finally get finished with that function, please let me know I
 would like to copy it. :-)

 Cheers,

 tedd

All yours. I figure I'm done with it. (At least until I actually need
to use it for something and then I have to test it for real. :-) )

Andrew

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



RE: [PHP] Removeing duplicates inside for/foreach loop.

2008-07-15 Thread Niccolo Machiavelli
I'm firly certain array unique won't can't handle dimensional arrays. This
is what I have for code it almost works

$order_data = array();
while ($row = $db-fetchRow($result)) {
$order_data[] = 'a
href='.setup_uri('orders').'?id=' . $row['order_number'] . '' .
$row['order_payment_first_name'] . ' ' . $row['order_payment_last_name'] .
'/a';
}
$db-freeresult($result);

sort($order_data);

if ($count = count($order_data)) {

for ($i = 2; $i  $count; $i++) {

if ($order_data[$i]['order_number'] ==
$order_data[$i-1]['order_number']) {
unset($order_data[$i-1]);
}

if (count($order_data)  0) {
$order_list = implode(', ',
$order_data);
} else {
$order_list = '';
}

}
}

-Original Message-
From: tedd [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 15, 2008 12:12 PM
To: php-general@lists.php.net
Subject: Re: [PHP] Removeing duplicates inside for/foreach loop.

At 11:50 AM -0500 7/15/08, Niccolo Machiavelli wrote:
$array = array(

-snip-

My question is I want to remove duplicate order numbers in other words
ditch
*one* of the Mike Smith rows there's a duplicate order number there.

And I need to do it in either a for/foreach loop. Somehow there's got to be
a simple way to check and only output non duplicate order numbers while I'm
looping thru the data. Any help would be greatly appreciated.

Niccolo:

Check out: array_unique

http://www.php.net/array_unique

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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Removeing duplicates inside for/foreach loop.

2008-07-15 Thread Eric Butera
On Tue, Jul 15, 2008 at 12:50 PM, Niccolo Machiavelli
[EMAIL PROTECTED] wrote:
 $array = array(

  1 = array(order_number = 10DA0DDEDAF97DB, order_payment_first_name
 =  Mike, order_payment_last_name =  Smith),

  2 = array(order_number = 10DA0DDEDAF97DB, order_payment_first_name
 =  Mike, order_payment_last_name =  Smith),

  3 = array(order_number = 45Y3453245T23T5, order_payment_first_name
 =  Steve, order_payment_last_name =  Jobs),

  4 = array(order_number = 34RTB345T45T456, order_payment_first_name
 =  Frank, order_payment_last_name =  Capra),

  5 = array(order_number = 567U457645645Y6, order_payment_first_name
 =  John, order_payment_last_name =  Doe),

  6 = array(order_number = 7698234T456M963, order_payment_first_name
 =  Bill, order_payment_last_name =  Williams));



 echo('pre');

 print_r($array);

 echo('/pre');



 My question is I want to remove duplicate order numbers in other words ditch
 *one* of the Mike Smith rows there's a duplicate order number there.

 And I need to do it in either a for/foreach loop. Somehow there's got to be
 a simple way to check and only output non duplicate order numbers while I'm
 looping thru the data. Any help would be greatly appreciated.





 Thanks

 [EMAIL PROTECTED]



Would it be possible to leave them out in your original query?

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



RE: [PHP] Math Weirdness

2008-07-15 Thread Robert Cummings
On Tue, 2008-07-15 at 12:37 -0400, tedd wrote:
 At 12:31 PM -0400 7/15/08, Robert Cummings wrote:
 
 Umm... here it is to unlimited precision: ¼
 
 Cheers,
 Rob.
 
 Yeah and here's ƒ
 
 Like or not, that's all there is to it.

Weird... you're client bastar-dized my beautiful pi symbol.

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] Removeing duplicates inside for/foreach loop.

2008-07-15 Thread Jim Lucas

Niccolo Machiavelli wrote:

I'm firly certain array unique won't can't handle dimensional arrays. This
is what I have for code it almost works

$order_data = array();
while ($row = $db-fetchRow($result)) {
$order_data[] = 'a
href='.setup_uri('orders').'?id=' . $row['order_number'] . '' .
$row['order_payment_first_name'] . ' ' . $row['order_payment_last_name'] .
'/a';
}
$db-freeresult($result);


since you are getting your information from a db, use
SELECT DISTINCT order_number, 

This will ensure that only unique order_numbers are returned



sort($order_data);

if ($count = count($order_data)) {

for ($i = 2; $i  $count; $i++) {

if ($order_data[$i]['order_number'] ==
$order_data[$i-1]['order_number']) {
unset($order_data[$i-1]);
}

if (count($order_data)  0) {
$order_list = implode(', ',
$order_data);
} else {
$order_list = '';
}

}
}

-Original Message-
From: tedd [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 15, 2008 12:12 PM

To: php-general@lists.php.net
Subject: Re: [PHP] Removeing duplicates inside for/foreach loop.

At 11:50 AM -0500 7/15/08, Niccolo Machiavelli wrote:

$array = array(


-snip-


My question is I want to remove duplicate order numbers in other words

ditch

*one* of the Mike Smith rows there's a duplicate order number there.

And I need to do it in either a for/foreach loop. Somehow there's got to be
a simple way to check and only output non duplicate order numbers while I'm
looping thru the data. Any help would be greatly appreciated.


Niccolo:

Check out: array_unique

http://www.php.net/array_unique

Cheers,

tedd




--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] case and accent - insensitive regular expression?

2008-07-15 Thread Yeti
The original problem was

User X submits a character string A.

A PHP scripts uses A to search for it's occurences in a DB, ignoring special
characters.

The result of ze search is a list of character strings M-LIST with matches.

This list gets outputted to the user X, but before that all the matching
strings should be replaced with 'span style=color: #FF'..'/span'

If i clearly got the OP then he is using MySQL to perform the search.

I guess he is doing it with MATCH. So MySQL already found the match and in
PHP it has to be done again ...

eg.

The table has 2 entries, string1 and string2 ..

string1 = 'Thís ís an éxámplè stríng wíth áccénts.'

string2 = 'This is an example string without accents.'

Now the user searches for ample:

search = '*ample*'

Both string have matches due to accent-insensitivity (AI). Now the result is
outputted with highlighting ..

*Thís ís an éx*span style=color: #FF*ámplè*/span* stríng wíth
áccénts.*

*This is an ex*span style=color: #FF*ample*/span* string without
accents.*

So since MySQL already did the job, why not get the occurances from it?

I'm not an MySQL expert, but I know google and found something called string
functions. Especially a locate function got my interest.

http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_locate

Now shouldnt it be possible to create a query that searches the db for
matches and additionally uses the string function?

I have no idea, but maybe some MySQL-expert out there has ...

Yeti


On Tue, Jul 15, 2008 at 7:17 PM, Andrew Ballard [EMAIL PROTECTED] wrote:

 On Tue, Jul 15, 2008 at 12:30 PM, tedd [EMAIL PROTECTED] wrote:
  At 10:15 AM -0400 7/15/08, Andrew Ballard wrote:
 
  On TueWell, OK, I can think of one optimization. This takes advantage of
  the
  fact that preg_replace can accept arrays as parameters. In a couple
  very quick tests this version is roughly 30% faster than my previous
  version:
 
  -snip-
 
  Hey, when you finally get finished with that function, please let me know
 I
  would like to copy it. :-)
 
  Cheers,
 
  tedd

 All yours. I figure I'm done with it. (At least until I actually need
 to use it for something and then I have to test it for real. :-) )

 Andrew

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




Re: [PHP] Math Weirdness - Can it be done with integers alone??

2008-07-15 Thread Jochem Maas

tedd schreef:

At 4:45 PM -0400 7/14/08, Daniel Brown wrote:

That's as far OT as I'm going, but it's worth noting how
regulation doesn't do shit if it's not enforced.


The only thing that's regulated AND enforced is what you owe the 
government.


actually your under no obligation to declare any income tax in your
country, look into it




Don't get me started.  :-)

Cheers,

tedd




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



Re: [PHP] Math Weirdness

2008-07-15 Thread Jochem Maas

Robin Vickery schreef:

2008/7/15 tedd [EMAIL PROTECTED]:

I said:

Round-off errors normally don't enter into things unless your doing
multiplication and division operations.

And that is not Bull -- it's true. You can add and subtract all the
floating point numbers (the one's we are talking about here) you want
without any rounding errors whatsoever.


$ php -r 'echo 0.7 - 0.2 == 0.5 ? true\n : false\n;'
false

The operation you do isn't important. You just can't represent certain
numbers exactly in binary, just as you can't represent 1/3 exactly in
decimal. They have to be rounded internally.


which makes php casting so much fun:

$ php -r 'echo (string)(0.7 - 0.2) == 0.5 ? true\n : false\n;'
true





-robin




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



Re: [PHP] Math Weirdness

2008-07-15 Thread Jochem Maas

Robert Cummings schreef:

On Tue, 2008-07-15 at 12:37 -0400, tedd wrote:

At 12:31 PM -0400 7/15/08, Robert Cummings wrote:

Umm... here it is to unlimited precision: ¼

Cheers,
Rob.

Yeah and here's ƒ

Like or not, that's all there is to it.


Weird... you're client bastar-dized my beautiful pi symbol.


no it's the worst round error ever. how exactly do you go
from 3.1 to .25 :-P



Cheers,
Rob.



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



Re: [PHP] Math Weirdness

2008-07-15 Thread Robert Cummings
On Tue, 2008-07-15 at 20:17 +0200, Jochem Maas wrote:
 Robin Vickery schreef:
  2008/7/15 tedd [EMAIL PROTECTED]:
  I said:
 
  Round-off errors normally don't enter into things unless your doing
  multiplication and division operations.
 
  And that is not Bull -- it's true. You can add and subtract all the
  floating point numbers (the one's we are talking about here) you want
  without any rounding errors whatsoever.
  
  $ php -r 'echo 0.7 - 0.2 == 0.5 ? true\n : false\n;'
  false
  
  The operation you do isn't important. You just can't represent certain
  numbers exactly in binary, just as you can't represent 1/3 exactly in
  decimal. They have to be rounded internally.
 
 which makes php casting so much fun:
 
 $ php -r 'echo (string)(0.7 - 0.2) == 0.5 ? true\n : false\n;'
 true

Just make a simple function...

?php

function close_enough( $float1, $float2, $delta=0.01 )
{
return (abs( $float1 - $float2 )  $delta);
}

?

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] Math Weirdness

2008-07-15 Thread Robert Cummings
On Tue, 2008-07-15 at 20:21 +0200, Jochem Maas wrote:
 Robert Cummings schreef:
  On Tue, 2008-07-15 at 12:37 -0400, tedd wrote:
  At 12:31 PM -0400 7/15/08, Robert Cummings wrote:
  Umm... here it is to unlimited precision: ¼
 
  Cheers,
  Rob.
  Yeah and here's ƒ
 
  Like or not, that's all there is to it.
  
  Weird... you're client bastar-dized my beautiful pi symbol.
 
 no it's the worst round error ever. how exactly do you go
 from 3.1 to .25 :-P

Ask Jay, he's the skimming master!  :)

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] Math Weirdness

2008-07-15 Thread Jay Blanchard
[snip]
Ask Jay, he's the skimming master!  :)
[/snip]

Bow down before mebut not too far lest ye be skimmed as well. 

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



Re: [PHP] case and accent - insensitive regular expression?

2008-07-15 Thread Andrew Ballard
On Tue, Jul 15, 2008 at 2:07 PM, Yeti [EMAIL PROTECTED] wrote:
 The original problem was

 User X submits a character string A.

 A PHP scripts uses A to search for it's occurences in a DB, ignoring special
 characters.

 The result of ze search is a list of character strings M-LIST with matches.

 This list gets outputted to the user X, but before that all the matching
 strings should be replaced with 'span style=color: #FF'..'/span'

 If i clearly got the OP then he is using MySQL to perform the search.

 I guess he is doing it with MATCH. So MySQL already found the match and in
 PHP it has to be done again ...

 eg.

 The table has 2 entries, string1 and string2 ..

 string1 = 'Thís ís an éxámplè stríng wíth áccénts.'

 string2 = 'This is an example string without accents.'

 Now the user searches for ample:

 search = 'ample'

 Both string have matches due to accent-insensitivity (AI). Now the result is
 outputted with highlighting ..

 Thís ís an éxspan style=color: #FFámplè/span stríng wíth áccénts.

 This is an exspan style=color: #FFample/span string without
 accents.

Correct.

 So since MySQL already did the job, why not get the occurances from it?

 I'm not an MySQL expert, but I know google and found something called string
 functions. Especially a locate function got my interest.

 http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_locate

 Now shouldnt it be possible to create a query that searches the db for
 matches and additionally uses the string function?

 I have no idea, but maybe some MySQL-expert out there has ...

 Yeti


There are definitely possibilities there. Personally, I tend to be
biased against using the database to format output for presentation,
so I'd rather not push the task off there. Still, I know lots of
developers do not share this bias, so I'll address a couple other
issues I see with this approach:

1) If the search word appears multiple times, LOCATE() will only find
it once. I'd probably use REPLACE() instead. This leads to the next
problem:

2) I'm not sure if the OP wants this or not, but if he wants to
highlight each of multiple search terms the way many sites do, he
would have to split the terms and build a SQL phrase that like this
(there are probably other approaches available in MySQL to do the same
thing):

-- search phrase 'quaint french cafe'
SELECT REPLACE(REPLACE(REPLACE(`my_column`, 'quaint', 'span
class=keysearchquaint/span'), 'french', 'span
class=keysearchfrench/span'), 'cafe', 'span
class=keysearchcafe/span') FROM ...

In this case, he should get all instances of each word highlighted,
but the accented characters would again be replaced with a particular
style. (Not to mention the size and complexity of the query being
passed from PHP to the database or the potential size of the result
being passed from the database to PHP since it now could have lots of
formatting text embedded in it.)

Andrew


Re: [PHP] Advice on a radar chart

2008-07-15 Thread Richard Heyes

If you are willing to use googles chart api ..

http://code.google.com/apis/chart/#radar


Nope. It's not something I need to implement, mmore a personal (albeit 
with this lists help) project.


--
Richard Heyes

Employ me:
http://www.phpguru.org/cv

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



Re: [PHP] Math Weirdness

2008-07-15 Thread tedd

At 8:21 PM +0200 7/15/08, Jochem Maas wrote:

Robert Cummings schreef:

On Tue, 2008-07-15 at 12:37 -0400, tedd wrote:

At 12:31 PM -0400 7/15/08, Robert Cummings wrote:

Umm... here it is to unlimited precision: 1Ž4

Cheers,
Rob.

Yeah and here's Ÿ

Like or not, that's all there is to it.


Weird... you're client bastar-dized my beautiful pi symbol.


no it's the worst round error ever. how exactly do you go
from 3.1 to .25 :-P


Well, someone's client took infinity and turned it into an integral.

tdd



--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Advice on a radar chart

2008-07-15 Thread tedd

At 8:26 PM +0100 7/15/08, Richard Heyes wrote:

If you are willing to use googles chart api ..

http://code.google.com/apis/chart/#radar


Nope. It's not something I need to implement, mmore a personal 
(albeit with this lists help) project.


--
Richard Heyes


Richard:

What do you want to implement as a radar chart?

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Advice on a radar chart

2008-07-15 Thread Richard Heyes

What do you want to implement as a radar chart?


Nothing in particular. Just a generic radar chart for representing data.

--
Richard Heyes

Employ me:
http://www.phpguru.org/cv

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



[PHP] is there a problem with php script pulling HTML out of database as it writes the page??

2008-07-15 Thread Rod Clay
Hello.  Again, I'm fairly new to php so please forgive me if my question 
is a very simple or obvious one.


I've just tried testing for the first time some php code that is pulling 
text out of a database to print it on the webpage.  Some of this text 
includes HTML, specifically in this case an img src=x 
statement.  Much to my surprise, this is not working.  Is there a 
problem with pulling HTML out of a database like this as the page is 
being written? 

There's no problem of course if my php code is writing the HTML to the 
page - in this case, the img src=xx statement works fine and the 
image is displayed.  Why is it a problem when my php script pulls the 
HTML code out of a database and writes it to the page from there??


It would appear that when my php script writes HTML to the page a 
process of some kind is executed to, in this case, get the image and put 
it on the page.  Apparently this same process is NOT executed if the 
HTML is retrieved from a database and simply written to the page from 
there.  Is this correct?  And, if it is, can anyone suggest a 
workaround, another way to get done what I'm trying to do here?


Thanks for any help you can give me.

Rod Clay



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



Re: [PHP] is there a problem with php script pulling HTML out of database as it writes the page??

2008-07-15 Thread Stut

On 15 Jul 2008, at 22:36, Rod Clay wrote:
Hello.  Again, I'm fairly new to php so please forgive me if my  
question is a very simple or obvious one.


I've just tried testing for the first time some php code that is  
pulling text out of a database to print it on the webpage.  Some of  
this text includes HTML, specifically in this case an img  
src=x statement.  Much to my surprise, this is not  
working.  Is there a problem with pulling HTML out of a database  
like this as the page is being written?
There's no problem of course if my php code is writing the HTML to  
the page - in this case, the img src=xx statement works fine  
and the image is displayed.  Why is it a problem when my php script  
pulls the HTML code out of a database and writes it to the page from  
there??


It would appear that when my php script writes HTML to the page a  
process of some kind is executed to, in this case, get the image and  
put it on the page.  Apparently this same process is NOT executed if  
the HTML is retrieved from a database and simply written to the page  
from there.  Is this correct?  And, if it is, can anyone suggest a  
workaround, another way to get done what I'm trying to do here?


Code please, we're not mind readers!

-Stut

--
http://stut.net/

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



Re: [PHP] is there a problem with php script pulling HTML out of database as it writes the page??

2008-07-15 Thread Rod Clay
Yes, here's the code that is retrieving news items from the database 
and printing them on the page (I do some other stuff with the text 
before, and after, I print it, for example, find the sentences, so I can 
print complete sentences, and not just pieces of sentences).  As I say, 
occasionally these news items contain some HTML, e.g., the img 
src=xxx statement.  All of the text is being correctly retrieved 
from the database and written to the page, including the img 
src=xxx statement, because I see it all in the page source of the 
page in my browser.  However, the img src= statement is NOT 
working, that is, the image does NOT appear on the page.


$result = mysql_query(SELECT * FROM newsitem ORDER BY 
newsitem_date DESC);

if (mysql_num_rows($result)  0)
{
 $i = 1;
 while (($row = mysql_fetch_assoc($result))  ($i  6)) { ?
  div id=newsitem
  p?php echo $row['newsitem_date']; ?bibr / ?php $title 
= $row['title']; echo $title; echo /i/bbr by ; ? ?php echo 
$row['author']; echo  of em; echo $row['newsservice']; ?/embrbr /

  ?php $newsitem_array = explode('.', $row['newsitem_text']);
 $print_newsitem = $newsitem_array[0] . .;
 $length_newsitem = strlen($print_newsitem);
 for ($j = 1; $length_newsitem  250; $j++) {
$print_newsitem = $print_newsitem . $newsitem_array[$j] . .;
$length_newsitem = strlen($print_newsitem);
 }
 echo $print_newsitem;
 echo br; $url_string = a href=\ . $row['url'] . \ (read 
more of this article)/a; echo $url_string;
$blog_result = mysql_query(SELECT * FROM blog where discussion 
= \$title\);

 if (mysql_num_rows($blog_result)  0)
$not = ;
 else
 $not =  not;
 echo br; echo This news item does$not have a blog discussion 
; echo nbsp;nbsp;;

 if (mysql_num_rows($blog_result)  0)
echo a href=\bloglist.php?discussion=$title\Read this 
item's blog/a ;

 else
echo a href=\blog.php?discussion=$title\Start a discussion 
on this item/a ;

   $i++;
  ?
  /pbr /
  /div
?php
 }
}
?

Stut wrote:

On 15 Jul 2008, at 22:36, Rod Clay wrote:
Hello.  Again, I'm fairly new to php so please forgive me if my 
question is a very simple or obvious one.


I've just tried testing for the first time some php code that is 
pulling text out of a database to print it on the webpage.  Some of 
this text includes HTML, specifically in this case an img 
src=x statement.  Much to my surprise, this is not 
working.  Is there a problem with pulling HTML out of a database like 
this as the page is being written?
There's no problem of course if my php code is writing the HTML to 
the page - in this case, the img src=xx statement works fine 
and the image is displayed.  Why is it a problem when my php script 
pulls the HTML code out of a database and writes it to the page from 
there??


It would appear that when my php script writes HTML to the page a 
process of some kind is executed to, in this case, get the image and 
put it on the page.  Apparently this same process is NOT executed if 
the HTML is retrieved from a database and simply written to the page 
from there.  Is this correct?  And, if it is, can anyone suggest a 
workaround, another way to get done what I'm trying to do here?


Code please, we're not mind readers!

-Stut



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



Re: [PHP] is there a problem with php script pulling HTML out of database as it writes the page??

2008-07-15 Thread dg


On Jul 15, 2008, at 3:06 PM, Rod Clay wrote:

All of the text is being correctly retrieved from the database and  
written to the page, including the img src=xxx statement,  
because I see it all in the page source of the page in my browser.   
However, the img src= statement is NOT working, that is,  
the image does NOT appear on the page.


What exactly is it printing? What is the doctype?


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



Re: [PHP] is there a problem with php script pulling HTML out of database as it writes the page??

2008-07-15 Thread Rod Clay
It's (was) not printing anything.  Here's the doctype statement:  
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;


HOWEVER, thanks for all of the responses so far, but please accept my 
apologies because evidently this is NOT a php question after all - I 
just tried another, much, much smaller photo and that is printing, so it 
would appear that it is a much more mundane problem, actually an HTML 
problem!!!


Again, please accept my apologies for this false alarm, but I had tested 
and tested and tested this and was stumped an hour ago!  Thought it was 
a different kind of problem.  Mea culpa! :-[


dg wrote:


On Jul 15, 2008, at 3:06 PM, Rod Clay wrote:

All of the text is being correctly retrieved from the database and 
written to the page, including the img src=xxx statement, 
because I see it all in the page source of the page in my browser.  
However, the img src= statement is NOT working, that is, 
the image does NOT appear on the page.


What exactly is it printing? What is the doctype?




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



RE: [PHP] is there a problem with php script pulling HTML out of database as it writes the page??

2008-07-15 Thread Alex Chamberlain


 -Original Message-
 From: Rod Clay [mailto:[EMAIL PROTECTED]
 Sent: 15 July 2008 22:36
 To: php-general@lists.php.net
 Subject: [PHP] is there a problem with php script pulling HTML out of
 database as it writes the page??
 
 Hello.  Again, I'm fairly new to php so please forgive me if my
 question
 is a very simple or obvious one.
 
 I've just tried testing for the first time some php code that is
 pulling
 text out of a database to print it on the webpage.  Some of this text
 includes HTML, specifically in this case an img src=x
 statement.  Much to my surprise, this is not working.  Is there a
 problem with pulling HTML out of a database like this as the page is
 being written?
 
 There's no problem of course if my php code is writing the HTML to the
 page - in this case, the img src=xx statement works fine and
 the
 image is displayed.  Why is it a problem when my php script pulls the
 HTML code out of a database and writes it to the page from there??
 
 It would appear that when my php script writes HTML to the page a
 process of some kind is executed to, in this case, get the image and
 put
 it on the page.  Apparently this same process is NOT executed if the
 HTML is retrieved from a database and simply written to the page from
 there.  Is this correct?  And, if it is, can anyone suggest a
 workaround, another way to get done what I'm trying to do here?
 
 Thanks for any help you can give me.
 
 Rod Clay

Have you got a code snippet??

Alex

No virus found in this outgoing message. Scanned by AVG Free 8.0
Checked by AVG - http://www.avg.com 
Version: 8.0.138 / Virus Database: 270.4.11/1553 - Release Date: 15/07/2008
05:48


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



Re: [PHP] is there a problem with php script pulling HTML out of database as it writes the page??

2008-07-15 Thread dg
It would be helpful if you could clarify the error you are getting,  
but could be something involving quotes, stripslashes() and  
addslashes();



On Jul 15, 2008, at 2:36 PM, Rod Clay wrote:

Hello.  Again, I'm fairly new to php so please forgive me if my  
question is a very simple or obvious one.


I've just tried testing for the first time some php code that is  
pulling text out of a database to print it on the webpage.  Some of  
this text includes HTML, specifically in this case an img  
src=x statement.  Much to my surprise, this is not  
working.  Is there a problem with pulling HTML out of a database  
like this as the page is being written?
There's no problem of course if my php code is writing the HTML to  
the page - in this case, the img src=xx statement works fine  
and the image is displayed.  Why is it a problem when my php script  
pulls the HTML code out of a database and writes it to the page from  
there??


It would appear that when my php script writes HTML to the page a  
process of some kind is executed to, in this case, get the image and  
put it on the page.  Apparently this same process is NOT executed if  
the HTML is retrieved from a database and simply written to the page  
from there.  Is this correct?  And, if it is, can anyone suggest a  
workaround, another way to get done what I'm trying to do here?


Thanks for any help you can give me.

Rod Clay



--
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] Warning:Cannot modify header information - Error

2008-07-15 Thread Daniel Brown
On Tue, Jul 15, 2008 at 11:51 AM, Tiji varghese
[EMAIL PROTECTED] wrote:
 Hi All !
 I am having some problem with the code below. Everytime I run it it gives me 
 the following error:
 Warning: Cannot modify header information - headers already sent
 by (output started at
 C:\xampp\htdocs\practice.com\displayUserData.php:7) in 
 C:\xampp\htdocs\practice.com\displayUserData.php on line 12

This message means that something was sent before line 12.  In
your case, the HTML.  All things that have to do with headers must be
before ANYTHING is sent to the browser.  If you need to have the HTML
before a setcookie(), header(), or another header-based PHP action,
check into ob_start() and the other output-buffering functions PHP has
available.

-- 
/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.

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



[PHP] Changing PHP.ini

2008-07-15 Thread Adam Gerson
By visiting php.info in a web browser I have confirmed the location of 
my php.ini file as /usr/local/php5/lib/php.ini. I open that file and 
edit the line:


; - display_errors = Off

and change it to

display_errors = On

I then retstart Appache and visit php.info which still reports 
display_errors = Off. What else can I do?


Thanks,
Adam


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



RE: [PHP] Changing PHP.ini

2008-07-15 Thread bruce
what os are you using?

if you're on linux, type:
 find / -name php.ini

do you see multiple copies of the php.ini file?

if you're on windows, use the search function to see if you have multiple
copies of php.ini.

if you really want to do a quick check to see if you're modifying the right
php.ini, just go ahead and rename it to something else, and then restart
apache, and check your results..



-Original Message-
From: Adam Gerson [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2008 3:36 PM
To: php-general@lists.php.net
Subject: [PHP] Changing PHP.ini


By visiting php.info in a web browser I have confirmed the location of
my php.ini file as /usr/local/php5/lib/php.ini. I open that file and
edit the line:

; - display_errors = Off

and change it to

display_errors = On

I then retstart Appache and visit php.info which still reports
display_errors = Off. What else can I do?

Thanks,
Adam


--
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



[Fwd: Re: [PHP] is there a problem with php script pulling HTML out of database as it writes the page??]

2008-07-15 Thread Rod Clay
Sorry, I'm back again with this same problem!  Apparently the only 
reason it looked like it was solved an hour ago was because the img 
src=xx statement I tried reading out of the database was pointing 
to an image already on the page!


When the img src=xxx statement points to an image NOT already on 
the page, it doesn't work.


I thought the size of the image might be the problem, but no matter how 
small I make the image, it doesn't work.


Again, any insight into what might be the problem here would be MUCH 
appreciated.


Is it necessary for an img src=xxx statement to be in the code 
of the script writing the page for the image to be correctly inserted 
onto the page?  I believe that's the question.


It looks like when the img src=xx statement is pulled from a 
database and copied onto the webpage, some kind of php or HTML parser 
doesn't get a chance to parse it, resolve it, and go retrieve the image 
to put it on the page!!!


I hope I'm wrong about this, but at this point I don't have any other 
plausible theory!!
---BeginMessage---
Yes, here's the code that is retrieving news items from the database 
and printing them on the page (I do some other stuff with the text 
before, and after, I print it, for example, find the sentences, so I can 
print complete sentences, and not just pieces of sentences).  As I say, 
occasionally these news items contain some HTML, e.g., the img 
src=xxx statement.  All of the text is being correctly retrieved 
from the database and written to the page, including the img 
src=xxx statement, because I see it all in the page source of the 
page in my browser.  However, the img src= statement is NOT 
working, that is, the image does NOT appear on the page.


$result = mysql_query(SELECT * FROM newsitem ORDER BY 
newsitem_date DESC);

if (mysql_num_rows($result)  0)
{
 $i = 1;
 while (($row = mysql_fetch_assoc($result))  ($i  6)) { ?
  div id=newsitem
  p?php echo $row['newsitem_date']; ?bibr / ?php $title 
= $row['title']; echo $title; echo /i/bbr by ; ? ?php echo 
$row['author']; echo  of em; echo $row['newsservice']; ?/embrbr /

  ?php $newsitem_array = explode('.', $row['newsitem_text']);
 $print_newsitem = $newsitem_array[0] . .;
 $length_newsitem = strlen($print_newsitem);
 for ($j = 1; $length_newsitem  250; $j++) {
$print_newsitem = $print_newsitem . $newsitem_array[$j] . .;
$length_newsitem = strlen($print_newsitem);
 }
 echo $print_newsitem;
 echo br; $url_string = a href=\ . $row['url'] . \ (read 
more of this article)/a; echo $url_string;
$blog_result = mysql_query(SELECT * FROM blog where discussion 
= \$title\);

 if (mysql_num_rows($blog_result)  0)
$not = ;
 else
 $not =  not;
 echo br; echo This news item does$not have a blog discussion 
; echo nbsp;nbsp;;

 if (mysql_num_rows($blog_result)  0)
echo a href=\bloglist.php?discussion=$title\Read this 
item's blog/a ;

 else
echo a href=\blog.php?discussion=$title\Start a discussion 
on this item/a ;

   $i++;
  ?
  /pbr /
  /div
?php
 }
}
?

Stut wrote:

On 15 Jul 2008, at 22:36, Rod Clay wrote:
Hello.  Again, I'm fairly new to php so please forgive me if my 
question is a very simple or obvious one.


I've just tried testing for the first time some php code that is 
pulling text out of a database to print it on the webpage.  Some of 
this text includes HTML, specifically in this case an img 
src=x statement.  Much to my surprise, this is not 
working.  Is there a problem with pulling HTML out of a database like 
this as the page is being written?
There's no problem of course if my php code is writing the HTML to 
the page - in this case, the img src=xx statement works fine 
and the image is displayed.  Why is it a problem when my php script 
pulls the HTML code out of a database and writes it to the page from 
there??


It would appear that when my php script writes HTML to the page a 
process of some kind is executed to, in this case, get the image and 
put it on the page.  Apparently this same process is NOT executed if 
the HTML is retrieved from a database and simply written to the page 
from there.  Is this correct?  And, if it is, can anyone suggest a 
workaround, another way to get done what I'm trying to do here?


Code please, we're not mind readers!

-Stut



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



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

[PHP] Lookimg for a script....

2008-07-15 Thread Pete Holsberg
Can anyone point me to a (free) script that will ask for a person's 
email address and username, and then look up the password that's in a 
plain text file?


Thanks.


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



Re: [PHP] DB search and case sensitive comparison

2008-07-15 Thread Chris

 Now what I need to do is to ensure that the lookup_string is in the
 useragent string and the CASE is the same: IE: Mozilla and not MOZILLA or
 mozilla etc...

Make the database do the work if possible.

mysql select * from a where a like '%MOZILLA%';
+-+
| a   |
+-+
| Mozilla |
| MOZILLA |
+-+
2 rows in set (0.00 sec)

mysql select * from a where a like BINARY '%MOZILLA%';
+-+
| a   |
+-+
| MOZILLA |
+-+
1 row in set (0.00 sec)


-- 
Postgresql  php tutorials
http://www.designmagick.com/

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



[PHP] test

2008-07-15 Thread Børge Holen
test
-- 
---
Børge Holen
http://www.arivene.net

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



[Fwd: [Fwd: Re: [PHP] is there a problem with php script pulling HTML out of database as it writes the page??]]

2008-07-15 Thread Rod Clay
OK.  Once again, a problem I thought was abstruse and formidable turns 
out to be ridiculously simple and embarrassingly obvious (once you 
realize what it is  - image not in web server directory!!!)  But I 
didn't know until this happened that the browser sends a follow-up 
request to the web server for the images it finds specified on the 
page.  This is a very useful piece of knowledge!!  It made it obvious 
that I was looking for the problem in all the wrong places!  Sorry for 
the false alarm.  Next time I'll try to have a real problem everyone can 
sink their teeth into!!
---BeginMessage---
Sorry, I'm back again with this same problem!  Apparently the only 
reason it looked like it was solved an hour ago was because the img 
src=xx statement I tried reading out of the database was pointing 
to an image already on the page!


When the img src=xxx statement points to an image NOT already on 
the page, it doesn't work.


I thought the size of the image might be the problem, but no matter how 
small I make the image, it doesn't work.


Again, any insight into what might be the problem here would be MUCH 
appreciated.


Is it necessary for an img src=xxx statement to be in the code 
of the script writing the page for the image to be correctly inserted 
onto the page?  I believe that's the question.


It looks like when the img src=xx statement is pulled from a 
database and copied onto the webpage, some kind of php or HTML parser 
doesn't get a chance to parse it, resolve it, and go retrieve the image 
to put it on the page!!!


I hope I'm wrong about this, but at this point I don't have any other 
plausible theory!!
---BeginMessage---
Yes, here's the code that is retrieving news items from the database 
and printing them on the page (I do some other stuff with the text 
before, and after, I print it, for example, find the sentences, so I can 
print complete sentences, and not just pieces of sentences).  As I say, 
occasionally these news items contain some HTML, e.g., the img 
src=xxx statement.  All of the text is being correctly retrieved 
from the database and written to the page, including the img 
src=xxx statement, because I see it all in the page source of the 
page in my browser.  However, the img src= statement is NOT 
working, that is, the image does NOT appear on the page.


$result = mysql_query(SELECT * FROM newsitem ORDER BY 
newsitem_date DESC);

if (mysql_num_rows($result)  0)
{
 $i = 1;
 while (($row = mysql_fetch_assoc($result))  ($i  6)) { ?
  div id=newsitem
  p?php echo $row['newsitem_date']; ?bibr / ?php $title 
= $row['title']; echo $title; echo /i/bbr by ; ? ?php echo 
$row['author']; echo  of em; echo $row['newsservice']; ?/embrbr /

  ?php $newsitem_array = explode('.', $row['newsitem_text']);
 $print_newsitem = $newsitem_array[0] . .;
 $length_newsitem = strlen($print_newsitem);
 for ($j = 1; $length_newsitem  250; $j++) {
$print_newsitem = $print_newsitem . $newsitem_array[$j] . .;
$length_newsitem = strlen($print_newsitem);
 }
 echo $print_newsitem;
 echo br; $url_string = a href=\ . $row['url'] . \ (read 
more of this article)/a; echo $url_string;
$blog_result = mysql_query(SELECT * FROM blog where discussion 
= \$title\);

 if (mysql_num_rows($blog_result)  0)
$not = ;
 else
 $not =  not;
 echo br; echo This news item does$not have a blog discussion 
; echo nbsp;nbsp;;

 if (mysql_num_rows($blog_result)  0)
echo a href=\bloglist.php?discussion=$title\Read this 
item's blog/a ;

 else
echo a href=\blog.php?discussion=$title\Start a discussion 
on this item/a ;

   $i++;
  ?
  /pbr /
  /div
?php
 }
}
?

Stut wrote:

On 15 Jul 2008, at 22:36, Rod Clay wrote:
Hello.  Again, I'm fairly new to php so please forgive me if my 
question is a very simple or obvious one.


I've just tried testing for the first time some php code that is 
pulling text out of a database to print it on the webpage.  Some of 
this text includes HTML, specifically in this case an img 
src=x statement.  Much to my surprise, this is not 
working.  Is there a problem with pulling HTML out of a database like 
this as the page is being written?
There's no problem of course if my php code is writing the HTML to 
the page - in this case, the img src=xx statement works fine 
and the image is displayed.  Why is it a problem when my php script 
pulls the HTML code out of a database and writes it to the page from 
there??


It would appear that when my php script writes HTML to the page a 
process of some kind is executed to, in this case, get the image and 
put it on the page.  Apparently this same process is NOT executed if 
the HTML is retrieved from a database and simply written to the page 
from there.  Is this correct?  And, if it is, can anyone suggest a 
workaround, another way to get done what I'm 

Re: [PHP] Changing PHP.ini

2008-07-15 Thread Thorsten Suckow-Homberg


By visiting php.info in a web browser I have confirmed the location of 
my php.ini file as /usr/local/php5/lib/php.ini. I open that file and 
edit the line:


; - display_errors = Off

and change it to

display_errors = On

I then retstart Appache and visit php.info which still reports 
display_errors = Off. What else can I do?


Should be simple: create a script with the following code:

?php
phpinfo();
?

Then open that script in your browser. The generated output does also 
provide information about the path of the loaded php.ini.


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



[PHP] Downloading a file

2008-07-15 Thread Robbert van Andel
I am having trouble getting a file to download to work in Internet Explorer.
The site works fine in FireFox.   The page retrieves the contents of a file
from a database and outputs the following

 

?PHP

   

header(Content-type: application/octet-stream);

header(Content-Disposition: attachment; filename=\{$data['filename']}\);

header(Content-Description: PHP Generated Data);

echo $data['file'];

   

?

 

Where $data['filename'] is the name of the file as stored in the database
and $data['file'] is the contents of the file.  The script used to download
the file is called view.php.  As I mentioned, this works great in FireFox
but with Internet Explorer, I get the following error:

 

Internet Explorer cannot download view.php from www.yourdomain.com.

 

Internet Explorer was not able to open this Internet site. The requested
site is either unavailable or cannot be found. Please try again later.

 

Any help would be greatly appreciated.

 

Robbert



Re: [PHP] Lookimg for a script....

2008-07-15 Thread Daniel Brown
On Tue, Jul 15, 2008 at 7:34 PM, Pete Holsberg [EMAIL PROTECTED] wrote:
 Can anyone point me to a (free) script that will ask for a person's email
 address and username, and then look up the password that's in a plain text
 file?

http://www.google.com/search?q=flat-file+php+user+management

-- 
/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.

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