php-general Digest 30 Jun 2010 23:42:11 -0000 Issue 6824

Topics (messages 306560 through 306581):

form validation code
        306560 by: David Mehler
        306562 by: Daniel P. Brown
        306564 by: Richard Quadling
        306565 by: Shreyas Agasthya
        306568 by: Richard Quadling

Re: Array form processing
        306561 by: Ford, Mike
        306567 by: tedd

Re: last modified on a page
        306563 by: tedd

Re: Login form + User level access
        306566 by: tedd

Regular Expression to get the whole Comma Separated String in Array Key
        306569 by: Gaurav Kumar
        306570 by: João Cândido de Souza Neto
        306571 by: Richard Quadling

Is this a bug with date() ?
        306572 by: Michael Alaimo
        306573 by: Michael Alaimo
        306575 by: Lester Caine
        306581 by: Hans Åhlin

Brandon Rampersad wants to chat
        306574 by: Brandon Rampersad

PHP Trick or Not - You Be the Judge
        306576 by: Brandon Rampersad
        306578 by: Jim Lucas
        306579 by: Robert Cummings
        306580 by: Michael Shadle

Re: Problem with SOAP and authentication? SoapFault exception: [HTTP] 
Unauthorized
        306577 by: robert mena

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Hello,
I've been looking at this to long, and am not seeing the issue. When i
had the below php code set to !empty instead of !isset as it is now I
got the value of the name variable echoed back, yet on sql insert that
field, along with all others are empty, though no error is generated,
just a bogus record is inserted.
When I changed to !isset I'm now getting the die statement echoed as
if no value was passed from the form. This is not the case, I filled
it out completely.
Can anyone tell me where this code went wrong?
Thanks.
Dave.

Html form:
<h3>Fields marked with a * (star) are required.</h3>
<form method="post" action="">
<div>
<label for="txtname">Name*:</label>
<input type="text" name="name" /> <br />
</div>

<div>
<input id="reset" name="reset" type="reset"/>
</div>
<div>
<input id="submit" name="submit" type="submit"/>
</div>
</form>
</div>

php Code:
// Check if fields are isset
echo "Field Checs.<br />";
if (!isset($_POST['name'])) {
echo "The value of Name is " . $_POST['name']. "<br />";
} else {
die('ERROR: Missing value - Event Name');
}

--- End Message ---
--- Begin Message ---
On Wed, Jun 30, 2010 at 09:07, David Mehler <[email protected]> wrote:
> Hello,
> I've been looking at this to long, and am not seeing the issue. When i
> had the below php code set to !empty instead of !isset as it is now I
> got the value of the name variable echoed back, yet on sql insert that
> field, along with all others are empty, though no error is generated,
> just a bogus record is inserted.
> When I changed to !isset I'm now getting the die statement echoed as
> if no value was passed from the form. This is not the case, I filled
> it out completely.
> Can anyone tell me where this code went wrong?

    Sure.

> php Code:
> // Check if fields are isset
> echo "Field Checs.<br />";
> if (!isset($_POST['name'])) {

    .... the line above.

    (Hint: isset != empty)



    (Another hint: with !empty(), you told PHP, "if it's not empty."
Now, with !isset(), you're saying, "if it's not set.")




    (Answer: Remove the exclamation point from !isset().)


-- 
</Daniel P. Brown>
UNADVERTISED DEDICATED SERVER SPECIALS
SAME-DAY SETUP
Just ask me what we're offering today!
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/

--- End Message ---
--- Begin Message ---
On 30 June 2010 14:23, Daniel P. Brown <[email protected]> wrote:
>    (Hint: isset != empty)

More importantly ...

isset != !empty

$a = Null;
$b = '';
// $c = undefined;
$d = 'Hello';

isset($a) = False vs True  = empty($a)
isset($b) = True  vs True  = empty($b)
isset($c) = False vs True  = empty($c)
isset($d) = True  vs False = empty($d)



-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
http://www.php.net/manual/en/types.comparisons.php

<http://www.php.net/manual/en/types.comparisons.php>The first table actually
gives a very good understanding.

--Shreyas

On Wed, Jun 30, 2010 at 7:05 PM, Richard Quadling <[email protected]>wrote:

> On 30 June 2010 14:23, Daniel P. Brown <[email protected]> wrote:
> >    (Hint: isset != empty)
>
> More importantly ...
>
> isset != !empty
>
> $a = Null;
> $b = '';
> // $c = undefined;
> $d = 'Hello';
>
> isset($a) = False vs True  = empty($a)
> isset($b) = True  vs True  = empty($b)
> isset($c) = False vs True  = empty($c)
> isset($d) = True  vs False = empty($d)
>
>
>
> --
> -----
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Regards,
Shreyas Agasthya

--- End Message ---
--- Begin Message ---
On 30 June 2010 14:53, Shreyas Agasthya <[email protected]> wrote:
> http://www.php.net/manual/en/types.comparisons.php
> The first table actually gives a very good understanding.
> --Shreyas
>
> On Wed, Jun 30, 2010 at 7:05 PM, Richard Quadling <[email protected]>
> wrote:
>>
>> On 30 June 2010 14:23, Daniel P. Brown <[email protected]> wrote:
>> >    (Hint: isset != empty)
>>
>> More importantly ...
>>
>> isset != !empty
>>
>> $a = Null;
>> $b = '';
>> // $c = undefined;
>> $d = 'Hello';
>>
>> isset($a) = False vs True  = empty($a)
>> isset($b) = True  vs True  = empty($b)
>> isset($c) = False vs True  = empty($c)
>> isset($d) = True  vs False = empty($d)
>>
>>
>>
>> --
>> -----
>> Richard Quadling
>> "Standing on the shoulders of some very clever giants!"
>> EE : http://www.experts-exchange.com/M_248814.html
>> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
>> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
>> ZOPA : http://uk.zopa.com/member/RQuadling
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>
>
> --
> Regards,
> Shreyas Agasthya
>

empty() === !boolean()

and

isset() === !is_null()



-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Ron Piggott [mailto:[email protected]]
> Sent: 29 June 2010 22:22
> 
> Am I on the right track?  I don't know what to do with the second
> "FOREACH"

Sort of.

> 
> <?php
> 
> foreach($_REQUEST as $key => $val) {
>      $$key = $val;
>        echo $key . ": " . $val . "<br>";
> 
>        if ( $val == "Array" ) {

I would prefer to use is_array() here:

        if (is_array($val))

>               $i=0;
> 

At this point, you've just proved that $val is an array (whichever test you 
use!), so simply foreach it like one. I know you know how to do that as you did 
it with $_REQUEST above!

>                       foreach ($val) {
>                               echo "$val[$i]<br>";
>                               $i++;
>                       }

                    foreach ($val as $option) {
                               echo "$option<br />\n";
                    }

> 
>        }
> }
> 
> ?>

Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, 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

--- End Message ---
--- Begin Message ---
At 4:54 PM -0400 6/29/10, Ron Piggott wrote:
I am trying to process a form where the user uses checkboxes:

<input type="checkbox" name="painDesc[]" value="1" />Sharp
<input type="checkbox" name="painDesc[]" value="2" />Stabbing
<input type="checkbox" name="painDesc[]" value="3" />Jabbing

When I do:

foreach($_REQUEST as $key => $val) {
     $$key = $val;
         echo $key . ": " . $val . "<br>";
}

The output is:

painDesc: Array

I need to know the values of the array (IE to know what the user is
checking), not that there is an array.  I hope to save these values to the
database.

Thank you.

Ron

Ron:

Try this:

http://php1.net/b/form-checkbox/

If you want the form to retain the values, try this:

http://php1.net/b/form-checkbox1/


Cheers,

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

--- End Message ---
--- Begin Message ---
At 4:41 PM -0400 6/29/10, Paul M Foster wrote:
On Tue, Jun 29, 2010 at 03:44:37PM -0400, tedd wrote:

 At 12:11 AM -0400 6/14/10, David Mehler wrote:
 Hello,
 I've got what is probably a simple question. I've got a site with a
 footer include file. I want to have a section that displays the last
 time the page was modified. So for example say the index.php was last
 modified today and another page  was modified two days ago. When the
 include is run on the other page it says something like this page was
 last modified and it would be two days ago, but for the index file I
 get this page was last modified and today's date.
 Thanks.
 Dave.

 Dave:

 A bit late but try this:

 <?php
 echo "Last modified: " . date ("F d Y H:i:s.", getlastmod());
 ?>

Wha--? I never heard of that function before (getlastmod)! Kewl.

Paul

Paul:

Our knowledge is a bit like Swiss cheese, some parts are there and some parts are missing. :-)

I have the distinct impression that my missing parts are getting larger.

Cheers,

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

--- End Message ---
--- Begin Message ---
At 8:07 PM +0000 6/29/10, Carlos Sura wrote:
Thank you for your answer Ted, You are right, well, I do have my login form, but what I do not understand is how to implement switch statement.

switch ($level){

case 0:

include ("admin.php");

break;

case 1:

include ("sales.php");

break;

case 2:

include ("superuser.php");

break;

}

Try:

case 0:
header('location:admin.php');
exit();
break;

Instead of includes.


Now I'm wondering if every page has to have something like:

if ($level==2){

} else {

}


Of course, you must check the level of permission granted to the user before allowing them to see any protected page.

I would suggest using a $_SESSION['level'] during logon to set the level of permission and then on each protected page do something like this:

$level = isset($_SESSION['level']) ? $_SESSION['level'] : null;

if($level < 2)
   {
   // redirect to somewhere else
  header('location:admin.php');
  exit();
   }

// this will allow the super-user (level 2) to see everything while redirecting everyone else elsewhere


Cheers,

tedd

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

--- End Message ---
--- Begin Message ---
Hi All,

Need help in resolving the below problem-


I would like to get the whole comma separated string into an array value-

1. $postText = "chapters 5, 6, 7, 8";
OR
2. $postText = "chapters 5, 6;
OR
3. $postText = "chapters 5, 6, 7";

What i have done so far is-
preg_match('/chapter[s]*[ ]*(\d+, \d+, \d+)/i', $postText, $matches);

The above will exactly match the third value $postText = "chapters 5, 6, 7";

By Above $matches will contain a value of : $matches[1] = '5, 6, 7';

Now i need a SINGLE regular expression which can match first, second
variable above or any number of comma separated string and IMPORTANTLY
provide me that whole comma separated sting value (as above) in single array
key element like below-

$matches[1] = '5, 6, 7';
OR
$matches[1] = '5, 6';
OR
$matches[1] = '5, 6, 7, 8, 9';


Also I have to use regular expression only as the flow of the code does not
permit to use any other method to get comma separated string from the
master/base string.

Thanks,

Gaurav Kumar

--- End Message ---
--- Begin Message ---
Not tested, but I think it should work:

preg_match_all('/(\d+),/', $postText, $matches);

-- 
João Cândido de Souza Neto

"Gaurav Kumar" <[email protected]> escreveu na mensagem 
news:[email protected]...
> Hi All,
>
> Need help in resolving the below problem-
>
>
> I would like to get the whole comma separated string into an array value-
>
> 1. $postText = "chapters 5, 6, 7, 8";
> OR
> 2. $postText = "chapters 5, 6;
> OR
> 3. $postText = "chapters 5, 6, 7";
>
> What i have done so far is-
> preg_match('/chapter[s]*[ ]*(\d+, \d+, \d+)/i', $postText, $matches);
>
> The above will exactly match the third value $postText = "chapters 5, 6, 
> 7";
>
> By Above $matches will contain a value of : $matches[1] = '5, 6, 7';
>
> Now i need a SINGLE regular expression which can match first, second
> variable above or any number of comma separated string and IMPORTANTLY
> provide me that whole comma separated sting value (as above) in single 
> array
> key element like below-
>
> $matches[1] = '5, 6, 7';
> OR
> $matches[1] = '5, 6';
> OR
> $matches[1] = '5, 6, 7, 8, 9';
>
>
> Also I have to use regular expression only as the flow of the code does 
> not
> permit to use any other method to get comma separated string from the
> master/base string.
>
> Thanks,
>
> Gaurav Kumar
> 



--- End Message ---
--- Begin Message ---
On 30 June 2010 15:12, Gaurav Kumar <[email protected]> wrote:
> Hi All,
>
> Need help in resolving the below problem-
>
>
> I would like to get the whole comma separated string into an array value-
>
> 1. $postText = "chapters 5, 6, 7, 8";
> OR
> 2. $postText = "chapters 5, 6;
> OR
> 3. $postText = "chapters 5, 6, 7";
>
> What i have done so far is-
> preg_match('/chapter[s]*[ ]*(\d+, \d+, \d+)/i', $postText, $matches);
>
> The above will exactly match the third value $postText = "chapters 5, 6, 7";
>
> By Above $matches will contain a value of : $matches[1] = '5, 6, 7';
>
> Now i need a SINGLE regular expression which can match first, second
> variable above or any number of comma separated string and IMPORTANTLY
> provide me that whole comma separated sting value (as above) in single array
> key element like below-
>
> $matches[1] = '5, 6, 7';
> OR
> $matches[1] = '5, 6';
> OR
> $matches[1] = '5, 6, 7, 8, 9';
>
>
> Also I have to use regular expression only as the flow of the code does not
> permit to use any other method to get comma separated string from the
> master/base string.
>
> Thanks,
>
> Gaurav Kumar
>

Try ...

preg_match('/chapters? ?((?:\d++(?:, )?)+)/im', $old_string, $a_Matches))


chapters? ?((?:\d++(?:, )?)+)

Match the characters “chapter” literally «chapter»
Match the character “s” literally «s?»
   Between zero and one times, as many times as possible, giving back
as needed (greedy) «?»
Match the character “ ” literally « ?»
   Between zero and one times, as many times as possible, giving back
as needed (greedy) «?»
Match the regular expression below and capture its match into
backreference number 1 «((?:\d++(?:, )?)+)»
   Match the regular expression below «(?:\d++(?:, )?)+»
      Between one and unlimited times, as many times as possible,
giving back as needed (greedy) «+»
      Match a single digit 0..9 «\d++»
         Between one and unlimited times, as many times as possible,
without giving back (possessive) «++»
      Match the regular expression below «(?:, )?»
         Between zero and one times, as many times as possible, giving
back as needed (greedy) «?»
         Match the characters “, ” literally «, »


Created with RegexBuddy
-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
I understand that technically there are more than 52 weeks in a year. 
Well at least google says 1 year = 52.177457 weeks.

So I run the command:
php > echo date('W' , mktime(0, 0, 0, 1, 1, date('Y')));
53

As you can see the result is 53.

Any thoughts on this?

Mike

--- End Message ---
--- Begin Message ---
I have found a bug report.  This is the correct functionality.

Mike

> I understand that technically there are more than 52 weeks in a year.
> Well at least google says 1 year = 52.177457 weeks.
>
> So I run the command:
> php > echo date('W' , mktime(0, 0, 0, 1, 1, date('Y')));
> 53
>
> As you can see the result is 53.
>
> Any thoughts on this?
>
> Mike
>


--- End Message ---
--- Begin Message ---
Michael Alaimo wrote:
I have found a bug report.  This is the correct functionality.

Mike

I understand that technically there are more than 52 weeks in a year.
Well at least google says 1 year = 52.177457 weeks.

So I run the command:
php>  echo date('W' , mktime(0, 0, 0, 1, 1, date('Y')));
53

As you can see the result is 53.

Any thoughts on this?

http://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/1016ca2b-7f43-2b10-8199-a78d1bcc49e9&overridelayout=true
Covers it nicely ...

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--- End Message ---
--- Begin Message ---
A year can have 52 or 53 weeks and it can begin with week nr 1, 52 or 53
check this algorithm
http://www.threesides.se/blogg/2010/04/15/date-calculation-algorithm/


**********************************************
 Hans Åhlin
   Tel: +46761488019
   icq: 275232967
   http://www.kronan-net.com/
   irc://irc.freenode.net:6667 - TheCoin
**********************************************



2010/6/30 Lester Caine <[email protected]>:
> Michael Alaimo wrote:
>>
>> I have found a bug report.  This is the correct functionality.
>>
>> Mike
>>
>>> I understand that technically there are more than 52 weeks in a year.
>>> Well at least google says 1 year = 52.177457 weeks.
>>>
>>> So I run the command:
>>> php>  echo date('W' , mktime(0, 0, 0, 1, 1, date('Y')));
>>> 53
>>>
>>> As you can see the result is 53.
>>>
>>> Any thoughts on this?
>
> http://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/1016ca2b-7f43-2b10-8199-a78d1bcc49e9&overridelayout=true
> Covers it nicely ...
>
> --
> Lester Caine - G8HFL
> -----------------------------
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk//
> Firebird - http://www.firebirdsql.org/index.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
-----------------------------------------------------------------------

Brandon Rampersad wants to stay in better touch using some of Google's
coolest new
products.

If you already have Gmail or Google Talk, visit:
http://mail.google.com/mail/b-b89a7a894d-806ae18504-KOgzrPXRyt_-nvSOA0A6kJ3ATvY
You'll need to click this link to be able to chat with Brandon Rampersad.

To get Gmail - a free email account from Google with over 2,800 megabytes of
storage - and chat with Brandon Rampersad, visit:
http://mail.google.com/mail/a-b89a7a894d-806ae18504-KOgzrPXRyt_-nvSOA0A6kJ3ATvY

Gmail offers:
- Instant messaging right inside Gmail
- Powerful spam protection
- Built-in search for finding your messages and a helpful way of organizing
  emails into "conversations"
- No pop-up ads or untargeted banners - just text ads and related information
  that are relevant to the content of your messages

All this, and its yours for free. But wait, there's more! By opening a Gmail
account, you also get access to Google Talk, Google's instant messaging
service:

http://www.google.com/talk/

Google Talk offers:
- Web-based chat that you can use anywhere, without a download
- A contact list that's synchronized with your Gmail account
- Free, high quality PC-to-PC voice calls when you download the Google Talk
  client

We're working hard to add new features and make improvements, so we might also
ask for your comments and suggestions periodically. We appreciate your help in
making our products even better!

Thanks,
The Google Team

To learn more about Gmail and Google Talk, visit:
http://mail.google.com/mail/help/about.html
http://www.google.com/talk/about.html

(If clicking the URLs in this message does not work, copy and paste them into
the address bar of your browser).

--- End Message ---
--- Begin Message ---
Hello guys, i was just doing some testing and was wondring if echo is faster
than print or print_r. I think since echo is a language construct and
print_r is a function, echo is faster.

Please let me know.

Thanks

-- 
A Brandon_R Production

--- End Message ---
--- Begin Message ---
Brandon Rampersad wrote:
> Hello guys, i was just doing some testing and was wondring if echo is faster
> than print or print_r. I think since echo is a language construct and
> print_r is a function, echo is faster.
> 
> Please let me know.
> 
> Thanks
> 

People in the past have said that echo and print as actually the same call
within PHP core system.  I have never dug through the core code that makes up
PHP so I cannot confirm this claim.

print_r on the other hand is a totally different thing.  It takes and processes
strings, arrays, objects, etc... So, with that said, it will be much slower.  It
has to detect what type of object it is and then deal with all the pieces.  And
then in the end, output everything to the screen.

-- 
Jim Lucas

A: Maybe because some people are too annoyed by top-posting.
Q: Why do I not get an answer to my question(s)?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

--- End Message ---
--- Begin Message --- Hey Brandon, do you think you could spend some time reading the Google talk manual? It's kind of irritating seeing your "Brandon Rampersad wants to chat" spam on the list repeatedly.

As for which is faster... your assertion is right.

Cheers,
Rob.



Brandon Rampersad wrote:
Hello guys, i was just doing some testing and was wondring if echo is faster
than print or print_r. I think since echo is a language construct and
print_r is a function, echo is faster.

Please let me know.

Thanks


--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--- End Message ---
--- Begin Message ---
biggest difference:

http://php.net/print
print() returns 1, always - which means it's returning a value

http://php.net/echo
doesn't return anything

Sara Golemon's "how long is a piece of string" blog post
(http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html
which appears to be down or something right now) I believe shows the
different opcodes (using VLD - http://pecl.php.net/package/vld)

This is a micro-level optimization. I believe echo is "faster" or
"less intensive" because it does not need to return a value, but on
modern CPUs saving a couple ops is probably not that big of a deal
(even thousands of them) - I think the general consensus is "there is
really no difference" last I saw. Only very very small optimizations.

On Wed, Jun 30, 2010 at 10:22 AM, Jim Lucas <[email protected]> wrote:
> Brandon Rampersad wrote:
>> Hello guys, i was just doing some testing and was wondring if echo is faster
>> than print or print_r. I think since echo is a language construct and
>> print_r is a function, echo is faster.
>>
>> Please let me know.
>>
>> Thanks
>>
>
> People in the past have said that echo and print as actually the same call
> within PHP core system.  I have never dug through the core code that makes up
> PHP so I cannot confirm this claim.
>
> print_r on the other hand is a totally different thing.  It takes and 
> processes
> strings, arrays, objects, etc... So, with that said, it will be much slower.  
> It
> has to detect what type of object it is and then deal with all the pieces.  
> And
> then in the end, output everything to the screen.
>
> --
> Jim Lucas
>
> A: Maybe because some people are too annoyed by top-posting.
> Q: Why do I not get an answer to my question(s)?
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Well,

I've captured using wireshark both communications:

The one that works

POST /XISOAPAdapter/MessageServlet?channel=:Y_BS_SIP_DEV:cc_soap_snd_sip_dev
HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "http://sap.com/xi/WebService/soap1.1";
User-Agent: Jakarta Commons-HttpClient/3.1
Host: X.Y.Z.W:50000
Content-Length: 535

Using cUrl I tried to mimic the behavior.  The content is the same (I've
even tried to reproduce some of the headers). but I get an error.

POST /XISOAPAdapter/MessageServlet?channel=:Y_BS_SIP_DEV:cc_soap_snd_sip_dev
HTTP/1.1
Authorization: Basic Ym9sOmJlbW9sMjAxMA==
Host: X.Y.Z.W:50000
Accept: */*
Content-Type: text/xml;charset=UTF-8
SOAPAction: "http://sap.com/xi/WebService/soap1.1";
User-Agent: Jakarta Commons-HttpClient/3.1
Content-Length: 535

Any ideas?

On Tue, Jun 29, 2010 at 6:45 PM, robert mena <[email protected]> wrote:

> Hi,
>
> I am using soapUI which is a client soap tester (that works with this
> webservice) to compare what is being generated.  In the header I see
> Authorization: Basic =XYS....
>
> So the default (using SoapClient) should also work...
>
> I've captured the tcpdump file and will try to load using wireshark.
>
>
> On Tue, Jun 29, 2010 at 5:18 PM, Richard Quadling <[email protected]>wrote:
>
>> On 29 June 2010 20:53, robert mena <[email protected]> wrote:
>> > Hi Richard,
>> > Thanks for taking the time.
>> >
>> > Unfortunately I can't give you access to the actual webservice.   I am
>> using
>> > Zend_Soap_Client so my code is like this
>> > $soapOptions = array(
>> >       "login"      => 'xxx',
>> >       "password"   => 'yyyyy');
>> > $client = new Zend_Soap_Client('http://myproviders.com/wsdl.xml',
>> > $soapOptions);
>> > $rc = $client->mi_request($var);
>> > I get
>> > PHP Fatal error:  Uncaught SoapFault exception: [HTTP] Unauthorized in
>> > /usr/local/zend/share/ZendFramework/library/Zend/Soap/Client.php:987
>> > Stack trace:
>> > #0 [internal function]: SoapClient->__doRequest('<?xml version="...',
>> > 'http://10.200....', 'http://sap.com/...', 2)
>> > #1
>> /usr/local/zend/share/ZendFramework/library/Zend/Soap/Client.php(987):
>> > call_user_func(Array, '<?xml version="...', 'http://10.200....',
>> > 'http://sap.com/...', 2)
>> > #2 [internal function]:
>> > Zend_Soap_Client->_doRequest(Object(Zend_Soap_Client_Common), '<?xml
>> > version="...', 'http://10.200....', 'http://sap.com/...', 2, 0)
>> > #3
>> >
>> /usr/local/zend/share/ZendFramework/library/Zend/Soap/Client/Common.php(70):
>> > call_user_func(Array, Object(Zend_Soap_Client_Common), '<?xml
>> version="...',
>> > 'http://10.200....', 'http://sap.com/...', 2, 0)
>> > #4 [internal function]: Zend_Soap_Client_Common->__doRequest('<?xml
>> > version="...', 'http://10.200....', 'http://sap.com/...', 2, 0)
>> > #5
>> /usr/local/zend/share/ZendFramework/library/Zend/Soap/Client.php(1113):
>> > SoapClient->__soapCall('mi_request_ in
>> > /usr/local/zend/share/ZendFramework/library/Zend/Soap/Client.php on line
>> 987
>> > Calling the SoapClient directly gives me the same result.
>> >
>> > On Tue, Jun 29, 2010 at 9:41 AM, Richard Quadling <[email protected]>
>> > wrote:
>> >>
>> >> On 29 June 2010 13:58, robert mena <[email protected]> wrote:
>> >> > I was hoping for a "userland" soap library (like nuSoap if I
>> understand
>> >> > correctly).   I can't change the fact that the remote webservice
>> >> > requires
>> >> > http auth.
>> >> > Hopefully someone in this list uses either zend_soap or soapClient
>> >> > directly
>> >> > with auth to confirm or deny that the problem is in this part
>> >> > specifically.
>> >> >
>> >> > On Tue, Jun 29, 2010 at 7:23 AM, Richard Quadling <
>> [email protected]>
>> >> > wrote:
>> >> >>
>> >> >> On 28 June 2010 22:37, robert mena <[email protected]> wrote:
>> >> >> > Hi,
>> >> >> > I'll have a look.  I am using Zend Framework's Zend_Soap_Client
>> which
>> >> >> > in
>> >> >> > turn uses SoapClient.  I'll try to use SoapClient directly.
>> >> >> > I am not using https and I am not going through a proxy (using a
>> non
>> >> >> > standard port).  I've tested with another SOAP client (a
>> standalone
>> >> >> > application called SoapUI) without a problem.
>> >> >> >
>> >> >> > Is there anyone using SoapClient (or Zend_Soap_Client) with auth
>> with
>> >> >> > success?   What other library (that does not use SoapClient) could
>> I
>> >> >> > try?
>> >> >> > On Mon, Jun 28, 2010 at 6:27 AM, Richard Quadling
>> >> >> > <[email protected]>
>> >> >> > wrote:
>> >> >> >>
>> >> >> >> On 26 June 2010 23:46, robert mena <[email protected]>
>> wrote:
>> >> >> >> > Hi,
>> >> >> >> >
>> >> >> >> > I am trying to access a webservice using php's soapclient but I
>> >> >> >> > keep
>> >> >> >> > getting
>> >> >> >> > the error SoapFault exception: [HTTP] Unauthorized
>> >> >> >> >
>> >> >> >> > If I try using a web browser I can authenticate using the same
>> >> >> >> > credentials
>> >> >> >> > used by the php code.
>> >> >> >> >
>> >> >> >> > I've searched but the only mention that I found led to a 'won't
>> >> >> >> > fix'
>> >> >> >> > bug
>> >> >> >> > registered to php 5.1.6.  I am using 5.2.10.
>> >> >> >> >
>> >> >> >> > Any ideas of what may be causing this?  Is there a workaround?
>> >> >> >> >
>> >> >> >> > Regards.
>> >> >> >> >
>> >> >> >>
>> >> >> >> Can you show the SoapClient construction you are using?
>> >> >> >>
>> >> >> >> The documentation says that you can supply HTTP authentication
>> [1]
>> >> >> >> ...
>> >> >> >>
>> >> >> >> "For HTTP authentication, the login and password options can be
>> used
>> >> >> >> to supply credentials. For making an HTTP connection through a
>> proxy
>> >> >> >> server, the options proxy_host, proxy_port, proxy_login and
>> >> >> >> proxy_password are also available. For HTTPS client certificate
>> >> >> >> authentication use local_cert and passphrase options. An
>> >> >> >> authentication may be supplied in the authentication option. The
>> >> >> >> authentication method may be either SOAP_AUTHENTICATION_BASIC
>> >> >> >> (default) or SOAP_AUTHENTICATION_DIGEST."
>> >> >> >>
>> >> >> >> There was recent activity on a Soap Authorisation Header bug [2].
>> >> >> >>
>> >> >> >> If this issue is appropriate, you can try a building your code
>> code
>> >> >> >> from SVN (no win32 snapshots for a LONG time now).
>> >> >> >>
>> >> >> >> Regards,
>> >> >> >>
>> >> >> >> Richard.
>> >> >> >>
>> >> >> >> [1] http://docs.php.net/manual/en/soapclient.soapclient.php
>> >> >> >> [2] http://bugs.php.net/bug.php?id=50976
>> >> >> >> --
>> >> >> >> -----
>> >> >> >> Richard Quadling
>> >> >> >> "Standing on the shoulders of some very clever giants!"
>> >> >> >> EE : http://www.experts-exchange.com/M_248814.html
>> >> >> >> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
>> >> >> >> Zend Certified Engineer :
>> >> >> >> http://zend.com/zce.php?c=ZEND002498&r=213474731
>> >> >> >> ZOPA : http://uk.zopa.com/member/RQuadling
>> >> >> >
>> >> >> >
>> >> >>
>> >> >> You can, of course, do it all yourself with cURL or sockets, but I
>> >> >> believe the overhead would be significant.
>> >> >>
>> >> >> I think in the first instance, can we see the code you are using to
>> >> >> make the request?
>> >> >>
>> >> >> I use the Zend_Soap_[Client|Server|WSDL|AutoDiscovery] but not with
>> >> >> external Auth (like you are wanting). Instead, one of my services is
>> >> >> the auth service (username is sent plain text and password is sent
>> MD5
>> >> >> with a nonce - I believe the principle is sound. I chose this as I
>> was
>> >> >> being REALLY lazy in not learning about how to do Auth any other
>> way.
>> >> >>
>> >> >> Richard.
>> >> >>
>> >> >>
>> >> >> --
>> >> >> -----
>> >> >> Richard Quadling
>> >> >> "Standing on the shoulders of some very clever giants!"
>> >> >> EE : http://www.experts-exchange.com/M_248814.html
>> >> >> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
>> >> >> Zend Certified Engineer :
>> >> >> http://zend.com/zce.php?c=ZEND002498&r=213474731
>> >> >> ZOPA : http://uk.zopa.com/member/RQuadling
>> >> >
>> >> >
>> >>
>> >> Can you provide a link to the service? I'm willing to help you through
>> >> this, but you have to give us something to work with.
>> >>
>> >> I do see that you've asked several questions here and not had the
>> >> greatest of responses.
>> >>
>> >> Often that means no-one knows an answer.
>> >>
>> >> So, when someone DOES pay interest ...
>> >>
>> >> Regards,
>> >>
>> >> Richard.
>> >> --
>> >> -----
>> >> Richard Quadling
>> >> "Standing on the shoulders of some very clever giants!"
>> >> EE : http://www.experts-exchange.com/M_248814.html
>> >> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
>> >> Zend Certified Engineer :
>> http://zend.com/zce.php?c=ZEND002498&r=213474731
>> >> ZOPA : http://uk.zopa.com/member/RQuadling
>> >
>> >
>>
>> What type of HTTP authentication is the server using? Basic or Digest?
>>
>> PHP's SoapClient supports the setting of an authentication option [1].
>>
>> "An authentication may be supplied in the authentication option. The
>> authentication method may be either SOAP_AUTHENTICATION_BASIC
>> (default) or SOAP_AUTHENTICATION_DIGEST."
>>
>> But the Zend_Soap_Client code does not support this option. You'd have
>> to add it. Pretty simple to do.
>>
>> But that is only if PHP actually supports the digest mechanism.
>>
>> Can you adapt your code to test the use of PHP's SoapClient with a
>> third option of ...
>>
>> 'authentication' => SOAP_AUTHENTICATION_DIGEST,
>>
>> If that works, then I can help you get the Zend_Soap_Client working
>> with it and send the patches to Zend.
>>
>> Richard.
>>
>>
>> [1] http://docs.php.net/manual/en/soapclient.soapclient.php
>>
>> --
>> -----
>> Richard Quadling
>> "Standing on the shoulders of some very clever giants!"
>> EE : http://www.experts-exchange.com/M_248814.html
>> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
>> Zend Certified Engineer :
>> http://zend.com/zce.php?c=ZEND002498&r=213474731
>> ZOPA : http://uk.zopa.com/member/RQuadling
>>
>
>

--- End Message ---

Reply via email to