OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 1 Nov 2004 08:03:45 -0000 Issue 3086

php-general-digest-helplists.php.net
Date: Mon Nov 01 2004 - 02:03:45 CST


php-general Digest 1 Nov 2004 08:03:45 -0000 Issue 3086

Topics (messages 200774 through 200818):

Re: php command to open a url?
        200774 by: Lists
        200775 by: Ben Ramsey

Re: SOAP w/PHP 4
        200776 by: Ben Ramsey

Re: MultiSelect List Box in PHP
        200777 by: Andy B
        200779 by: Marek Kilimajer
        200783 by: Andy B
        200788 by: Chris Shiflett

Re: 3 is not a valid MySQL result resource
        200778 by: Ross Hulford
        200800 by: Curt Zirzow

code problem
        200780 by: Ross Hulford
        200782 by: John Holmes

Help with Advanced Guestbook
        200781 by: Melanie
        200784 by: Lists

str_pad with  
        200785 by: Jonel Rienton
        200787 by: Greg Donald

Re: PHP in CGI ....php.in
        200786 by: Jonel Rienton

Getting Information From Another Page
        200789 by: GH
        200792 by: Jason Wong

Help with preg_match_all()
        200790 by: Francisco Javier Escoppinichi Fernández
        200801 by: Curt Zirzow
        200803 by: Francisco Javier Escoppinichi Fernández

Re: php compiler
        200791 by: Hodicska Gergely
        200798 by: Curt Zirzow
        200818 by: Hodicska Gergely

Need to add a 0 to a float number
        200793 by: Brent Clements
        200795 by: Brent Clements

PHP Working With Excel File ?
        200794 by: Sejati Opreker
        200796 by: p80
        200797 by: p80

Re: beginnind and end of the week
        200799 by: Curt Zirzow

PHP_EOL on Darwin?
        200802 by: Greg Beaver

Simple math failing - PHP Bug?
        200804 by: Brian T. Allen
        200805 by: Thomas Goyne
        200806 by: Jason Wong
        200807 by: Chris Shiflett
        200808 by: Brian T. Allen
        200809 by: Brian T. Allen
        200810 by: Chris Shiflett
        200812 by: Brian T. Allen
        200813 by: M. Sokolewicz
        200815 by: Thomas Goyne

Re: Unable to validate XML with Schema if namespace is specified.
        200811 by: Christian Stocker

PLEASE HELP ON MAIL FUNCTION
        200814 by: kunal Aggarwal
        200816 by: Chris
        200817 by: Manuel Lemos

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


  header ("Location: ./");
  exit;

I use the above at the end of a authorization script, to direct back to
a page.

On Oct 31, 2004, at 12:03 PM, Ken Tozier wrote:

> I've been looking around in the php documentation for a couple of
> hours now but can't seem to find any functions to open a url in the
> current browser window. Does php allow this? If so, could someone
> point me to a link?
>
> Basically what I'm trying to do is loop back in a login form until a
> user enters a valid username/password and then redirect to that user's
> personal info page.
>
> Thanks for any help
>
> Ken
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


Ken Tozier wrote:
> I've been looking around in the php documentation for a couple of hours
> now but can't seem to find any functions to open a url in the current
> browser window. Does php allow this? If so, could someone point me to a
> link?

Check out the PHP header() function, specifically the "Location" header:
<http://www.php.net/header>

--
Regards,
Ben Ramsey
http://benramsey.com

---------------------------------------------------
Atlanta PHP - http://www.atlphp.org/
The Southeast's premier PHP community.
---------------------------------------------------

attached mail follows:


Dan Joseph wrote:
> Does PHP 4 support SOAP, or does something have to be added to it??

I know I've already given you some pointers on this, and hopefully
you're on your way to playing with PHP and SOAP, but I noticed a
potentially helpful article in the current issue of PHP Magazine.

It's by Adam Trachtenberg and entitled "Talking to eBay with PHP & SOAP."

Unfortunately, it's not available on-line, but you may be able to find a
copy in a bookstore or order it from the PHP Magazine Web site.
<http://www.php-mag.net/itr/ausgaben/psecom,id,229,nodeid,112.html>

--
Regards,
Ben Ramsey
http://benramsey.com

---------------------------------------------------
Atlanta PHP - http://www.atlphp.org/
The Southeast's premier PHP community.
---------------------------------------------------

attached mail follows:


I need to be able to print the selected items without the "array..." thing
around it. so example would be if 1 and 2 are selected it would print:

1, 2
it's supposed to be formatted for the user...

-----Original Message-----
From: -{ Rene Brehmer }- [mailto:metalbunnymetalbunny.net]
Sent: Sunday, October 31, 2004 5:12 AM
To: php-generallists.php.net
Subject: Re: [PHP] MultiSelect List Box in PHP

Would be easier if you didn't send it as HTML ... bad boy you

Rene

At 10:00 31-10-2004, M. Sokolewicz wrote:
>---------[ input.html ]----------
>.... one two three ....
>---------[ ]----------
>---------[ input.php ]----------
><?php
>print_r($_POST);
>?>
>---------[ ]----------
>---------[ output ]----------
>Array
>(
> [select] => Array
> (
> [0] => 1
> [1] => 2
> )
>
> [submit] => submit
>)
>---------[ ]----------
>Above output is with #1 and #2 selected, and #3 not selected. Easy, huh?
>
>- Tul

--
Rene Brehmer
aka Metalbunny

If your life was a dream, would you wake up from a nightmare, dripping of
sweat, hoping it was over? Or would you wake up happy and pleased, ready to
take on the day with a smile?

http://metalbunny.net/
References, tools, and other useful stuff...
Check out the new Metalbunny forums at http://forums.metalbunny.net/

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

attached mail follows:


implode()

Andy B wrote:
> I need to be able to print the selected items without the "array..." thing
> around it. so example would be if 1 and 2 are selected it would print:
>
> 1, 2
> it's supposed to be formatted for the user...
>
>
>
> -----Original Message-----
> From: -{ Rene Brehmer }- [mailto:metalbunnymetalbunny.net]
> Sent: Sunday, October 31, 2004 5:12 AM
> To: php-generallists.php.net
> Subject: Re: [PHP] MultiSelect List Box in PHP
>
>
> Would be easier if you didn't send it as HTML ... bad boy you
>
>
> Rene
>
> At 10:00 31-10-2004, M. Sokolewicz wrote:
>
>>---------[ input.html ]----------
>>.... one two three ....
>>---------[ ]----------
>>---------[ input.php ]----------
>><?php
>>print_r($_POST);
>>?>
>>---------[ ]----------
>>---------[ output ]----------
>>Array
>>(
>> [select] => Array
>> (
>> [0] => 1
>> [1] => 2
>> )
>>
>> [submit] => submit
>>)
>>---------[ ]----------
>>Above output is with #1 and #2 selected, and #3 not selected. Easy, huh?
>>
>>- Tul
>
>
> --
> Rene Brehmer
> aka Metalbunny
>
> If your life was a dream, would you wake up from a nightmare, dripping of
> sweat, hoping it was over? Or would you wake up happy and pleased, ready to
> take on the day with a smile?
>
> http://metalbunny.net/
> References, tools, and other useful stuff...
> Check out the new Metalbunny forums at http://forums.metalbunny.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


here is my total code for this file:
//note that the html structure isn't there yet but it still gives the
general idea

<?
include("libs/conf.db");
mysql_connect($host, $mysqluser, $mysqlpwd);
$query=mysql_query("select company from wata.members");
?>
<form method="post" action="<?echo $_SERVER['PHP_SELF'];?>">
<select name="members[]" multiple>
<?
while($listbox=mysql_fetch_array($query)){?>
<option value="<?echo $listbox['company'];?>"><?echo $listbox['company'];?>
<?}?>
</select>

<input type="submit" value="submit">
</form>

<?
echo implode(", ",$_POST['members']);
?>
//end code...
result printed at bottom of page under submit button is this:
(only prints last element of array)

for some reason it seems that my array isn't being built right... you can
change it to work with your db just change the connect string and the field
list from a db to test it...

-----Original Message-----
From: Marek Kilimajer [mailto:listskilimajer.net]
Sent: Sunday, October 31, 2004 4:14 PM
To: Andy B
Cc: PHP mailing list
Subject: Re: [PHP] MultiSelect List Box in PHP

implode()

attached mail follows:


--- Andy B <aborka1wmis.net> wrote:
> I need to be able to print the selected items without the
> "array..." thing around it. so example would be if 1 and 2 are
> selected it would print:
>
> 1, 2

It sounds like you just need to learn how to use arrays with PHP. The
manual is a good place to start:

http://www.php.net/array

Hope that helps.

Chris

=====
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly HTTP Developer's Handbook - Sams
Coming January 2005 http://httphandbook.org/

attached mail follows:


My page displays the first result and then I get the following
error.................

Warning: mysql_fetch_assoc(): 3 is not a valid MySQL result resource in
c:\inetpub\wwwroot\testy\Untitled-1.php on line 29

Please help.

R.

my code.............

<?php require_once('Connections/ross.php'); ?>
<?php
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
  $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database_ross, $ross);
$query_Recordset1 = "SELECT portfolio.location_name FROM portfolio";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1,
$startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $ross) or
die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
  $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
  $all_Recordset1 = mysql_query($query_Recordset1);
  $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

mysql_free_result($Recordset1);
?>
<?php echo $totalRows_Recordset1 ?>
<?php do { ?>
<p><?php echo $row_Recordset1['location_name']; ?></p>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>

attached mail follows:


* Thus wrote Ross Hulford:
> My page displays the first result and then I get the following
> error.................
>
> Warning: mysql_fetch_assoc(): 3 is not a valid MySQL result resource in
> c:\inetpub\wwwroot\testy\Untitled-1.php on line 29
>
>
>
> Please help.
>
> R.
>
>
> my code.............
>
>
> ...
>
> $Recordset1 = mysql_query($query_limit_Recordset1, $ross) or
> die(mysql_error());
> ...
>
> mysql_free_result($Recordset1);

You are freeing $Recordset1, thus making it useless.

> ?>
> <?php echo $totalRows_Recordset1 ?>
> <?php do { ?>
> <p><?php echo $row_Recordset1['location_name']; ?></p>
> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
 

Curt
--
Quoth the Raven, "Nevermore."

attached mail follows:


This is my code...........................

<?php require_once('Connections/ross.php'); ?>
<?php
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
  $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database_ross, $ross);
$query_Recordset1 = "SELECT portfolio.location_name FROM portfolio";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1,
$startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $ross) or
die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
  $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
  $all_Recordset1 = mysql_query($query_Recordset1);
  $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

mysql_free_result($Recordset1);
?>
<?php echo $totalRows_Recordset1 ?>
<?php do { ?>
<p><?php echo $row_Recordset1['location_name']; ?></p>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>

It displays one result then thows up the following error

Warning: mysql_fetch_assoc(): 3 is not a valid MySQL result resource in
c:\inetpub\wwwroot\testy\Untitled-1.php on line 29

attached mail follows:


Ross Hulford wrote:
> This is my code...........................
[snip]
> mysql_free_result($Recordset1);
...
> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
>
> It displays one result then thows up the following error
>
> Warning: mysql_fetch_assoc(): 3 is not a valid MySQL result resource in
> c:\inetpub\wwwroot\testy\Untitled-1.php on line 29

You free the result and then try to fetch more rows from it... not going
to work.

--

---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

attached mail follows:


I am trying to use Advanced Guestbook in my website
(www.tracingfootprints.com) but would like to have it match (in style,
background, etc) the other pages in the site. I've been trying to figure
out how to do that (with very limited PHP knowledge) without success. My
site is hosted by Go Daddy on LInux. I'm designing the site in FrontPage
2002.

Thanks!
Melanie

attached mail follows:


It looks like you can change quite a bit by opening the "body.php" file
in the "templates" folder. If you are using FP, if you haven't
already, make sure to set it so it does not affect code. You might
want to open that in Notepad to make sure though.

On Oct 31, 2004, at 1:03 PM, Melanie wrote:

> I am trying to use Advanced Guestbook in my website
> (www.tracingfootprints.com) but would like to have it match (in style,
> background, etc) the other pages in the site. I've been trying to
> figure out how to do that (with very limited PHP knowledge) without
> success. My site is hosted by Go Daddy on LInux. I'm designing the
> site in FrontPage 2002.
> Thanks!
> Melanie
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


Hi guys,

i was trying to do an str_pad with &nbsp; (space) but somehow it's just
putting in one space and &nbs

sample code:

<? echo str_pad($varname,20,"&nbsp;" ?>

anybody else experienced this?

thanks and regards,
jonel

--
I not know English well, but I know 7 computer languages.
-anonymous

attached mail follows:


On Sun, 31 Oct 2004 16:13:44 -0600, Jonel Rienton <jonelroad14.com> wrote:
> i was trying to do an str_pad with &nbsp; (space) but somehow it's just
> putting in one space and &nbs
>
> sample code:
>
> <? echo str_pad($varname,20,"&nbsp;" ?>
>
> anybody else experienced this?

"&nbsp;" is 6 characters. It may only appear as one character when
viewed as html, but to str_pad() it's 6 characters.

--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

attached mail follows:


have you tried

#!/usr/local/lib/php -c /home/mydomaine/www

--
I not know English well, but I know 7 computer languages.

On Oct 31, 2004, at 2:32 AM, Christian Ista wrote:

>
>> where did you place your php.ini?
>
> In the root of my application in www. /home/mydomaine/www
>
> Thanks,
>
>
> Christian,
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


I would like to know how to extract the following from the website
http://www.state.ny.us/security/

The Values for

New York State is currently at:

New York City is currently at:

I would like to store this information into my database and check it
every half hour to see if it has been updated?

How can I do this?

attached mail follows:


On Sunday 31 October 2004 23:12, GH wrote:
> I would like to know how to extract the following from the website
> http://www.state.ny.us/security/
>
> The Values for
>
> New York State is currently at:
>
> New York City is currently at:
>
> I would like to store this information into my database and check it
> every half hour to see if it has been updated?
>
> How can I do this?

fopen(), preg_match()

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
I bet Einstein turned himself all sorts of colors before he invented the
lightbulb.

  -- Homer Simpson
     Bart the Genius
*/

attached mail follows:


Hello people...

I'm relatively a beginner with regular expressions, so I need a little
help here.. I hope you can help me...

Ok, I have a HTML file with several tags like this:
{$base.username}
{$base.date}
{$blog.lastpost}

And so on.. It's a kind of a template system... well... I need to
create a expression to get all the tags from the HTML with
preg_match_all() in order to have them in a array...

Can you help me with this.. I already Googled for that, but I really
don't understand too well :P

--
Francisco Javier Escoppinichi Fernández
Email: fjefdezgmail.com
Web: http://www.fire-dragon.net/
MSN: dragonfire-dragon.net
Cel: 044 (612) 348 91 00

"Sólo hay 3 cosas que no vuelven atrás: la palabra emitida, la flecha
lanzada y la oportunidad perdida."

attached mail follows:


* Thus wrote Francisco Javier Escoppinichi Fernndez:
> Hello people...
>
> I'm relatively a beginner with regular expressions, so I need a little
> help here.. I hope you can help me...

If you read the whole section http://php.net/pcre you'll be able
to do this in your sleep.

>
> Ok, I have a HTML file with several tags like this:
> {$base.username}
> {$base.date}
> {$blog.lastpost}
>
> And so on.. It's a kind of a template system... well... I need to
> create a expression to get all the tags from the HTML with
> preg_match_all() in order to have them in a array...

So your looking from something that starts with '{' and continues
while not a ')' ...

  /{([^}]*?)}/

Curt
--
Quoth the Raven, "Nevermore."

attached mail follows:


Thanks!

Worked like a charm!

*Problem solved*

On Mon, 1 Nov 2004 03:01:12 +0000, Curt Zirzow
<php-generalzirzow.dyndns.org> wrote:
> * Thus wrote Francisco Javier Escoppinichi Fernndez:
> > Hello people...
> >
> > I'm relatively a beginner with regular expressions, so I need a little
> > help here.. I hope you can help me...
>
> If you read the whole section http://php.net/pcre you'll be able
> to do this in your sleep.
>
> >
> > Ok, I have a HTML file with several tags like this:
> > {$base.username}
> > {$base.date}
> > {$blog.lastpost}
> >
> > And so on.. It's a kind of a template system... well... I need to
> > create a expression to get all the tags from the HTML with
> > preg_match_all() in order to have them in a array...
>
> So your looking from something that starts with '{' and continues
> while not a ')' ...
>
> /{([^}]*?)}/
>
> Curt
> --
> Quoth the Raven, "Nevermore."
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Francisco Javier Escoppinichi Fernández
Email: fjefdezgmail.com
Web: http://www.fire-dragon.net/
MSN: dragonfire-dragon.net
Cel: 044 (612) 348 91 00

"Sólo hay 3 cosas que no vuelven atrás: la palabra emitida, la flecha
lanzada y la oportunidad perdida."

attached mail follows:


Hi!

> I think the precedence of left and right associative operands can't
be > compared. The switch between associativities already separates the
> expression (if it could be explained this way).

Yes, this behaviour confused me. This is not common in other programming
languages:
o C : invalid lvalue in assignment
o Java : required: variable
                found : value
o JavaScript: invalid assignment left-hand side (Mozilla)
                syntax error (Internet explorer)

But for me it isn't egxactly clear how the evaluation order was
calculated (why doesn't the first = operator executed before &&). Does
anybody know for example a flowchart, how it is implemented in PHP?

Felho

attached mail follows:


* Thus wrote Hodicska Gergely:
> Hi!
>
> > I think the precedence of left and right associative operands can't
> be > compared. The switch between associativities already separates the
> > expression (if it could be explained this way).
>
> Yes, this behaviour confused me. This is not common in other programming
> languages:
> o C : invalid lvalue in assignment
> o Java : required: variable
> found : value
> o JavaScript: invalid assignment left-hand side (Mozilla)
> syntax error (Internet explorer)
>
> But for me it isn't egxactly clear how the evaluation order was
> calculated (why doesn't the first = operator executed before &&). Does
> anybody know for example a flowchart, how it is implemented in PHP?

I kind of hinted in my earlier what is going on but:

  $a = 1 && $b = 0;

Is first silently evaluated as:

  $a = (1 && $b = 0);

Now we test the left and right expressions of &&. The left
expression is true. So the right expression is tested which
happens to be ($b = 0).

Curt
--
Quoth the Raven, "Nevermore."

attached mail follows:


> I kind of hinted in my earlier what is going on but:
> $a = 1 && $b = 0;
> Is first silently evaluated as:
> $a = (1 && $b = 0);
thx your answer, just one more little thing...

> So the right expression is tested which happens to be ($b = 0).
...why ($b = 0) is on the right side, not only $b.

Felho

u.i. Is there any information, why PHP was implemented this way?

attached mail follows:


Hi,
 How would I add a 0 to variables that have the following?

I want

$var = 6.5

to be converted to

$var = 6.50

Thanks,
Brent

attached mail follows:


Solved my own problem

Note to self, RTFM:

number_format is w hat I needed.

Thanks,
Brent

----- Original Message -----
From: "Brent Clements" <bclemimaginative-enterprises.com>
To: <php-generallists.php.net>
Sent: Sunday, October 31, 2004 8:01 PM
Subject: [PHP] Need to add a 0 to a float number

Hi,
 How would I add a 0 to variables that have the following?

I want

$var = 6.5

to be converted to

$var = 6.50

Thanks,
Brent

attached mail follows:


Hi,
Can PHP work with Excel files as database ?
If not, how can I conver it to MySQL format and
reconvert it to Excel 'coz I need it to report it
in Excel format,
Thx

                
_______________________________
Do you Yahoo!?
Express yourself with Y! Messenger! Free. Download now.
http://messenger.yahoo.com

attached mail follows:


On Monday 01 November 2004 02:58 am, Sejati Opreker wrote:
> Hi,
> Can PHP work with Excel files as database ?
> If not, how can I conver it to MySQL format and
> reconvert it to Excel 'coz I need it to report it
> in Excel format,

With exel, export your exel file to CSV (by doing save as...) then you can
import your CSV file to mysql using the phpmyadmin import interface.

attached mail follows:


On Monday 01 November 2004 02:58 am, Sejati Opreker wrote:
> Hi,
> Can PHP work with Excel files as database ?
> If not, how can I conver it to MySQL format and
> reconvert it to Excel 'coz I need it to report it
> in Excel format,
> Thx

With exel, export your exel file to CSV (by doing save as...) then you can
import your CSV file to mysql using the phpmyadmin import interface.

attached mail follows:


* Thus wrote Jerry Swanson:
> I need to run a query using PHP/MYSQL. The query should be for a week.
> So if today is tuesday, the query should be from Monday to Sunday.
> How in in php I can know when the beginning and end of the week?
>

<?php

  // in case the date unlikley changes
  $t = time();

  // this weeks monday
  $m = strtotime('this monday', $t);

  // next weeks monday minus 1 second
  $s = strtotime('next monday', $t) - 1;

  echo date('r', $m), "\n";
  echo date('r', $s), "\n"

?>

Now $m and $s contain the proper timestamps.

Curt
--
Quoth the Raven, "Nevermore."

attached mail follows:


Hi all,

What's the standard line ending for Darwin? is it still the same as old
Mac, which I think was just \r? Or does it use \n like unix?

Greg

attached mail follows:


Hi,

OK, I'm totally stumped by this. This should be the simplest math
imaginable (addition and subtraction), but PHP is coming up with the
wrong answer!

I've checked on 3 different machines (all linux) running both PHP 4 and
PHP 5.

Here is the code to duplicate the problem:

-----------------------------------
<?php

$a = 2503.54;
$b = 303.55;
$c = 202.13;

$total = 0;
$total += $a;
$total += $b;
$total += $c;

$added_total = $total;

echo "$a + $b + $c = $total<br>";
echo "Actual: $total<br><br>";

$total -= $a;
$total -= $b;
$total -= $c;

echo "$added_total - $a - $b - $c = 0<br>";
echo "Actual: $total<br><br>";

?>
-----------------------------------

This ~should~ output this:

       2503.54 + 303.55 + 202.13 = 3009.22
       Actual: 3009.22

       3009.22 - 2503.54 - 303.55 - 202.13 = 0
       Actual: 0

But instead it outputs this:

       2503.54 + 303.55 + 202.13 = 3009.22
       Actual: 3009.22

       3009.22 - 2503.54 - 303.55 - 202.13 = 0
       Actual: 2.84217094304E-13

Now I'm the first to admit that 0.000000000000284217094304 and 0 are
really very close, but when you are testing a variable to see if it
equals 0, it is the difference between true and false.

This seems very, very basic to me, but I can't find the flaw in my code.

Is this legitimately bad math on the part of PHP?

Thanks,
Brian

attached mail follows:


On Sun, 31 Oct 2004 21:52:32 -0700, Brian T. Allen <briangzmarketing.com>
wrote:

> Hi,
>
> OK, I'm totally stumped by this. This should be the simplest math
> imaginable (addition and subtraction), but PHP is coming up with the
> wrong answer!
>
> [snip]
> Is this legitimately bad math on the part of PHP?
>
> Thanks,
> Brian
>

This is a flaw in how computers handle floating point numbers, not php.
As the memory needed to store exact floats to any useful precision would
quickly get out of control, floats are handled inprecisely. As a result,
you should never test for equality with a float, but rather check if the
float is within a certain range of the desired number.

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

http://www.smempire.org

attached mail follows:


On Monday 01 November 2004 04:52, Brian T. Allen wrote:

> OK, I'm totally stumped by this. This should be the simplest math
> imaginable (addition and subtraction), but PHP is coming up with the
> wrong answer!
>
> I've checked on 3 different machines (all linux) running both PHP 4 and
> PHP 5.
>
> Here is the code to duplicate the problem:

[snip]

> Now I'm the first to admit that 0.000000000000284217094304 and 0 are
> really very close, but when you are testing a variable to see if it
> equals 0, it is the difference between true and false.
>
> This seems very, very basic to me, but I can't find the flaw in my code.
>
> Is this legitimately bad math on the part of PHP?

Most computer languages handling floating point calculations just as poorly.
If accuracy is important use the BCMath functions.

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
BOFH Excuse #332:

suboptimal routing experience
*/

attached mail follows:


--- Jason Wong <php-generalgremlins.biz> wrote:
> Most computer languages handling floating point calculations
> just as poorly. If accuracy is important use the BCMath
> functions.

Or use Fortran and double precision. :-)

Still, testing a floating point number as a boolean is one of the worst
ideas I've ever heard...

Chris

=====
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly HTTP Developer's Handbook - Sams
Coming January 2005 http://httphandbook.org/

attached mail follows:


Thomas Goyne wrote:

> On Sun, 31 Oct 2004 21:52:32 -0700, Brian T. Allen
> <briangzmarketing.com> wrote:
>
>> Hi,
>>
>> OK, I'm totally stumped by this. This should be the simplest math
>> imaginable (addition and subtraction), but PHP is coming up with the
>> wrong answer!
>>
>> [snip]
>> Is this legitimately bad math on the part of PHP?
>>
>> Thanks,
>> Brian
>>
>
> This is a flaw in how computers handle floating point numbers, not
> php. As the memory needed to store exact floats to any useful
> precision would quickly get out of control, floats are handled
> inprecisely. As a result, you should never test for equality with a
> float, but rather check if the float is within a certain range of the
> desired number.
>

Wow, this is pretty dissappointing.

I can understand if I was doing math on 12 or 13 digit numbers, but just
adding and subtracting back out a couple of 2 digit decimals I would
expect to end up back at zero.

I understand it isn't PHP's fault.

Thanks for the quick reply,
Brian

attached mail follows:


Chris Shiflett wrote:

>--- Jason Wong <php-generalgremlins.biz> wrote:
>
>
>>Most computer languages handling floating point calculations
>>just as poorly. If accuracy is important use the BCMath
>>functions.
>>
>>
>
>Or use Fortran and double precision. :-)
>
>Still, testing a floating point number as a boolean is one of the worst
>ideas I've ever heard...
>
>Chris
>
>=====
>Chris Shiflett - http://shiflett.org/
>
>PHP Security - O'Reilly HTTP Developer's Handbook - Sams
>Coming January 2005 http://httphandbook.org/
>
>
>
Well, in fairness, it's one of the worst ideas you've ever heard because
you know of this limitation.

In reality, using a calculator or something that doesn't share this
limitation, 0 = 0 and this wouldn't be a problem. It's only when 0 =
0.0000000000001342344 that this becomes a problem.

Brian

attached mail follows:


--- "Brian T. Allen" <briangzmarketing.com> wrote:
> Well, in fairness, it's one of the worst ideas you've ever heard
> because you know of this limitation.

Of course. That wasn't a dig at you or anything - just a comment. You're
free to heed or ignore it.

> In reality, using a calculator or something that doesn't share
> this limitation, 0 = 0 and this wouldn't be a problem.

Well, 0 == 0 in PHP, too. Calculators have the same limitations that any
other computing device does. Some modern calculators have some pretty
impressive precision, but it's not hard to exceed it with a few seemingly
harmless operations. A couple of numbers like 12.34567 and 23.45678 can
get pretty nasty with a few operations.

Regardless of this, I'm not in favor of depending on anything that's the
least bit questionable or complicated. I don't even like evaluating
integers as boolean unless they are strictly 0 or 1, and even then there
can be problems (you accidentally decrement a variable twice before
evaluating it again, so that it goes from 1 to -1 and continues to
evaluate as true forever).

In short, complexity breeds problems, regardless of how smart you are.

Chris

=====
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly HTTP Developer's Handbook - Sams
Coming January 2005 http://httphandbook.org/

attached mail follows:


Chris Shiflett wrote:

>--- "Brian T. Allen" <briangzmarketing.com> wrote:
>
>
>>Well, in fairness, it's one of the worst ideas you've ever heard
>>because you know of this limitation.
>>
>>
>
>Of course. That wasn't a dig at you or anything - just a comment. You're
>free to heed or ignore it.
>
>
>
>>In reality, using a calculator or something that doesn't share
>>this limitation, 0 = 0 and this wouldn't be a problem.
>>
>>
>
>Well, 0 == 0 in PHP, too. Calculators have the same limitations that any
>other computing device does. Some modern calculators have some pretty
>impressive precision, but it's not hard to exceed it with a few seemingly
>harmless operations. A couple of numbers like 12.34567 and 23.45678 can
>get pretty nasty with a few operations.
>
>Regardless of this, I'm not in favor of depending on anything that's the
>least bit questionable or complicated. I don't even like evaluating
>integers as boolean unless they are strictly 0 or 1, and even then there
>can be problems (you accidentally decrement a variable twice before
>evaluating it again, so that it goes from 1 to -1 and continues to
>evaluate as true forever).
>
>In short, complexity breeds problems, regardless of how smart you are.
>
>Chris
>
>=====
>Chris Shiflett - http://shiflett.org/
>
>PHP Security - O'Reilly HTTP Developer's Handbook - Sams
>Coming January 2005 http://httphandbook.org/
>
>
>

No worries, this isn't personal. I just want to explore this limitation
and it's implications for my benefit and the benefit of any that read
this thread later when they are searching for answers to a similar problem.

I just think the following should work, and outside of this limitation
of computers is sound programming:

$subtotal = 0;
$subtotal += 503.54;
$subtotal += 303.55;
$subtotal -= 503.54;
$subtotal -= 303.55;

if($subtotal > 0){
    // A balance is due
}

But if $subtotal is 0.0000000000034322 then it shows a balance is due
when one isn't.

When adding dollar amounts using only whole cents (and excluding the
limitation we've been discussing) you should always have a credit >=
.01, a balance >= .01, or no balance / credit due, which would equal 0
or 0.00, but NOT 0.0000000000034322.

Yes, there are ways to program around this, but it shouldn't be
necessary. The example above shouldn't be questionable or complicated,
in fact it is about as basic as it comes. It's 2nd Grade math. You
just should have to program around that. I would MUCH rather have PHP
run a little slower and take up more memory and get the answer right
then have every PHP programmer have to program around this limitation
for even the most basic math.

Thanks,
Brian

attached mail follows:


Brian T. Allen wrote:
> Chris Shiflett wrote:
>
>> --- "Brian T. Allen" <briangzmarketing.com> wrote:
>>
>>
>>> Well, in fairness, it's one of the worst ideas you've ever heard
>>> because you know of this limitation.
>>>
>>
>>
>> Of course. That wasn't a dig at you or anything - just a comment. You're
>> free to heed or ignore it.
>>
>>
>>
>>> In reality, using a calculator or something that doesn't share
>>> this limitation, 0 = 0 and this wouldn't be a problem.
>>>
>>
>>
>> Well, 0 == 0 in PHP, too. Calculators have the same limitations that any
>> other computing device does. Some modern calculators have some pretty
>> impressive precision, but it's not hard to exceed it with a few seemingly
>> harmless operations. A couple of numbers like 12.34567 and 23.45678 can
>> get pretty nasty with a few operations.
>>
>> Regardless of this, I'm not in favor of depending on anything that's the
>> least bit questionable or complicated. I don't even like evaluating
>> integers as boolean unless they are strictly 0 or 1, and even then there
>> can be problems (you accidentally decrement a variable twice before
>> evaluating it again, so that it goes from 1 to -1 and continues to
>> evaluate as true forever).
>>
>> In short, complexity breeds problems, regardless of how smart you are.
>>
>> Chris
>>
>> =====
>> Chris Shiflett - http://shiflett.org/
>>
>> PHP Security - O'Reilly HTTP Developer's Handbook - Sams
>> Coming January 2005 http://httphandbook.org/
>>
>>
>>
>
> No worries, this isn't personal. I just want to explore this limitation
> and it's implications for my benefit and the benefit of any that read
> this thread later when they are searching for answers to a similar problem.
>
> I just think the following should work, and outside of this limitation
> of computers is sound programming:
>
> $subtotal = 0;
> $subtotal += 503.54;
> $subtotal += 303.55;
> $subtotal -= 503.54;
> $subtotal -= 303.55;
>
> if($subtotal > 0){
> // A balance is due
> }
>
> But if $subtotal is 0.0000000000034322 then it shows a balance is due
> when one isn't.
>
> When adding dollar amounts using only whole cents (and excluding the
> limitation we've been discussing) you should always have a credit >=
> .01, a balance >= .01, or no balance / credit due, which would equal 0
> or 0.00, but NOT 0.0000000000034322.
>
> Yes, there are ways to program around this, but it shouldn't be
> necessary. The example above shouldn't be questionable or complicated,
> in fact it is about as basic as it comes. It's 2nd Grade math. You
> just should have to program around that. I would MUCH rather have PHP
> run a little slower and take up more memory and get the answer right
> then have every PHP programmer have to program around this limitation
> for even the most basic math.
>
> Thanks,
> Brian
have you ever thought about working with all those numbers in cents, as
integers, and applying the math to that? That'll work *just fine*

attached mail follows:


On Sun, 31 Oct 2004 23:30:53 -0700, Brian T. Allen <briangzmarketing.com>
wrote:

> No worries, this isn't personal. I just want to explore this limitation
> and it's implications for my benefit and the benefit of any that read
> this thread later when they are searching for answers to a similar
> problem.
>
> I just think the following should work, and outside of this limitation
> of computers is sound programming:
>
> $subtotal = 0;
> $subtotal += 503.54;
> $subtotal += 303.55;
> $subtotal -= 503.54;
> $subtotal -= 303.55;
>
> if($subtotal > 0){
> // A balance is due
> }
>
> But if $subtotal is 0.0000000000034322 then it shows a balance is due
> when one isn't.
>
> When adding dollar amounts using only whole cents (and excluding the
> limitation we've been discussing) you should always have a credit >=
> .01, a balance >= .01, or no balance / credit due, which would equal 0
> or 0.00, but NOT 0.0000000000034322.
>
> Yes, there are ways to program around this, but it shouldn't be
> necessary. The example above shouldn't be questionable or complicated,
> in fact it is about as basic as it comes. It's 2nd Grade math. You
> just should have to program around that. I would MUCH rather have PHP
> run a little slower and take up more memory and get the answer right
> then have every PHP programmer have to program around this limitation
> for even the most basic math.
>
> Thanks,
> Brian
>

It would be more than a minor slowdown, as php would have to inplement
something that is so slow when done at a far lower level that there used
to be a seperate processor just to handle it. Also, 1/3 is certainly
basic math, but it eventually gets impossible to store accuratly, as there
is not exact decimal value. You could store the fractional value of it,
but what happens when you have something like log(sqrt(1/3))? The only
way to have an exact value would be to store every single operation done
to the number, and rerun them every time the number is refered to, but you
still have rounding between every step of that.

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

http://www.smempire.org

attached mail follows:


On Sun, 31 Oct 2004 19:08:04 +0000, Dusty Bin <lixoargus.pt> wrote:
> I am trying to validate an XML document, using
> DomDocument::schemaValidate() as in the following code:
>
> <?php
> $txt =<<<EOT
> <?xml version="1.0"?>
> <Article xmlns='http://www.example.com/xml'>
> <Item>ItemText</Item>
> </Article>
> EOT;
> $dom = new DOMDocument();
> $dom->loadXML($txt);
> if ($dom->schemaValidate("Article.xsd")) {
> print $dom->saveXML();
> }
> ?>
>
> The schema I am trying to validate against is:
>
> <?xml version="1.0" ?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
> <xs:element name="Article">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="Item" maxOccurs="unbounded"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:schema>
>
> This produces the following output:
>
> Warning: Element Article not declared in E:\PHPTest\testXML.php on line 10
>
> Warning: Element Article not declared in E:\PHPTest\testXML.php on line 10

Aren't you missing any namespace declaration in your Schema File?

I'm no XML Schema Expert at al, so I took trang and let it made one
out of your XML and it produced the following:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://www.example.com/xml"
xmlns:x="http://www.example.com/xml">
  <xs:element name="Article">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="x:Item"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Item" type="xs:NCName"/>
</xs:schema>

And this validates (at least with libxml2 version 2.6.14, the PHP
version doesn't matter, since all the validation is done by
libxml2...)

chregu

>
> If I remove the default namespace from the article tag, the XML
> validates correctly. I seem to recollect that namespace support is not
> fully implemented, so my question is, is this a bug, or just something
> not yet implemented, or is there an obvious blunder in what I am trying
> to do, which I cannot see.
> Best regards. . . Dusty
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60 | fax +41 1 240 56 71
http://www.bitflux.ch | chregubitflux.ch | gnupg-keyid 0x5CE1DECB

attached mail follows:


 
  
Dear friend,
I am using PHP 4.3.4 version.
Please tell how to unpload a mail function.
Error comes on executing mail function is

"mail(): SMTP server response: 550 5.7.1 Unable to relay for softenggiclcl.com in C:\Program Files\Apache Group\Apache2\htdocs\testprodigious\MAIL\mail_enquiry.php on line 30
"

Scprit used is

<?
/* recipients */
      $to = "softenggiclcl.com";

    /* subject */
   $subject = "Automatic Weekly Reports of Marketing from Prodigious";

   /*making message body */
       $message ="Wekly Reprot";

        /* To send HTML mail, you can
         set the Content-type header. there header are nessare for maing table
         in php and even for html pahe without these header only script will send
         in mail no brwser look*/

          $headers = "MIME-Version: 1.0\r\n";
          $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

                /* and now mail it */
                mail($to, $subject, $message,$headers );
?>

I will be grateful to you.

With Best Regards
 
 
 «·´`·.(*·.¸(`·.¸ ¸.·´)¸.·*).·´`·»
«..Er. Kunal Aggarwal ..»
«·´`·.(¸.·*(¸.·´ `·.¸)*·.¸).·´`·»
 
Software Engineer
ICL Certifications Limited
372, Industrial Area Phase 1
Panchkula
Haryana
India
Voice Talk:-+91-98159-65988(Mobile), +91-0172-2563358 (Office) * 24, +91-0172-2563358 (Fax)
 
Email: softenggiclcl.com
Website: www.iclcertifications.com

attached mail follows:


Your Apache/PHP Mail function is working properly. The SMTP server needs
to be configured to relay email from the PHP server.

The normal configuration would be to allow the relay of all mail from
that server.

Chris

kunal Aggarwal wrote:

>
>
>Dear friend,
>I am using PHP 4.3.4 version.
>Please tell how to unpload a mail function.
>Error comes on executing mail function is
>
>"mail(): SMTP server response: 550 5.7.1 Unable to relay for softenggiclcl.com in C:\Program Files\Apache Group\Apache2\htdocs\testprodigious\MAIL\mail_enquiry.php on line 30
>"
>
>
>Scprit used is
>
><?
>/* recipients */
> $to = "softenggiclcl.com";
>
> /* subject */
> $subject = "Automatic Weekly Reports of Marketing from Prodigious";
>
> /*making message body */
> $message ="Wekly Reprot";
>
> /* To send HTML mail, you can
> set the Content-type header. there header are nessare for maing table
> in php and even for html pahe without these header only script will send
> in mail no brwser look*/
>
> $headers = "MIME-Version: 1.0\r\n";
> $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
>
> /* and now mail it */
> mail($to, $subject, $message,$headers );
>?>
>
>
>I will be grateful to you.
>
>With Best Regards
>
>
> «·´`·.(*·.¸(`·.¸ ¸.·´)¸.·*).·´`·»
>«..Er. Kunal Aggarwal ..»
>«·´`·.(¸.·*(¸.·´ `·.¸)*·.¸).·´`·»
>
>Software Engineer
>ICL Certifications Limited
>372, Industrial Area Phase 1
>Panchkula
>Haryana
>India
>Voice Talk:-+91-98159-65988(Mobile), +91-0172-2563358 (Office) * 24, +91-0172-2563358 (Fax)
>
>Email: softenggiclcl.com
>Website: www.iclcertifications.com
>
>
>

attached mail follows:


Hello,

On 11/01/2004 03:58 AM, Kunal Aggarwal wrote:
> I am using PHP 4.3.4 version.
> Please tell how to unpload a mail function.
> Error comes on executing mail function is
>
> "mail(): SMTP server response: 550 5.7.1 Unable to relay for softenggiclcl.com in C:\Program Files\Apache Group\Apache2\htdocs\testprodigious\MAIL\mail_enquiry.php on line 30
> "

This means that your SMTP server is requiring authentication to relay
messages.

The mail function does not support authentication. You may want to try
this class that comes with wrapper function named smtp_mail(). It
emulates the mail() function except that it lets you relay messages on a
server authenticating with a user name and password that you can provide:

http://www.phpclasses.org/mimemessage

You also need these two classes:

http://www.phpclasses.org/smtpclass

http://www.phpclasses.org/sasl

--

Regards,
Manuel Lemos

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

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html