php-general Digest 15 Oct 2010 21:02:12 -0000 Issue 6989

Topics (messages 308730 through 308741):

Re: floored by floor()
        308730 by: Glen Fuller

An invitation to Multiply.com
        308731 by: Farianto Kurniawan (via Multiply)

Re: Help with sending credentials?
        308732 by: Richard Quadling
        308735 by: Tommy Pham
        308737 by: Richard Quadling

Re: RegExp question: how to add a number?
        308733 by: Ford, Mike
        308736 by: Richard Quadling
        308738 by: Andrew Ballard
        308739 by: Richard Quadling
        308740 by: Andrew Ballard

Re: searching for application like Google Doc
        308734 by: Tommy Pham

Error message not understood
        308741 by: sueandant

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On 10/14/2010 7:49 AM, chris h wrote:
floor(32703) is different then floor(327.03 * 100).  The former is an int,
while the later is a float.  Read those links that were sent :)


Chris.


On Thu, Oct 14, 2010 at 2:14 AM, Glen Fuller<glenmful...@shaw.ca>  wrote:

On 10/13/2010 10:48 PM, Mattias Thorslund wrote:

Hi List,

I'm having a problem with the behavior of the floor() function:

echo floor(327.03 * 100)."\n"; //prints "32702" and not "32703"!!

Sanity check:
var_dump(327.03 * 100); //prints "float(32703)" as expected

Any ideas why this happens, and how to work around it?

Thanks,

Mattias



Wouldn't that be equivalent to floor(32703), and since 32703 is the nearest
integer to 32703 it returns it?

Glen Fuller



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





I, see - makes sense now, thank you!


--- End Message ---
--- Begin Message ---
Your Friend Farianto wants you to be his contact on Multiply. Check it out:
http://multiply.com/si/aCD2q,fg,4cQ+pf+4etZKQ




If you never want to be contacted by Multiply again, go to 
http://multiply.com/bl/aCD2q,fg,4cQ+pf+4etZKQ

Report abuse: http://multiply.com/info/inquiry
Privacy policy: http://multiply.com/info/privacy

We haven't added your email address to any lists, nor will we share it with 
anyone at any time.
Multiply, 6001 Park of Commerce Blvd,
Boca Raton, FL

Copyright 2004-2010 Multiply, Inc., All Rights Reserved.

--- End Message ---
--- Begin Message ---
On 14 October 2010 21:45, Brian Dunning <br...@briandunning.com> wrote:
> Gents -
>
> I'm trying to work with a major vendor's web service, but all my efforts are 
> met with a 401 authentication error response. I can log in manually to this 
> URL using these credentials through a browser, so I know the credentials are 
> good. Unfortunately the support guys at the vendor don't see any problem with 
> my code and have not been able to help.
>
> $url = "https://servername.com/script";;
> $ctx = stream_context_create(array('https' => array(
>        'timeout' => 10,
>        'header'  => sprintf("Authorization: Basic %s\r\n", 
> base64_encode("myUsername:myPassword"))
>        )));
> $result = file_get_contents($url, 0, $ctx);
> $http_response = explode(' ', $http_response_header[0]);
> $response_code = $http_response[1];     <<<=== This is evaluating to '401'
>
>
> Thanks.

Are they using Basic authentication?

Does ...

https://myUsername:mypassw...@http://servername.com/script

work?

Is this a SOAP based web service?

Are they expecting the SOAPHeader to contain the authentication?




-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Richard Quadling [mailto:rquadl...@gmail.com]
> Sent: Friday, October 15, 2010 1:47 AM
> To: Brian Dunning
> Cc: PHP-General List
> Subject: Re: [PHP] Help with sending credentials?
> 
> On 14 October 2010 21:45, Brian Dunning <br...@briandunning.com> wrote:
> > Gents -
> >
> > I'm trying to work with a major vendor's web service, but all my efforts are
> met with a 401 authentication error response. I can log in manually to this
> URL using these credentials through a browser, so I know the credentials are
> good. Unfortunately the support guys at the vendor don't see any problem
> with my code and have not been able to help.
> >
> > $url = "https://servername.com/script";; $ctx =
> > stream_context_create(array('https' => array(
> >        'timeout' => 10,
> >        'header'  => sprintf("Authorization: Basic %s\r\n",
> > base64_encode("myUsername:myPassword"))
> >        )));
> > $result = file_get_contents($url, 0, $ctx); $http_response = explode('
> > ', $http_response_header[0]); $response_code = $http_response[1];
> > <<<=== This is evaluating to '401'
> >
> >
> > Thanks.
> 
> Are they using Basic authentication?
> 
> Does ...
> 
> https://myUsername:mypassw...@http://servername.com/script

Shouldn't that be https://myUsername:mypassw...@servername.com/script ?

> 
> work?
> 
> Is this a SOAP based web service?
> 
> Are they expecting the SOAPHeader to contain the authentication?
> 
> 
> 
> 
> --
> Richard Quadling
> Twitter : EE : Zend
> @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
> 

Regards,
Tommy


--- End Message ---
--- Begin Message ---
On 15 October 2010 10:51, Tommy Pham <tommy...@gmail.com> wrote:
>> -----Original Message-----
>> From: Richard Quadling [mailto:rquadl...@gmail.com]
>> Sent: Friday, October 15, 2010 1:47 AM
>> To: Brian Dunning
>> Cc: PHP-General List
>> Subject: Re: [PHP] Help with sending credentials?
>>
>> On 14 October 2010 21:45, Brian Dunning <br...@briandunning.com> wrote:
>> > Gents -
>> >
>> > I'm trying to work with a major vendor's web service, but all my efforts 
>> > are
>> met with a 401 authentication error response. I can log in manually to this
>> URL using these credentials through a browser, so I know the credentials are
>> good. Unfortunately the support guys at the vendor don't see any problem
>> with my code and have not been able to help.
>> >
>> > $url = "https://servername.com/script";; $ctx =
>> > stream_context_create(array('https' => array(
>> >        'timeout' => 10,
>> >        'header'  => sprintf("Authorization: Basic %s\r\n",
>> > base64_encode("myUsername:myPassword"))
>> >        )));
>> > $result = file_get_contents($url, 0, $ctx); $http_response = explode('
>> > ', $http_response_header[0]); $response_code = $http_response[1];
>> > <<<=== This is evaluating to '401'
>> >
>> >
>> > Thanks.
>>
>> Are they using Basic authentication?
>>
>> Does ...
>>
>> https://myUsername:mypassw...@http://servername.com/script
>
> Shouldn't that be https://myUsername:mypassw...@servername.com/script ?
>
>>
>> work?
>>
>> Is this a SOAP based web service?
>>
>> Are they expecting the SOAPHeader to contain the authentication?
>>
>>
>>
>>
>> --
>> Richard Quadling
>> Twitter : EE : Zend
>> @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
>>
>
> Regards,
> Tommy
>
>

Yeah. CNP error. Thanks.



-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Andre Polykanine [mailto:an...@oire.org]
> Sent: 14 October 2010 21:42
> 
> Hi everyone,
> I hope you're doing well (haven't written here for a long time :-)).
> The question is as follows: I have a regexp that would do the
> following. If the string begins with "Re:", it will change the
> beginning to "Re[2]:"; if it doesn't, then it would add "Re:" at the
> beginning. But (attention, here it is!) if the string starts with
> something like "Re[4]:", it should replace it by "Re[5]:".
> Here's the code:
> 
> $start=mb_strtolower(mb_substr($f['Subject'], 0, 3));
> if ($start=="re:") {
> $subject=preg_replace("/^re:(.+?)$/usi", "re[2]:$1", $f['Subject']);
> } elseif ($start=="re[") {
> // Here $1+1 doesn't work, it returns "Re[4+1]:"!
> $subject=preg_replace("/^re\[(\d+)\]:(.+?)$/usi", "re[$1+1]:$2",
> $f['Subject']);
> } else {
> $subject="Re: ".$f['Subject'];
> }
> 
> I know there actually exists a way to do the numeral addition
> ("Re[5]:", not "Re[4+1]:").
> How do I manage to do this?

This looks like a job for the "e" modifier (see 
http://php.net/manual/en/reference.pcre.pattern.modifiers.php, and example #4 
at http://php.net/preg_replace). Something like:

  $subject = preg_replace("/^re\[(\d+)\:](.+?)$/eusi", "'re['.(\\1+1).']:\\2'", 
$f['Subject']);

Cheers!

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





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--- End Message ---
--- Begin Message ---
On 15 October 2010 10:16, Ford, Mike <m.f...@leedsmet.ac.uk> wrote:
>> -----Original Message-----
>> From: Andre Polykanine [mailto:an...@oire.org]
>> Sent: 14 October 2010 21:42
>>
>> Hi everyone,
>> I hope you're doing well (haven't written here for a long time :-)).
>> The question is as follows: I have a regexp that would do the
>> following. If the string begins with "Re:", it will change the
>> beginning to "Re[2]:"; if it doesn't, then it would add "Re:" at the
>> beginning. But (attention, here it is!) if the string starts with
>> something like "Re[4]:", it should replace it by "Re[5]:".
>> Here's the code:
>>
>> $start=mb_strtolower(mb_substr($f['Subject'], 0, 3));
>> if ($start=="re:") {
>> $subject=preg_replace("/^re:(.+?)$/usi", "re[2]:$1", $f['Subject']);
>> } elseif ($start=="re[") {
>> // Here $1+1 doesn't work, it returns "Re[4+1]:"!
>> $subject=preg_replace("/^re\[(\d+)\]:(.+?)$/usi", "re[$1+1]:$2",
>> $f['Subject']);
>> } else {
>> $subject="Re: ".$f['Subject'];
>> }
>>
>> I know there actually exists a way to do the numeral addition
>> ("Re[5]:", not "Re[4+1]:").
>> How do I manage to do this?
>
> This looks like a job for the "e" modifier (see 
> http://php.net/manual/en/reference.pcre.pattern.modifiers.php, and example #4 
> at http://php.net/preg_replace). Something like:
>
>  $subject = preg_replace("/^re\[(\d+)\:](.+?)$/eusi", 
> "'re['.(\\1+1).']:\\2'", $f['Subject']);
>
> Cheers!
>
> Mike

Watch out for the missing '[1]'. This needs to become '[2]' and not '[1]'.

The callback seems to be the only way I could get the regex to work.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--- End Message ---
--- Begin Message ---
On Fri, Oct 15, 2010 at 5:52 AM, Richard Quadling <rquadl...@gmail.com> wrote:
> On 15 October 2010 10:16, Ford, Mike <m.f...@leedsmet.ac.uk> wrote:
>>> -----Original Message-----
>>> From: Andre Polykanine [mailto:an...@oire.org]
>>> Sent: 14 October 2010 21:42
>>>
>>> Hi everyone,
>>> I hope you're doing well (haven't written here for a long time :-)).
>>> The question is as follows: I have a regexp that would do the
>>> following. If the string begins with "Re:", it will change the
>>> beginning to "Re[2]:"; if it doesn't, then it would add "Re:" at the
>>> beginning. But (attention, here it is!) if the string starts with
>>> something like "Re[4]:", it should replace it by "Re[5]:".
>>> Here's the code:
>>>
>>> $start=mb_strtolower(mb_substr($f['Subject'], 0, 3));
>>> if ($start=="re:") {
>>> $subject=preg_replace("/^re:(.+?)$/usi", "re[2]:$1", $f['Subject']);
>>> } elseif ($start=="re[") {
>>> // Here $1+1 doesn't work, it returns "Re[4+1]:"!
>>> $subject=preg_replace("/^re\[(\d+)\]:(.+?)$/usi", "re[$1+1]:$2",
>>> $f['Subject']);
>>> } else {
>>> $subject="Re: ".$f['Subject'];
>>> }
>>>
>>> I know there actually exists a way to do the numeral addition
>>> ("Re[5]:", not "Re[4+1]:").
>>> How do I manage to do this?
>>
>> This looks like a job for the "e" modifier (see 
>> http://php.net/manual/en/reference.pcre.pattern.modifiers.php, and example 
>> #4 at http://php.net/preg_replace). Something like:
>>
>>  $subject = preg_replace("/^re\[(\d+)\:](.+?)$/eusi", 
>> "'re['.(\\1+1).']:\\2'", $f['Subject']);
>>
>> Cheers!
>>
>> Mike
>
> Watch out for the missing '[1]'. This needs to become '[2]' and not '[1]'.
>
> The callback seems to be the only way I could get the regex to work.
>

How about preg_replace_callback()?

Andrew

--- End Message ---
--- Begin Message ---
On 15 October 2010 15:45, Andrew Ballard <aball...@gmail.com> wrote:
> On Fri, Oct 15, 2010 at 5:52 AM, Richard Quadling <rquadl...@gmail.com> wrote:
>> On 15 October 2010 10:16, Ford, Mike <m.f...@leedsmet.ac.uk> wrote:
>>>> -----Original Message-----
>>>> From: Andre Polykanine [mailto:an...@oire.org]
>>>> Sent: 14 October 2010 21:42
>>>>
>>>> Hi everyone,
>>>> I hope you're doing well (haven't written here for a long time :-)).
>>>> The question is as follows: I have a regexp that would do the
>>>> following. If the string begins with "Re:", it will change the
>>>> beginning to "Re[2]:"; if it doesn't, then it would add "Re:" at the
>>>> beginning. But (attention, here it is!) if the string starts with
>>>> something like "Re[4]:", it should replace it by "Re[5]:".
>>>> Here's the code:
>>>>
>>>> $start=mb_strtolower(mb_substr($f['Subject'], 0, 3));
>>>> if ($start=="re:") {
>>>> $subject=preg_replace("/^re:(.+?)$/usi", "re[2]:$1", $f['Subject']);
>>>> } elseif ($start=="re[") {
>>>> // Here $1+1 doesn't work, it returns "Re[4+1]:"!
>>>> $subject=preg_replace("/^re\[(\d+)\]:(.+?)$/usi", "re[$1+1]:$2",
>>>> $f['Subject']);
>>>> } else {
>>>> $subject="Re: ".$f['Subject'];
>>>> }
>>>>
>>>> I know there actually exists a way to do the numeral addition
>>>> ("Re[5]:", not "Re[4+1]:").
>>>> How do I manage to do this?
>>>
>>> This looks like a job for the "e" modifier (see 
>>> http://php.net/manual/en/reference.pcre.pattern.modifiers.php, and example 
>>> #4 at http://php.net/preg_replace). Something like:
>>>
>>>  $subject = preg_replace("/^re\[(\d+)\:](.+?)$/eusi", 
>>> "'re['.(\\1+1).']:\\2'", $f['Subject']);
>>>
>>> Cheers!
>>>
>>> Mike
>>
>> Watch out for the missing '[1]'. This needs to become '[2]' and not '[1]'.
>>
>> The callback seems to be the only way I could get the regex to work.
>>
>
> How about preg_replace_callback()?
>
> Andrew
>

Already provided an example using that : http://news.php.net/php.general/308728

It was the 'e' modifier I couldn't get to work, though I suppose, as
the code is eval'd, I should have been able to do it.

The callback just seems a LOT easier.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--- End Message ---
--- Begin Message ---
On Fri, Oct 15, 2010 at 11:07 AM, Richard Quadling <rquadl...@gmail.com> wrote:
> On 15 October 2010 15:45, Andrew Ballard <aball...@gmail.com> wrote:
>> On Fri, Oct 15, 2010 at 5:52 AM, Richard Quadling <rquadl...@gmail.com> 
>> wrote:
>>> On 15 October 2010 10:16, Ford, Mike <m.f...@leedsmet.ac.uk> wrote:
>>>>> -----Original Message-----
>>>>> From: Andre Polykanine [mailto:an...@oire.org]
>>>>> Sent: 14 October 2010 21:42
>>>>>
>>>>> Hi everyone,
>>>>> I hope you're doing well (haven't written here for a long time :-)).
>>>>> The question is as follows: I have a regexp that would do the
>>>>> following. If the string begins with "Re:", it will change the
>>>>> beginning to "Re[2]:"; if it doesn't, then it would add "Re:" at the
>>>>> beginning. But (attention, here it is!) if the string starts with
>>>>> something like "Re[4]:", it should replace it by "Re[5]:".
>>>>> Here's the code:
>>>>>
>>>>> $start=mb_strtolower(mb_substr($f['Subject'], 0, 3));
>>>>> if ($start=="re:") {
>>>>> $subject=preg_replace("/^re:(.+?)$/usi", "re[2]:$1", $f['Subject']);
>>>>> } elseif ($start=="re[") {
>>>>> // Here $1+1 doesn't work, it returns "Re[4+1]:"!
>>>>> $subject=preg_replace("/^re\[(\d+)\]:(.+?)$/usi", "re[$1+1]:$2",
>>>>> $f['Subject']);
>>>>> } else {
>>>>> $subject="Re: ".$f['Subject'];
>>>>> }
>>>>>
>>>>> I know there actually exists a way to do the numeral addition
>>>>> ("Re[5]:", not "Re[4+1]:").
>>>>> How do I manage to do this?
>>>>
>>>> This looks like a job for the "e" modifier (see 
>>>> http://php.net/manual/en/reference.pcre.pattern.modifiers.php, and example 
>>>> #4 at http://php.net/preg_replace). Something like:
>>>>
>>>>  $subject = preg_replace("/^re\[(\d+)\:](.+?)$/eusi", 
>>>> "'re['.(\\1+1).']:\\2'", $f['Subject']);
>>>>
>>>> Cheers!
>>>>
>>>> Mike
>>>
>>> Watch out for the missing '[1]'. This needs to become '[2]' and not '[1]'.
>>>
>>> The callback seems to be the only way I could get the regex to work.
>>>
>>
>> How about preg_replace_callback()?
>>
>> Andrew
>>
>
> Already provided an example using that : 
> http://news.php.net/php.general/308728
>
> It was the 'e' modifier I couldn't get to work, though I suppose, as
> the code is eval'd, I should have been able to do it.
>
> The callback just seems a LOT easier.
>

Sorry - I missed the callback function in there. The loop threw me off
because I thought that was part of the solution rather than a test
container.

Andrew

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Sharl.Jimh.Tsin [mailto:amoiz.sh...@gmail.com]
> Sent: Thursday, October 14, 2010 9:16 PM
> To: Bob McConnell
> Cc: ??; php-gene...@lists.php.net
> Subject: Re: [PHP] searching for application like Google Doc
> 
> Are you looking for a open-source project likes it?
> 
> searching it via Google with "php"、"office doc"、"open source" key words
> may help you.
> 
> Best regards,
> Sharl.Jimh.Tsin (From China)
> 
> 
> 
> 2010/10/14 Bob McConnell <r...@cbord.com>:
> > From: ??
> >
> >> Is there any application like Google Doc(here I mean the spreadsheet).
> >
> > What is your conception of "like"?
> >
> > Have you looked at OpenOffice?
> >
> > Bob McConnell
> >
> > --

I think he/she is asking if there is anything out there on net that is a 
spreadsheet and based purely html & javascript on the front end UI and the back 
end is either xml or db - similar to what google doc is.

Regards,
Tommy



--- End Message ---
--- Begin Message ---
Can anyone help me with this error message and explain how to correct the 
mismatch?

PHP Warning:  mysqli_connect() [<a 
href='function.mysqli-connect'>function.mysqli-connect</a>]: Headers and client 
library minor version mismatch. Headers:50051 Library:50151 

tholland

--- End Message ---

Reply via email to