php-general Digest 24 Oct 2009 21:01:16 -0000 Issue 6408

Topics (messages 299284 through 299307):

using mysql_close() = best practice?
        299284 by: Kim Madsen

Re: How to pronounce PHP code over the phone?
        299285 by: Kim Madsen
        299287 by: Dotan Cohen

Re: php mail() function
        299286 by: John Black
        299305 by: James Prentice
        299306 by: John Black
        299307 by: James Prentice

IDE with ftp and subversion?
        299288 by: Lars Nielsen
        299289 by: John Black
        299290 by: Lars Nielsen
        299291 by: Lars Nielsen

Array
        299292 by: Ron Piggott
        299293 by: Ashley Sheridan
        299300 by: Martin Scotta
        299301 by: Ron Piggott
        299302 by: Ron Piggott
        299303 by: Shawn McKenzie
        299304 by: Jim Lucas

$_SESSION variables
        299294 by: Ron Piggott
        299295 by: Ashley Sheridan
        299296 by: Ron Piggott
        299297 by: Phpster
        299298 by: Lester Caine

curl spider and being a good citizen
        299299 by: Michael A. Peters

Administrivia:

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

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

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


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

--- End Message ---
--- Begin Message ---
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

--- End Message ---
--- Begin Message ---
> 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

--- End Message ---
--- Begin Message ---
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.com    username: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

--- End Message ---
--- Begin Message ---
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=<www-d...@homemade>, size=523, nrcpt=1 (queue active)
Oct 24 12:49:40 homemade postfix/error[7530]: B80B7A70109:
to=<x...@gmail.com>, relay=none, delay=0.04, delays=0.03/0/0/0.01,
dsn=5.0.0, status=bounced (shawmail)

--- End Message ---
--- Begin Message ---
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

--- End Message ---
--- Begin Message ---
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
<s...@network-technologies.org> 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
>

--- End Message ---
--- Begin Message ---
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


--- End Message ---
--- Begin Message ---
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]

--- End Message ---
--- Begin Message ---
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]
> 


--- End Message ---
--- Begin Message ---
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


--- End Message ---
--- Begin Message ---
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 ) { 


--- End Message ---
--- Begin Message ---
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



--- End Message ---
--- Begin Message ---
On Sat, Oct 24, 2009 at 7:59 AM, Ashley Sheridan
<a...@ashleysheridan.co.uk>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

--- End Message ---
--- Begin Message ---
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?

<?php
if ( isset($_SESSION['order']) ) {
#customer has begun creating order

foreach ($_SESSION['order'] AS $key => $value ) { 
echo "Product: " . $key . " Quantity: " .
$_SESSION['order'][$key]['quantity'] . "<br>\r\n";
}

} else {
#no products selected

echo "<ul class=\"lists\">\r\n";
echo "<li>Your shopping cart is empty</li>\r\n";
echo "</ul>\r\n";

}

-----Original Message-----
From: Martin Scotta <martinsco...@gmail.com>
To: a...@ashleysheridan.co.uk
Cc: ron.pigg...@actsministries.org, PHP General
<php-gene...@lists.php.net>
Subject: Re: [PHP] Array
Date: Sat, 24 Oct 2009 11:50:14 -0300



On Sat, Oct 24, 2009 at 7:59 AM, Ashley Sheridan
<a...@ashleysheridan.co.uk> 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

--- End Message ---
--- Begin Message ---
AHH.  The count() command does the trick.  Ron

-----Original Message-----
From: Ron Piggott <ron.pigg...@actsministries.org>
Reply-to: ron.pigg...@actsministries.org
To: Martin Scotta <martinsco...@gmail.com>, phps...@gmail.com
Cc: a...@ashleysheridan.co.uk, PHP General <php-gene...@lists.php.net>
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?

<?php
if ( isset($_SESSION['order']) ) {
#customer has begun creating order

foreach ($_SESSION['order'] AS $key => $value ) { 
echo "Product: " . $key . " Quantity: " .
$_SESSION['order'][$key]['quantity'] . "<br>\r\n";
}

} else {
#no products selected

echo "<ul class=\"lists\">\r\n";
echo "<li>Your shopping cart is empty</li>\r\n";
echo "</ul>\r\n";

}

-----Original Message-----
From: Martin Scotta <martinsco...@gmail.com>
To: a...@ashleysheridan.co.uk
Cc: ron.pigg...@actsministries.org, PHP General
<php-gene...@lists.php.net>
Subject: Re: [PHP] Array
Date: Sat, 24 Oct 2009 11:50:14 -0300



On Sat, Oct 24, 2009 at 7:59 AM, Ashley Sheridan
<a...@ashleysheridan.co.uk> 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


--- End Message ---
--- Begin Message ---
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?
> 
> <?php
> if ( isset($_SESSION['order']) ) {
> #customer has begun creating order
> 
> foreach ($_SESSION['order'] AS $key => $value ) { 
> echo "Product: " . $key . " Quantity: " .
> $_SESSION['order'][$key]['quantity'] . "<br>\r\n";
> }
> 
> } else {
> #no products selected
> 
> echo "<ul class=\"lists\">\r\n";
> echo "<li>Your shopping cart is empty</li>\r\n";
> echo "</ul>\r\n";
> 
> }
> 

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

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

--- End Message ---
--- Begin Message ---
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?

<?php
if ( isset($_SESSION['order']) ) {
#customer has begun creating order

foreach ($_SESSION['order'] AS $key => $value ) { echo "Product: " . $key . " Quantity: " .
$_SESSION['order'][$key]['quantity'] . "<br>\r\n";
}

} else {
#no products selected

echo "<ul class=\"lists\">\r\n";
echo "<li>Your shopping cart is empty</li>\r\n";
echo "</ul>\r\n";

}


Try this

<?php

...

if ( isset($_SESSION['order']) &&    # Does it exist
     is_array($_SESSION['order']) && # Is it an array
     count($_SESSION['order']) > 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']}<br>\r\n";
    }

} else {
    #no products selected
    echo "<ul class=\"lists\">\r\n";
    echo "<li>Your shopping cart is empty</li>\r\n";
    echo "</ul>\r\n";
}


...

?>

-----Original Message-----
From: Martin Scotta <martinsco...@gmail.com>
To: a...@ashleysheridan.co.uk
Cc: ron.pigg...@actsministries.org, PHP General
<php-gene...@lists.php.net>
Subject: Re: [PHP] Array
Date: Sat, 24 Oct 2009 11:50:14 -0300



On Sat, Oct 24, 2009 at 7:59 AM, Ashley Sheridan
<a...@ashleysheridan.co.uk> 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

--- End Message ---
--- Begin Message ---
Instead of doing:

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

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

Ron


--- End Message ---
--- Begin Message ---
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



--- End Message ---
--- Begin Message ---
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 <a...@ashleysheridan.co.uk>
Reply-to: a...@ashleysheridan.co.uk
To: ron....@actsministries.org
Cc: PHP General <php-gene...@lists.php.net>
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




--- End Message ---
--- Begin Message --- 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 <ron....@actsministries.org> 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 <a...@ashleysheridan.co.uk>
Reply-to: a...@ashleysheridan.co.uk
To: ron....@actsministries.org
Cc: PHP General <php-gene...@lists.php.net>
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




--- End Message ---
--- Begin Message ---
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

--- End Message ---
--- Begin Message --- 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.

--- End Message ---

Reply via email to