php-general Digest 19 Apr 2009 14:43:52 -0000 Issue 6075

2009-04-19 Thread php-general-digest-help

php-general Digest 19 Apr 2009 14:43:52 - Issue 6075

Topics (messages 291661 through 291665):

Re: What is wrong with this code
291661 by: 9el
291662 by: Reese
291663 by: Manuel Lemos

Soap Client Help
291664 by: EPA WC

niewbie - call methods from another class
291665 by: MEM

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


--
---BeginMessage---
But in practice. I mean in real life you'll find the mail() function is
disabled in most servers :)
---End Message---
---BeginMessage---

9el wrote:

But in practice. I mean in real life you'll find the mail() function is
disabled in most servers :)


That's nice, but how many is larger volumes of email? 500? 5,000?
25,000?

I note PEAR:Mail has 3 open bugs, PEAR:Mail_Mime has 23 with 3 open
support requests. PHPMailer was mentioned earlier, it has 31 open
bugs (and someone noted that at least one was closed as resolved
even though it wasn't actually fixed).

So how many addresses can mail() safely handle?

Reese


---End Message---
---BeginMessage---
Hello,

9el wrote:
 *Note:* It is worth noting that the mail() function is not suitable for
 larger volumes of email in a loop. This function opens and closes an SMTP
 socket for each email, which is not very efficient.
 For the sending of large amounts of email, see the » PEAR::Mail, and »
 PEAR::Mail_Queue packages.
 *
 Note:* The following RFCs may be useful: » RFC 1896, » RFC 2045, » RFC 2046,
 » RFC 2047, » RFC 2048, » RFC 2049, and » RFC 2822.
 
 Copy from PHP Manual.

The PHP manual is wrong. Using the mail function does not necessarily
make it open and close SMTP connections for every recipient. That is
true with PHP under Windows.

When you use sendmail or equivalent (Postfix, Qmail, etc..) on Linux
usually the message is just dropped in the queue and the mail server
takes it from there. PHP does not necessarily have to wait for the
message be delivered to the remote recipient via SMTP.

You may want to read a more complete explanation here:

http://www.phpclasses.org/blog/package/14/post/1-Sending-messages-to-many-recipients-via-SMTP-in-PHP.html


-- 

Regards,
Manuel Lemos

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

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

---End Message---
---BeginMessage---
Hi All,

I am using the following code to build a SoapClient with some web service:


?php

ini_set(soap.wsdl_cache_enabled, 0);
ini_set('default_socket_timeout', 600);
$client = new 
SoapClient(http://iaspub.epa.gov/webservices/StationService/index.html?WSDL,array('trace'
= 1));
try {
 $sc = $client-getStationCount(43.1,43.5,-83.5,-83.1);
 print $sc;
} catch (SoapFault $exception) {
   echo $exception;
}

?
//

But I got the following error:
///
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing
WSDL: Unspecified encodingStyle in /var/www/myphp/wqxststest.php:5
Stack trace: #0 /var/www/myphp/wqxststest.php(5):
SoapClient-SoapClient('http://iaspub.e...', Array) #1 {main} thrown
in /var/www/myphp/wqxststest.php on line 5
///

Also when I tried same code (See below) with another service, it seems
working fine.
///
?php
$huc = $_REQUEST['huc'];
ini_set(soap.wsdl_cache_enabled, 0);
ini_set('default_socket_timeout', 600);
$client = new 
SoapClient(http://iaspub.epa.gov/webservices/WatershedSummaryService/index.html?WSDL,array('trace'
= 1));
try {
 $client-getCharacteristicSummary($huc);
 print $client-__getLastResponse();
} catch (SoapFault $exception) {
   echo $exception;
}
///
?

I tried to find what's causing this error on Google but no success.
Anyone know what's going on?

Your help is highly appreciated!

Tom
---End Message---
---BeginMessage---
Hello, I have something like this:
 
$stmt = $this-_dbh-prepare(INSERT INTO DOG (name_dog, race_dog, id_vet)
VALUES (?, ?, ?));
 
 $stmt-bindParam(1, $this-getNameDog() );
 $stmt-bindParam(2, $this-getRaceDog());
 $stmt-bindParam(3, );
 
  
 $stmt-execute();
   }
 
To make this insert function work, I need to fill the id_vet database column
with some values. 
I cannot use $this-getIdVet() because this method is not in dog class, is
on the veterinary class. 
So my question is:
How can I access the getIdVet() that is on the veterinary class to put it on
the insert dog method? 
 
 
Thanks a lot,
Márcio
 
---End Message---


[PHP] niewbie - call methods from another class

2009-04-19 Thread MEM
Hello, I have something like this:
 
$stmt = $this-_dbh-prepare(INSERT INTO DOG (name_dog, race_dog, id_vet)
VALUES (?, ?, ?));
 
 $stmt-bindParam(1, $this-getNameDog() );
 $stmt-bindParam(2, $this-getRaceDog());
 $stmt-bindParam(3, );
 
  
 $stmt-execute();
   }
 
To make this insert function work, I need to fill the id_vet database column
with some values. 
I cannot use $this-getIdVet() because this method is not in dog class, is
on the veterinary class. 
So my question is:
How can I access the getIdVet() that is on the veterinary class to put it on
the insert dog method? 
 
 
Thanks a lot,
Márcio
 


[PHP] self in inherited methods

2009-04-19 Thread Alex S Kurilo aka Kamazee

Is it right that 'self' in inherited method still points to the parent?
If it is, can you explain it? It makes me worry :)

A piece of code below for example

?php
class MyParent {
   const NAME = 'MyParent';
   public function get_instance() {
   return new self;
   }
   public function get_another_instance() {
   $class_name = get_class($this);
   return new $class_name;
   }
   public function get_name() {
   return self::NAME;
   }
}

class MyClass extends MyParent {
   const NAME = 'MyClass';
}

$a = new MyClass;
$b = $a-get_instance();
$c = $a-get_another_instance();

echo $a-get_name(),\n;
echo get_class($b),\n;
echo get_class($c),\n;
?



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



[PHP] How do I access a local variable?

2009-04-19 Thread abdulazeez alugo

Hi guys,

I have a function inside which I set alocal variable to store a result. Can I 
access this variable in another function? if yes then how?

function tbl1($entrytitle, $entrytext)

{

global $conn;

$result= mysql_query(INSERT INTO tbl1(tbl1_id, title, text)

 VALUES('NULL', '$entrytitle', '$entrytext'), $conn);

 $tbl_id=mysql_insert_id($conn);// this is the local variable I'm setting 
to get the last auto increment id

} 

 

Now I wish to access that variable in another function thus:

function tbl2($name, $entrytitle, $entrytext)

{

global $conn;

$result =mysql_query(INSERT INTO tbl2(tbl1_id, name, title, text)

   VALUES('$tbl1_id', '$name', '$entrytitle', 
'$entrytext' ), $Conn); 

}

 

Or is there a better way to store the variable?

Thanks in advance.

 

Alugo Abdulazeez

www.frangeovic.com

_
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/

Re: [PHP] How do I access a local variable?

2009-04-19 Thread Chris

abdulazeez alugo wrote:

Hi guys,

I have a function inside which I set alocal variable to store a result. Can I 
access this variable in another function? if yes then how?


No, you can't. You either need to pass it back (recommended) or make it 
global (not recommended).



function tbl1($entrytitle, $entrytext)

{

global $conn;

$result= mysql_query(INSERT INTO tbl1(tbl1_id, title, text)

 VALUES('NULL', '$entrytitle', '$entrytext'), $conn);

 $tbl_id=mysql_insert_id($conn);// this is the local variable I'm setting 
to get the last auto increment id


return $tbl_id;

} 

 


Now I wish to access that variable in another function thus:

function tbl2($name, $entrytitle, $entrytext)

{


  $other_id = tbl1($entrytitle, $entrytext);
  echo $other_id;


global $conn;

$result =mysql_query(INSERT INTO tbl2(tbl1_id, name, title, text)

   VALUES('$tbl1_id', '$name', '$entrytitle', '$entrytext' ), $Conn); 


}


PS : look up mysql_real_escape_string for when you save your data.

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


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



Re: [PHP] How do I access a local variable?

2009-04-19 Thread Paul M Foster
On Mon, Apr 20, 2009 at 12:54:27AM +0100, abdulazeez alugo wrote:

 
 Hi guys,
 
 I have a function inside which I set alocal variable to store a result. Can I 
 access this variable in another function? if yes then how?
 
 function tbl1($entrytitle, $entrytext)
 
 {
 
 global $conn;
 
 $result= mysql_query(INSERT INTO tbl1(tbl1_id, title, text)
 
  VALUES('NULL', '$entrytitle', '$entrytext'), $conn);
 
  $tbl_id=mysql_insert_id($conn);// this is the local variable I'm setting 
 to get the last auto increment id
 
 } 
 
  
 
 Now I wish to access that variable in another function thus:
 
 function tbl2($name, $entrytitle, $entrytext)
 
 {
 
 global $conn;
 
 $result =mysql_query(INSERT INTO tbl2(tbl1_id, name, title, text)
 
VALUES('$tbl1_id', '$name', '$entrytitle', 
 '$entrytext' ), $Conn); 
 
 }
 
  
 
 Or is there a better way to store the variable?

If a variable is local to a function, there is no way to access that
variable outside that function. You can pass it back as a return value
from the original function, or make it global (not advised) to make it
visible in other functions.

Paul

-- 
Paul M. Foster

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



[PHP] DATE / strtotime

2009-04-19 Thread Ron Piggott
Where $date_reference is 2009-04-18 the following code gives me a day of
1969-12-30. How do I get it to be 2009-04-17? 

$previous_date = strtotime(-1 days, $date_reference); 
$previous_date = date('Y-m-d', $previous_date);

echo $previous_date;   outputs 1969-12-30

Ron



Re: [PHP] DATE / strtotime

2009-04-19 Thread Chris

Ron Piggott wrote:

Where $date_reference is 2009-04-18 the following code gives me a day of
1969-12-30. How do I get it to be 2009-04-17? 

$previous_date = strtotime(-1 days, $date_reference); 
$previous_date = date('Y-m-d', $previous_date);


Slightly wrong syntax.

$previous_date = strtotime($date_reference -1 days);

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


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



Re: [PHP] DATE / strtotime

2009-04-19 Thread Jim Lucas

Ron Piggott wrote:

Where $date_reference is 2009-04-18 the following code gives me a day of
1969-12-30. How do I get it to be 2009-04-17? 

$previous_date = strtotime(-1 days, $date_reference); 
$previous_date = date('Y-m-d', $previous_date);


echo $previous_date;   outputs 1969-12-30

Ron




You need to read the strtotime page in the manual.

http://php.net/strtotime

It says that the second argument of the strtotime function is suppose to be a 
unix time stamp.

Is the value that you gave us for $date_reference a unix time stamp?  No

Your code should be like this.

// This converts 2009-04-19 00:00:00 into 1240099200
$date_reference_unix = strtotime($date_reference);
$previous_date = strtotime(-1 days, $date_reference_unix);
$previous_date = date('Y-m-d', $previous_date);

echo $previous_date;   outputs 1969-12-30


--
Jim Lucas

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

Twelfth Night, Act II, Scene V
by William Shakespeare

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



RE: [PHP] pup

2009-04-19 Thread ramesh.marimuthu

Thanks for your idea.

-Original Message-
From: Phpster [mailto:phps...@gmail.com]
Sent: Friday, April 17, 2009 5:39 PM
To: Ramesh Marimuthu (WT01 - Telecom Equipment)
Cc: li...@cmsws.com; geek...@gmail.com; php-general@lists.php.net
Subject: Re: [PHP] pup



On Apr 17, 2009, at 1:06, ramesh.marimu...@wipro.com wrote:


 Thanks Jim. Is there a way to get the value of that unchecked box?

 -rummy

 -Original Message-
 From: Jim Lucas [mailto:li...@cmsws.com]
 Sent: Friday, April 17, 2009 10:35 AM
 To: Ramesh Marimuthu (WT01 - Telecom Equipment)
 Cc: geek...@gmail.com; php-general@lists.php.net
 Subject: Re: [PHP] pup

 ramesh.marimu...@wipro.com wrote:

 Hi,

 I'm new to php.
 Say I have a check box which is checked already. Now I need to
 uncheck

 it and when I press the submit button, I should get the unchecked
 value.
 Can anyone help me on this.

 One.php

 if($qry[0]!=$login_type)
 {
 echo td class=tabhead align=center
 style=background-color:#CC66CCinput type=checkbox name=disable
 value=a.$count. checked DISABLED //br.$slot_value./td; }
 else { echo td class=tabhead align=center
 style=background-color:#00input type=checkbox name=enable[]
 value='--user .$slot_value. --ne .$nen. --timespec .$slt.'
 checked
 /br.$slot_value./td;
 }

 One.php calls Two.php
 Two.php

 $enable_slot= $_POST['enable'];
 $uncheck_slot= $_POST['uncheck'];

 if ($enable_slot){
 echo $enable_slot;
 foreach($enable_slot as $a) {
 echo p.$a. --unreserve/p;
 }
 }

 I get only the results only if checked. I think I'm doing a mistake
 in

 the code in red font.

 regards,
 -rummy



 When you uncheck a checkbox in an HTML form, it will not be submitted.

 http://www.w3.org/TR/html401/interact/forms.html#checkbox

 The part on the above page talking about only on checkbox controls
 can become successful. is the key here.

 The successful part links here:

 http://www.w3.org/TR/html401/interact/forms.html#successful-controls

 This explains that the definition of a successful checkbox submission
 is one that is  on.
 To have a checkbox in the on state means that it has to be checked.

 So, any checkbox that is /not/ checked is considered off or
 undefined will not be submitted because it is not valid.

 Or something like that... :)

 Jim Lucas

 Please do not print this email unless it is absolutely necessary.

 The information contained in this electronic message and any
 attachments to this message are intended for the exclusive use of the
 addressee(s) and may contain proprietary, confidential or privileged
 information. If you are not the intended recipient, you should not
 disseminate, distribute or copy this e-mail. Please notify the sender
 immediately and destroy all copies of this message and any
 attachments.

 WARNING: Computer viruses can be transmitted via email. The recipient
 should check this email and any attachments for the presence of
 viruses. The company accepts no liability for any damage caused by any

 virus transmitted by this email.

 www.wipro.com

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



What I do in this case is define it to unchecked in the php code and
then use the ternary operator to test it


$checkbox1 = 0;

$checkbox1 = (isset($_POST['check1'])) ? 1: 0 ;

Bastien

Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.

www.wipro.com

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



Re: [PHP] DATE / strtotime

2009-04-19 Thread Ron Piggott

Thanks Chris.  It has been a while since I used this command.  Ron


On Mon, 2009-04-20 at 13:27 +1000, Chris wrote:

 Ron Piggott wrote:
  Where $date_reference is 2009-04-18 the following code gives me a day of
  1969-12-30. How do I get it to be 2009-04-17? 
  
  $previous_date = strtotime(-1 days, $date_reference); 
  $previous_date = date('Y-m-d', $previous_date);
 
 Slightly wrong syntax.
 
 $previous_date = strtotime($date_reference -1 days);
 


Re: [PHP] pup

2009-04-19 Thread Jim Lucas

Ashley Sheridan wrote:

On Fri, 2009-04-17 at 12:54 -0400, Bob McConnell wrote:

From: tedd

At 10:43 PM -0700 4/16/09, Jim Lucas wrote:

Have your elements setup like such:

input type=checkbox name=reserve[rm1] value=yes / Room #1
input type=checkbox name=reserve[rm2] value=yes / Room #2
input type=checkbox name=reserve[rm3] value=yes / Room #3
input type=checkbox name=reserve[rm4] value=yes / Room #4
input type=checkbox name=reserve[rm5] value=yes / Room #5

Then on your processing page, you know that you have 5 rooms, 1 - 5.

With this information you can check to make sure that something

exists

?php
$rooms = range(1,5);
for ( $i = 1; $i = 5; $i++ ) {
if ( isset( $_POST['reserve']['rm'.$i] ) {
# Room was checked
} else {
# Room was NOT checked.
}
}
?

Jim et al:

Try this:

input type=checkbox name=reserve[1]  Room #1
input type=checkbox name=reserve[2]  Room #2
input type=checkbox name=reserve[3]  Room #3
input type=checkbox name=reserve[4]  Room #4
input type=checkbox name=reserve[5]  Room #5


if (isset($_POST['reserve']) )
{
foreach ($_POST['reserve'] as $key = $a)
   {
   echo($key $a br /);
   }
}

Here's the demo:

http://www.webbytedd.com//post-array1/index.php


Don't forget the /input on the end of those input lines. I've seen too
many pages already where I had to fix that problem.

Bob McConnell


It shouldn't really be

input type=checkbox name=reserve[1] Room #1/input

but something like this:

labelinput type=checkbox name=reserve[1] Room #1/label



Well, to quote the W3C Recommendation...
http://www.w3.org/TR/html401/interact/forms.html#h-17.9.1

FORM action=... method=post
TABLE
  TR
TDLABEL for=fnameFirst Name/LABEL
TDINPUT type=text name=firstname id=fname
  TR
TDLABEL for=lnameLast Name/LABEL
TDINPUT type=text name=lastname id=lname
/TABLE
/FORM

The label tag should reference the input via the for attribute.  Identifying 
the input tag by id attribute value.


And using the for attribute of the label tag in conjunction with the id
attribute of the input tag, you can separate the label and form element
entirely, which is sueful if you still use tables to line up your
forms! 



Ash
www.ashleysheridan.co.uk




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



Re: [PHP] How do I access a local variable?

2009-04-19 Thread Ashley Sheridan
On Sun, 2009-04-19 at 21:55 -0400, Paul M Foster wrote:
 On Mon, Apr 20, 2009 at 12:54:27AM +0100, abdulazeez alugo wrote:
 
  
  Hi guys,
  
  I have a function inside which I set alocal variable to store a result. Can 
  I access this variable in another function? if yes then how?
  
  function tbl1($entrytitle, $entrytext)
  
  {
  
  global $conn;
  
  $result= mysql_query(INSERT INTO tbl1(tbl1_id, title, text)
  
   VALUES('NULL', '$entrytitle', '$entrytext'), $conn);
  
   $tbl_id=mysql_insert_id($conn);// this is the local variable I'm 
  setting to get the last auto increment id
  
  } 
  
   
  
  Now I wish to access that variable in another function thus:
  
  function tbl2($name, $entrytitle, $entrytext)
  
  {
  
  global $conn;
  
  $result =mysql_query(INSERT INTO tbl2(tbl1_id, name, title, text)
  
 VALUES('$tbl1_id', '$name', '$entrytitle', 
  '$entrytext' ), $Conn); 
  
  }
  
   
  
  Or is there a better way to store the variable?
 
 If a variable is local to a function, there is no way to access that
 variable outside that function. You can pass it back as a return value
 from the original function, or make it global (not advised) to make it
 visible in other functions.
 
 Paul
 
 -- 
 Paul M. Foster
 

Or pass it by reference to the functions, so that both are able to make
changes to it.



Ash
www.ashleysheridan.co.uk


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