Re: [PHP] php mail() function

2009-10-24 Thread James Prentice
But it seems like the 'From:' address being given to the PHP mail()
function is maybe being ignored, because the error log lists
'www-d...@homemade' as being the sender, rather than listing the shaw
address.

The snippet from the PHP code:

$email = $_POST['email'];
...
mail($to, $subject, $msg, 'From:' . $email);

I have tried setting both $to and $email to be the same shaw address
since I assumed it should be recognized by the mail server, but it's
still getting bounced. So why is 'www-d...@homemade' being listed as
the sender? Any ideas?


On Sat, Oct 24, 2009 at 9:17 PM, James Prentice  wrote:
> I also suspect that the problem is due to the sender address, but I
> have tried using the shaw email address for the From: address that's
> given to the mail() function and it still gets bounced. It seems like
> the ISP should consider that address valid.
>
>
>
> On Sat, Oct 24, 2009 at 2:20 PM, Per olof Ljungmark  wrote:
>> James Prentice wrote:
>>>
>>> It sends the bounced message to /var/mail/www-data and I get this:
>>>
>>> --19BE8A70109.1256417846/homemade
>>> Content-Description: Delivery report
>>> Content-Type: message/delivery-status
>>>
>>> Reporting-MTA: dns; homemade
>>> X-Postfix-Queue-ID: 19BE8A70109
>>> X-Postfix-Sender: rfc822; www-d...@homemade
>>> Arrival-Date: Sat, 24 Oct 2009 13:57:26 -0700 (PDT)
>>>
>>> Final-Recipient: rfc822; x...@shaw.ca
>>> Action: failed
>>> Status: 5.0.0
>>> Diagnostic-Code: X-Postfix; shawmail.vc.shawcable.net
>>>
>>> --19BE8A70109.1256417846/homemade
>>> Content-Description: Undelivered Message
>>> Content-Type: message/rfc822
>>>
>>> Received: by homemade (Postfix, from userid 33)
>>>        id 19BE8A70109; Sat, 24 Oct 2009 13:57:26 -0700 (PDT)
>>> To: x...@shaw.ca
>>
>> Although 5.0.0 actually means something else I'm pretty sure you are
>> rejected because of an invalid sender address or domain. Use a sender
>> address that is valid with your ISP's mail relay.
>>
>> Just my $0.02
>>
>> --
>> per
>>
>

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



Re: [PHP] php mail() function

2009-10-24 Thread James Prentice
I also suspect that the problem is due to the sender address, but I
have tried using the shaw email address for the From: address that's
given to the mail() function and it still gets bounced. It seems like
the ISP should consider that address valid.



On Sat, Oct 24, 2009 at 2:20 PM, Per olof Ljungmark  wrote:
> James Prentice wrote:
>>
>> It sends the bounced message to /var/mail/www-data and I get this:
>>
>> --19BE8A70109.1256417846/homemade
>> Content-Description: Delivery report
>> Content-Type: message/delivery-status
>>
>> Reporting-MTA: dns; homemade
>> X-Postfix-Queue-ID: 19BE8A70109
>> X-Postfix-Sender: rfc822; www-d...@homemade
>> Arrival-Date: Sat, 24 Oct 2009 13:57:26 -0700 (PDT)
>>
>> Final-Recipient: rfc822; x...@shaw.ca
>> Action: failed
>> Status: 5.0.0
>> Diagnostic-Code: X-Postfix; shawmail.vc.shawcable.net
>>
>> --19BE8A70109.1256417846/homemade
>> Content-Description: Undelivered Message
>> Content-Type: message/rfc822
>>
>> Received: by homemade (Postfix, from userid 33)
>>        id 19BE8A70109; Sat, 24 Oct 2009 13:57:26 -0700 (PDT)
>> To: x...@shaw.ca
>
> Although 5.0.0 actually means something else I'm pretty sure you are
> rejected because of an invalid sender address or domain. Use a sender
> address that is valid with your ISP's mail relay.
>
> Just my $0.02
>
> --
> per
>

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



[PHP] How to Get the Sub Classes of a Parent Class

2009-10-24 Thread Raymond Irving
Hello,

Does any know of an optimized solution to get all the subclasses for a parent 
class?

__
Raymond Irving


Re: [PHP] Ubuntu and Apache

2009-10-24 Thread Miles Thompson
Brian,

You're not doing anything wrong. Apache runs as www-data in Ubuntu, so any
file created by Apache will belong to that owner:group.

Add yourself to the www-data group and life will become easier.

Cheers - Miles

On Sat, Oct 24, 2009 at 7:42 PM, Brian Hazelton wrote:

> I know this is not quite on topic but I do not know where else to turn. I
> needed to reinstall ubuntu and now I cannot change myself to be the owner of
> var www. I had been able to change myself to the owner of it and create,
> delete and modify any files I wanted before I had to reinstall. Now it seems
> the change is not taking effect. What happens  is I use the sudo chown
> command and it shows that I am the owner. I have a script that creates a
> file when I go to the page and it creates a file and has www-data as the
> owner, not me. What am I doing wrong?
> Thanks,
> Brian
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Miles Thompson
~~
"The piano keys are black and white,
But they sound like a million colours in your mind"
Spider's Web - Katie Melua


[PHP] Ubuntu and Apache

2009-10-24 Thread Brian Hazelton
I know this is not quite on topic but I do not know where else to turn. 
I needed to reinstall ubuntu and now I cannot change myself to be the 
owner of var www. I had been able to change myself to the owner of it 
and create, delete and modify any files I wanted before I had to 
reinstall. Now it seems the change is not taking effect. What happens  
is I use the sudo chown command and it shows that I am the owner. I have 
a script that creates a file when I go to the page and it creates a file 
and has www-data as the owner, not me. What am I doing wrong?

Thanks,
Brian

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



[PHP] cannot compile PHP 5.2.11 on Mac OS X 10.6.1

2009-10-24 Thread Mari Masuda

Hi,

I am setting up my Mac Book Pro running Mac OS X 10.6.1 as a  
development environment for Drupal.  I already successfully have MySQL  
5.1.40 and Apache 2.2.11 up and running.  I tried to compile PHP  
5.2.11 in the following manner and keep getting an error.  Any help  
would be great!


1.  Downloaded php-5.2.11.tar.gz from php.net.  The MD5 checksum of  
the downloaded file is the same as what is listed on php.net so I do  
not think the file is corrupt.
2.  Expanded php-5.2.11.tar.gz by double-clicking the file I  
downloaded and moving the resulting folder (named "php-5.2.11") to my  
desktop.


In terminal did the following (I am following the instructions in the  
box labeled "Example #1 Installation Instructions (Apache 2 Shared  
Module Version)" at http://www.php.net/manual/en/install.unix.apache2.php 
)

3.  cd /Users/mari/Desktop/php-5.2.11
4.  ./configure --prefix=/Applications/php --disable-short-tags --with- 
mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config  
--with-apxs2=/Applications/apache/bin/apxs --enable-mbstring --with- 
pdo-mysql=/usr/local/mysql

5.  make

At this point, make does not complete and it exits with an error:

---start error---
Undefined symbols:
  "_res_9_dn_expand", referenced from:
  _zif_dns_get_mx in dns.o
  "_res_9_search", referenced from:
  _zif_dns_get_mx in dns.o
  _zif_dns_check_record in dns.o
  "_libiconv", referenced from:
  __php_iconv_strlen in iconv.o
  _php_iconv_string in iconv.o
  _php_iconv_string in iconv.o
  __php_iconv_strpos in iconv.o
  __php_iconv_appendl in iconv.o
  __php_iconv_appendl in iconv.o
  _zif_iconv_substr in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _php_iconv_stream_filter_append_bucket in iconv.o
  _php_iconv_stream_filter_append_bucket in iconv.o
  "_res_9_dn_skipname", referenced from:
  _zif_dns_get_mx in dns.o
  _zif_dns_get_mx in dns.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [libs/libphp5.bundle] Error 1
---end error---

To try to simplify things, I deleted the php-5.2.11 folder I created  
in step 2 above and repeated steps 2 and 3.  Then at this point I only  
did ./configure by itself with no options, thinking that I could try  
to see if any of my configuration options were causing the issue.   
Alas, no, the problem still happens; the error is now this:


---start error---
Undefined symbols:
  "_res_9_dn_expand", referenced from:
  _zif_dns_get_mx in dns.o
  "_res_9_search", referenced from:
  _zif_dns_get_mx in dns.o
  _zif_dns_check_record in dns.o
  "_libiconv", referenced from:
  __php_iconv_strlen in iconv.o
  _php_iconv_string in iconv.o
  _php_iconv_string in iconv.o
  __php_iconv_strpos in iconv.o
  __php_iconv_appendl in iconv.o
  __php_iconv_appendl in iconv.o
  _zif_iconv_substr in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _php_iconv_stream_filter_append_bucket in iconv.o
  _php_iconv_stream_filter_append_bucket in iconv.o
  "_res_9_dn_skipname", referenced from:
  _zif_dns_get_mx in dns.o
  _zif_dns_get_mx in dns.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [sapi/cgi/php-cgi] Error 1
---end error---

What can I do to get around this problem and compile PHP?  Thanks!

Mari

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



Re: [PHP] php mail() function

2009-10-24 Thread Per olof Ljungmark

James Prentice wrote:

It sends the bounced message to /var/mail/www-data and I get this:

--19BE8A70109.1256417846/homemade
Content-Description: Delivery report
Content-Type: message/delivery-status

Reporting-MTA: dns; homemade
X-Postfix-Queue-ID: 19BE8A70109
X-Postfix-Sender: rfc822; www-d...@homemade
Arrival-Date: Sat, 24 Oct 2009 13:57:26 -0700 (PDT)

Final-Recipient: rfc822; x...@shaw.ca
Action: failed
Status: 5.0.0
Diagnostic-Code: X-Postfix; shawmail.vc.shawcable.net

--19BE8A70109.1256417846/homemade
Content-Description: Undelivered Message
Content-Type: message/rfc822

Received: by homemade (Postfix, from userid 33)
id 19BE8A70109; Sat, 24 Oct 2009 13:57:26 -0700 (PDT)
To: x...@shaw.ca


Although 5.0.0 actually means something else I'm pretty sure you are 
rejected because of an invalid sender address or domain. Use a sender 
address that is valid with your ISP's mail relay.


Just my $0.02

--
per

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



Re: [PHP] php mail() function

2009-10-24 Thread James Prentice
It sends the bounced message to /var/mail/www-data and I get this:

--19BE8A70109.1256417846/homemade
Content-Description: Delivery report
Content-Type: message/delivery-status

Reporting-MTA: dns; homemade
X-Postfix-Queue-ID: 19BE8A70109
X-Postfix-Sender: rfc822; www-d...@homemade
Arrival-Date: Sat, 24 Oct 2009 13:57:26 -0700 (PDT)

Final-Recipient: rfc822; x...@shaw.ca
Action: failed
Status: 5.0.0
Diagnostic-Code: X-Postfix; shawmail.vc.shawcable.net

--19BE8A70109.1256417846/homemade
Content-Description: Undelivered Message
Content-Type: message/rfc822

Received: by homemade (Postfix, from userid 33)
id 19BE8A70109; Sat, 24 Oct 2009 13:57:26 -0700 (PDT)
To: x...@shaw.ca

I will investigate how to change the loglevel of postfix, because
right now the error messages don't seem very helpful (at least to me).
Cheers

On Sat, Oct 24, 2009 at 1:27 PM, John Black
 wrote:
> James Prentice wrote:
>  > Also, I notice that in the mail.log file, the 'from:' value is
>>
>> 'www-d...@homemade'. The actual 'from:' value is provided to the php
>> mail() function via a web form, so should be somebody's email address
>> (e.g. my own in this case).
>
> I think PHP will use the apache user and domain to generate the email
> address. I use my own smtp function so I can't say for certain.
>
> One thing you could try is to use a valid email account on the server for
> the FROM address so that you can receive the bounced message. The actual
> message should contain more information.
> Alternatively attempt to increase the loglevel of postfix so you get exact
> feedback of why the connection is failing.
>
> As far as which server to use. I think this page lists the correct one:
> http://www.shaw.ca/en-ca/CustomerCare/InternetSupport/Residential/RoutersandShawServerNames.htm
>
> --
> John
>

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



Re: [PHP] php mail() function

2009-10-24 Thread John Black

James Prentice wrote:
 > Also, I notice that in the mail.log file, the 'from:' value is

'www-d...@homemade'. The actual 'from:' value is provided to the php
mail() function via a web form, so should be somebody's email address
(e.g. my own in this case).


I think PHP will use the apache user and domain to generate the email 
address. I use my own smtp function so I can't say for certain.


One thing you could try is to use a valid email account on the server 
for the FROM address so that you can receive the bounced message. The 
actual message should contain more information.
Alternatively attempt to increase the loglevel of postfix so you get 
exact feedback of why the connection is failing.


As far as which server to use. I think this page lists the correct one:
http://www.shaw.ca/en-ca/CustomerCare/InternetSupport/Residential/RoutersandShawServerNames.htm

--
John

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



Re: [PHP] php mail() function

2009-10-24 Thread James Prentice
Thanks, John. I set up the sasl_passwd file as per your instructions
but am still getting status=bounced. I'm wondering, what should the
values in main.cf be for 'myhostname' and 'mydestination'?

These pages give some info on the Shaw mail servers, but I'm not
certain which I should be using:

http://www.shaw.ca/en-ca/CustomerCare/InternetSupport/Residential/Email/ServiceDetails.htm

http://www.shaw.ca/en-ca/CustomerCare/InternetSupport/Residential/RoutersandShawServerNames.htm

Also, I notice that in the mail.log file, the 'from:' value is
'www-d...@homemade'. The actual 'from:' value is provided to the php
mail() function via a web form, so should be somebody's email address
(e.g. my own in this case).


from=, size=523, nrcpt=1 (queue active)
Oct 24 12:49:40 homemade postfix/error[7530]: B80B7A70109:
to=, relay=none, delay=0.04, delays=0.03/0/0/0.01,
dsn=5.0.0, status=bounced (shawmail)

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



Re: [PHP] Array

2009-10-24 Thread Jim Lucas

Ron Piggott wrote:

The code I have so far for orders is below.  When a product hasn't been
added it does what I want it to --- in giving the message "Your shopping
cart is empty".  When a product is added, but then the user changes
their mind I use the following lines of code to remove the selection:

UNSET($_SESSION['order'][$reference]['quantity']);
UNSET($_SESSION['order'][$reference]);

It still leaves the variable   $_SESSION['order']   as an array, even if
there are no selections in it.  The PHP command is_array is useless of
weed out when there are no products.

What I would like to have happen is if the shopping cart is empty then
the message "Your shopping cart is empty" be displayed 100% of the time.
How do I achieve this?  What changes to my code below need to happen?

foreach ($_SESSION['order'] AS $key => $value ) { 
echo "Product: " . $key . " Quantity: " .

$_SESSION['order'][$key]['quantity'] . "\r\n";
}

} else {
#no products selected

echo "\r\n";
echo "Your shopping cart is empty\r\n";
echo "\r\n";

}



Try this

 0   # Does it have at least 1 element
) {

#customer has begun creating order
foreach ($_SESSION['order'] AS $key => $value ) {
echo "Product: {$key} Quantity: 
{$_SESSION['order'][$key]['quantity']}\r\n";
}

} else {
#no products selected
echo "\r\n";
echo "Your shopping cart is empty\r\n";
echo "\r\n";
}


...

?>


-Original Message-
From: Martin Scotta 
To: a...@ashleysheridan.co.uk
Cc: ron.pigg...@actsministries.org, PHP General

Subject: Re: [PHP] Array
Date: Sat, 24 Oct 2009 11:50:14 -0300



On Sat, Oct 24, 2009 at 7:59 AM, Ashley Sheridan
 wrote:
On Sat, 2009-10-24 at 06:57 -0400, Ron Piggott wrote:

> The following line gives me an error message when there aren't

any
> values in the array --- how do I accommodate this?
>
> Warning: Invalid argument supplied for foreach()
>
> foreach ($_SESSION['order'] AS $key => $value ) {
>
>




Do an isset() on $_SESSION['order'] first to determine if the

variable
even exists, then do is_array() to determine if it's an array or
not
before trying to iterate it. My guess is that $_SESSION['order']
isn't
an array all the time.



Thanks,

Ash
http://www.ashleysheridan.co.uk




foreach works with array and instances. 
Unless the class implements Transversable, it's public properties are

used on the loop.


foreach($object as $prop => $value )
//php translates the foreach into something like this...
foreach(get_object_vars($object) as $prop => $value )




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

2009-10-24 Thread Shawn McKenzie
Ron Piggott wrote:
> The code I have so far for orders is below.  When a product hasn't been
> added it does what I want it to --- in giving the message "Your shopping
> cart is empty".  When a product is added, but then the user changes
> their mind I use the following lines of code to remove the selection:
> 
> UNSET($_SESSION['order'][$reference]['quantity']);
> UNSET($_SESSION['order'][$reference]);
> 
> It still leaves the variable   $_SESSION['order']   as an array, even if
> there are no selections in it.  The PHP command is_array is useless of
> weed out when there are no products.
> 
> What I would like to have happen is if the shopping cart is empty then
> the message "Your shopping cart is empty" be displayed 100% of the time.
> How do I achieve this?  What changes to my code below need to happen?
> 
>  if ( isset($_SESSION['order']) ) {
> #customer has begun creating order
> 
> foreach ($_SESSION['order'] AS $key => $value ) { 
> echo "Product: " . $key . " Quantity: " .
> $_SESSION['order'][$key]['quantity'] . "\r\n";
> }
> 
> } else {
> #no products selected
> 
> echo "\r\n";
> echo "Your shopping cart is empty\r\n";
> echo "\r\n";
> 
> }
> 

Or use unset, but unset the entire order:  unset($_SESSION['order'])

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Array

2009-10-24 Thread Ron Piggott

AHH.  The count() command does the trick.  Ron

-Original Message-
From: Ron Piggott 
Reply-to: ron.pigg...@actsministries.org
To: Martin Scotta , phps...@gmail.com
Cc: a...@ashleysheridan.co.uk, PHP General 
Subject: Re: [PHP] Array
Date: Sat, 24 Oct 2009 11:43:12 -0400

The code I have so far for orders is below.  When a product hasn't been
added it does what I want it to --- in giving the message "Your shopping
cart is empty".  When a product is added, but then the user changes
their mind I use the following lines of code to remove the selection:

UNSET($_SESSION['order'][$reference]['quantity']);
UNSET($_SESSION['order'][$reference]);

It still leaves the variable   $_SESSION['order']   as an array, even if
there are no selections in it.  The PHP command is_array is useless of
weed out when there are no products.

What I would like to have happen is if the shopping cart is empty then
the message "Your shopping cart is empty" be displayed 100% of the time.
How do I achieve this?  What changes to my code below need to happen?

 $value ) { 
echo "Product: " . $key . " Quantity: " .
$_SESSION['order'][$key]['quantity'] . "\r\n";
}

} else {
#no products selected

echo "\r\n";
echo "Your shopping cart is empty\r\n";
echo "\r\n";

}

-Original Message-
From: Martin Scotta 
To: a...@ashleysheridan.co.uk
Cc: ron.pigg...@actsministries.org, PHP General

Subject: Re: [PHP] Array
Date: Sat, 24 Oct 2009 11:50:14 -0300



On Sat, Oct 24, 2009 at 7:59 AM, Ashley Sheridan
 wrote: 
On Sat, 2009-10-24 at 06:57 -0400, Ron Piggott wrote:

> The following line gives me an error message when there aren't
any
> values in the array --- how do I accommodate this?
>
> Warning: Invalid argument supplied for foreach()
>
> foreach ($_SESSION['order'] AS $key => $value ) {
>
>



Do an isset() on $_SESSION['order'] first to determine if the
variable
even exists, then do is_array() to determine if it's an array or
not
before trying to iterate it. My guess is that $_SESSION['order']
isn't
an array all the time.


Thanks,
Ash
http://www.ashleysheridan.co.uk




foreach works with array and instances. 
Unless the class implements Transversable, it's public properties are
used on the loop.


foreach($object as $prop => $value )
//php translates the foreach into something like this...
foreach(get_object_vars($object) as $prop => $value )

-- 
Martin Scotta


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



Re: [PHP] Array

2009-10-24 Thread Ron Piggott
The code I have so far for orders is below.  When a product hasn't been
added it does what I want it to --- in giving the message "Your shopping
cart is empty".  When a product is added, but then the user changes
their mind I use the following lines of code to remove the selection:

UNSET($_SESSION['order'][$reference]['quantity']);
UNSET($_SESSION['order'][$reference]);

It still leaves the variable   $_SESSION['order']   as an array, even if
there are no selections in it.  The PHP command is_array is useless of
weed out when there are no products.

What I would like to have happen is if the shopping cart is empty then
the message "Your shopping cart is empty" be displayed 100% of the time.
How do I achieve this?  What changes to my code below need to happen?

 $value ) { 
echo "Product: " . $key . " Quantity: " .
$_SESSION['order'][$key]['quantity'] . "\r\n";
}

} else {
#no products selected

echo "\r\n";
echo "Your shopping cart is empty\r\n";
echo "\r\n";

}

-Original Message-
From: Martin Scotta 
To: a...@ashleysheridan.co.uk
Cc: ron.pigg...@actsministries.org, PHP General

Subject: Re: [PHP] Array
Date: Sat, 24 Oct 2009 11:50:14 -0300



On Sat, Oct 24, 2009 at 7:59 AM, Ashley Sheridan
 wrote:
On Sat, 2009-10-24 at 06:57 -0400, Ron Piggott wrote:

> The following line gives me an error message when there aren't
any
> values in the array --- how do I accommodate this?
>
> Warning: Invalid argument supplied for foreach()
>
> foreach ($_SESSION['order'] AS $key => $value ) {
>
>




Do an isset() on $_SESSION['order'] first to determine if the
variable
even exists, then do is_array() to determine if it's an array or
not
before trying to iterate it. My guess is that $_SESSION['order']
isn't
an array all the time.



Thanks,
Ash
http://www.ashleysheridan.co.uk




foreach works with array and instances. 
Unless the class implements Transversable, it's public properties are
used on the loop.


foreach($object as $prop => $value )
//php translates the foreach into something like this...
foreach(get_object_vars($object) as $prop => $value )

-- 
Martin Scotta


Re: [PHP] Array

2009-10-24 Thread Martin Scotta
On Sat, Oct 24, 2009 at 7:59 AM, Ashley Sheridan
wrote:

> On Sat, 2009-10-24 at 06:57 -0400, Ron Piggott wrote:
>
> > The following line gives me an error message when there aren't any
> > values in the array --- how do I accommodate this?
> >
> > Warning: Invalid argument supplied for foreach()
> >
> > foreach ($_SESSION['order'] AS $key => $value ) {
> >
> >
>
>
> Do an isset() on $_SESSION['order'] first to determine if the variable
> even exists, then do is_array() to determine if it's an array or not
> before trying to iterate it. My guess is that $_SESSION['order'] isn't
> an array all the time.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
foreach works with array and instances.
Unless the class implements Transversable, it's public properties are used
on the loop.


foreach($object as $prop => $value )
//php translates the foreach into something like this...
foreach(get_object_vars($object) as $prop => $value )

-- 
Martin Scotta


[PHP] curl spider and being a good citizen

2009-10-24 Thread Michael A. Peters
I'm writing a custom search engine for my site, it seemed easier than 
modifying sphyder (what I currently use) to do what I want especially 
since sphyder has a lot of stuff that isn't personally of use to me.


One of the things I want to do when I index is list external links and 
check them.


The idea is to have curl download just the headers but not content from 
external links.


This is what I have as part of my class to do that -

function meta($url) {
  $process = curl_init($url);
  curl_setopt($process, CURLOPT_CONNECTTIMEOUT, 15);
  curl_setopt($process, CURLOPT_TIMEOUT, 20);

  curl_setopt($process, CURLOPT_HTTPHEADER, $this->headers);
  curl_setopt($process, CURLOPT_USERAGENT, $this->user_agent);
  curl_setopt($process, CURLOPT_NOBODY, true);
  curl_setopt($process, CURLOPT_HEADER, 0);

  $fetch = curl_exec($process);

  $return[] = curl_getinfo($process, CURLINFO_HTTP_CODE);
  $meta = split(';',curl_getinfo($process, CURLINFO_CONTENT_TYPE));
  $return[] = $meta[0];

  curl_close($process);
  return $return;
  }

I am under the impression that
curl_setopt($process, CURLOPT_NOBODY, true);

does what I want - but the curl docs can be confusing.

Will that work to just download the headers needed to get the http 
status code and mime type w/o grabbing content?


And secondly, will making 40 or so connections to the same remote site 
just to grab headers but not content (there are two I link to quite a 
bit with permission) to check for moved files possibly cause issues with 
their server software? It doesn't seem to for me (Apache on Linux) but 
that's me, and I'm not positive curl stopped the download after getting 
last http header.


Pages on those sites do move as taxonomy moves and the people in charge 
don't seem to keep 301 moved redirects in place when they reorganize, so 
I do need to check with some frequency, but I don't want to cause problems.


Thanks for suggestions.

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



Re: [PHP] $_SESSION variables

2009-10-24 Thread Lester Caine

Ron Piggott wrote:

Instead of doing:

$_SESSION['order'][$reference]['quantity'] = 0;

Is there a way to get remove that part of the array altogether?


unset?
unset($_SESSION['order'][$reference]['quantity']);

Can't seem to reach php.net to confirm, but I use it myself ;)

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



Re: [PHP] $_SESSION variables

2009-10-24 Thread Phpster
Unset($_SESSION['order'][$reference]['quantity']); will clear the  
entire session object



Bastien

Sent from my iPod

On Oct 24, 2009, at 8:01 AM, Ron Piggott   
wrote:




I am programming a shopping cart.

So far I have used

$_SESSION['order'][$reference]['quantity'] = 0;

if the customer changed their mind about buying an item.  Is there a  
way

to remove the session variable altogether?

Ron

-Original Message-
From: Ashley Sheridan 
Reply-to: a...@ashleysheridan.co.uk
To: ron@actsministries.org
Cc: PHP General 
Subject: Re: [PHP] $_SESSION variables
Date: Sat, 24 Oct 2009 12:52:17 +0100

On Sat, 2009-10-24 at 07:52 -0400, Ron Piggott wrote:


Instead of doing:

$_SESSION['order'][$reference]['quantity'] = 0;

Is there a way to get remove that part of the array altogether?

Ron





I don't understand your question..

Thanks,
Ash
http://www.ashleysheridan.co.uk





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



Re: [PHP] $_SESSION variables

2009-10-24 Thread Ron Piggott

I am programming a shopping cart.  

So far I have used 

$_SESSION['order'][$reference]['quantity'] = 0;

if the customer changed their mind about buying an item.  Is there a way
to remove the session variable altogether?

Ron

-Original Message-
From: Ashley Sheridan 
Reply-to: a...@ashleysheridan.co.uk
To: ron@actsministries.org
Cc: PHP General 
Subject: Re: [PHP] $_SESSION variables
Date: Sat, 24 Oct 2009 12:52:17 +0100

On Sat, 2009-10-24 at 07:52 -0400, Ron Piggott wrote: 

> Instead of doing:
> 
> $_SESSION['order'][$reference]['quantity'] = 0;
> 
> Is there a way to get remove that part of the array altogether?
> 
> Ron
> 
> 


I don't understand your question..

Thanks,
Ash
http://www.ashleysheridan.co.uk





Re: [PHP] $_SESSION variables

2009-10-24 Thread Ashley Sheridan
On Sat, 2009-10-24 at 07:52 -0400, Ron Piggott wrote:

> Instead of doing:
> 
> $_SESSION['order'][$reference]['quantity'] = 0;
> 
> Is there a way to get remove that part of the array altogether?
> 
> Ron
> 
> 


I don't understand your question..

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] $_SESSION variables

2009-10-24 Thread Ron Piggott
Instead of doing:

$_SESSION['order'][$reference]['quantity'] = 0;

Is there a way to get remove that part of the array altogether?

Ron


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



Re: [PHP] Array

2009-10-24 Thread Ashley Sheridan
On Sat, 2009-10-24 at 06:57 -0400, Ron Piggott wrote:

> The following line gives me an error message when there aren't any
> values in the array --- how do I accommodate this?
> 
> Warning: Invalid argument supplied for foreach()
> 
> foreach ($_SESSION['order'] AS $key => $value ) { 
> 
> 


Do an isset() on $_SESSION['order'] first to determine if the variable
even exists, then do is_array() to determine if it's an array or not
before trying to iterate it. My guess is that $_SESSION['order'] isn't
an array all the time.

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] Array

2009-10-24 Thread Ron Piggott
The following line gives me an error message when there aren't any
values in the array --- how do I accommodate this?

Warning: Invalid argument supplied for foreach()

foreach ($_SESSION['order'] AS $key => $value ) { 


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



Re: [PHP] IDE with ftp and subversion?

2009-10-24 Thread Lars Nielsen
lør, 24 10 2009 kl. 12:15 +0200, skrev John Black:
> Lars Nielsen wrote:
> > Can anyone recommend an IDE with both subversion and ftp integration?
> > I have played a little with eclipse but find the integrations a little
> > dificult to manage.
> > Idealy I want a local development server with LAMP+svn and then an easy
> > opportunity to publish a site to a production server.
> 
> 
> Have you tried Netbeans?
>   http://www.netbeans.org/downloads/index.html
> 
> It comes with svn support, can upload your project to your webserver 
> over ftp, step by step debugger and a lot more.
> 
> Give it a try
> -- 
> John
> A casual stroll through the lunatic asylum shows that faith does not 
> prove anything.
> [Friedrich Nietzsche]
> 
Thanks again! :-)
It works like a dream! 

/Lars


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



Re: [PHP] IDE with ftp and subversion?

2009-10-24 Thread Lars Nielsen
Hi,
No I have not tryed that yet. Giving it a shot now! :-) 

Thanks

/Lars
lør, 24 10 2009 kl. 12:15 +0200, skrev John Black:
> Lars Nielsen wrote:
> > Can anyone recommend an IDE with both subversion and ftp integration?
> > I have played a little with eclipse but find the integrations a little
> > dificult to manage.
> > Idealy I want a local development server with LAMP+svn and then an easy
> > opportunity to publish a site to a production server.
> 
> 
> Have you tried Netbeans?
>   http://www.netbeans.org/downloads/index.html
> 
> It comes with svn support, can upload your project to your webserver 
> over ftp, step by step debugger and a lot more.
> 
> Give it a try
> -- 
> John
> A casual stroll through the lunatic asylum shows that faith does not 
> prove anything.
> [Friedrich Nietzsche]
> 


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



Re: [PHP] IDE with ftp and subversion?

2009-10-24 Thread John Black

Lars Nielsen wrote:

Can anyone recommend an IDE with both subversion and ftp integration?
I have played a little with eclipse but find the integrations a little
dificult to manage.
Idealy I want a local development server with LAMP+svn and then an easy
opportunity to publish a site to a production server.



Have you tried Netbeans?
http://www.netbeans.org/downloads/index.html

It comes with svn support, can upload your project to your webserver 
over ftp, step by step debugger and a lot more.


Give it a try
--
John
A casual stroll through the lunatic asylum shows that faith does not 
prove anything.

[Friedrich Nietzsche]

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



[PHP] IDE with ftp and subversion?

2009-10-24 Thread Lars Nielsen
Hi there,

Can anyone recommend an IDE with both subversion and ftp integration?
I have played a little with eclipse but find the integrations a little
dificult to manage.
Idealy I want a local development server with LAMP+svn and then an easy
opportunity to publish a site to a production server.

Can anyone give me a hint?

Regards
Lars Nielsen


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



Re: [PHP] How to pronounce PHP code over the phone?

2009-10-24 Thread Dotan Cohen
> There is... It's called a Fax ;-)
>

Again, I am interested in knowing the proper terminology for PHP
constructs and code. We have a name for a small sweer green fruit from
the vine, and we have a name for the alcoholic beverage that is
derived from it. Knowing these names helps one communicate verbally,
even when one could simply fax a photo of a grape and a glass of wine.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

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



Re: [PHP] php mail() function

2009-10-24 Thread John Black

Paul M Foster wrote:
 > 4. All due respect to Kranthi, but I believe he's wrong about relaying

mail from your webserver to the ISP's mailserver. I believe the ISP's
mailserver doesn't care, as long as the mail comes from your "pipe". You
could probably call yourself "pi...@pepperoni.com" and your ISP would
accept it. It's just the From:. Again, I could be wrong.


All the ISPs I have used so far require the user to authenticate even 
when on the same network.
So if you want to relay through the SMTP server of your ISP you need to 
login first. I think that is what Kranthi said


Try this:
1) Set up a password maps file (/etc/postfix/sasl_passwd) with the content:
mail.ispserver.comusername:password

Now Execute these commands
# chown root:root /etc/postfix/sasl_passwd
# chmod 600 /etc/postfix/sasl_passwd
# postmap /etc/postfix/sasl_passwd

And change your config to this /etc/postfix/main.cf:
relayhost = mail.ispserver.com
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous

Now reload postfix and try it again.
# postfix reload

--
John
Question / Answer based CAPTCHA
http://www.network-technologies.org/tiny.php?id=1

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



Re: [PHP] How to pronounce PHP code over the phone?

2009-10-24 Thread Kim Madsen

Dotan Cohen wrote on 2009-10-23 22:40:

But I think for the OP's purposes, he could simply DEFINE any word he wanted
at the beginning of the conversation: "Listen up duder. When I say 'de-ref'
you make hyphen and a greater-than sign. Capiche?". He could just as easily
say, "Listen up duder. When I say 'arrow-thingy' you make hyphen and a
greater-than sign. Capiche?"  Problem solved. ;-)



That is what was done, but I wanted to know if there was already some
agreed-upon language.


There is... It's called a Fax ;-)

--
Kind regards
Kim Emax - masterminds.dk

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



[PHP] using mysql_close() = best practice?

2009-10-24 Thread Kim Madsen

Hi

PHP closes an open db connection when the script is done.

I've read somewhere that in PHP6 this behaviour will dissapear, is this 
true? In that case using mysql_close() would definetly be best practice 
in all current scripts, to make it portable.


A nice solution would probably be adding a end_mysql() or page_end() to 
all pages and put whatever is needed into that function (mysql_close, 
mysql_free_result, etc)


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Sessions seems to kill db connection

2009-10-24 Thread Kim Madsen

Hi Kranthi

kranthi wrote on 2009-10-24 07:27:

Db error: Access denied for user 'www-data'@'localhost' (using password: NO)



WTF? I´m not using a user called www-data for MySQL connections, but apache 
runs as this user


in the case where $test is true there is an open mysql connection, but
when $test is false there is no open connection is  available. may be
you have opened a connection when $test is true or used a
mysql_close() when $test is false or when $_SESSION['login']['uid'] is
set.


I think you missed my words about resolving the matter, when you were 
cutting the quoted text :-)



regarding www-data, when mysql_query() fails to find a valid MySql
connection, it tries to open a new connection with mysql.default_user
and mysql.default_password (u can see these values trough phpinfo());
http://php.net/manual/en/function.mysql-connect.php


Thanks, that explained the www-data user

--
Kind regards
Kim Emax - masterminds.dk

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