php-general Digest 13 Aug 2008 20:07:28 -0000 Issue 5622

Topics (messages 278021 through 278054):

Re: More math fun
        278021 by: Robert Cummings
        278027 by: Jay Blanchard
        278032 by: Jim Lucas
        278049 by: Robert Cummings

Re: If Column Exists
        278022 by: Per Jessen
        278024 by: Robin Vickery
        278050 by: VamVan

Anyone using Lighttpd + webdav and a PHP handler?
        278023 by: mike

Re: A dumb question regarding sending email
        278025 by: tedd
        278029 by: Richard Heyes
        278031 by: Ross McKay
        278035 by: Jonesy
        278039 by: Richard Heyes
        278042 by: Richard Heyes
        278046 by: tedd

SOAP - return a list of items
        278026 by: Dan Joseph
        278033 by: Dan Joseph

phpguru.org back up
        278028 by: Richard Heyes
        278030 by: David Giragosian
        278034 by: Wolf
        278036 by: Richard Heyes
        278037 by: Richard Heyes
        278038 by: Richard Heyes
        278040 by: Ashley M. Kirchner
        278041 by: Wolf
        278043 by: Richard Heyes
        278044 by: Richard Heyes
        278045 by: Stut
        278047 by: Richard Heyes
        278048 by: tedd
        278052 by: Stut

Class diagram util
        278051 by: Christoph Boget
        278053 by: Nathan Nobbe

regex
        278054 by: Philip Thompson

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 ---
On Wed, 2008-08-13 at 08:14 +0100, Alex Chamberlain wrote:
> 1.7763568394E-15 is 0. The computer just had a rounding error somewhere. We
> had this discussion a few weeks ago, the solution being to decide to what
> accuracy you want the answer. Upto 14 decimal places will give you 0 here!!

I thought we had a different discussion a couple of weeks ago about
floating point storage precision. How come only Jay is getting *this*
rounding error?

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
[snip]
> 1.7763568394E-15 is 0. The computer just had a rounding error
somewhere. We
> had this discussion a few weeks ago, the solution being to decide to
what
> accuracy you want the answer. Upto 14 decimal places will give you 0
here!!

I thought we had a different discussion a couple of weeks ago about
floating point storage precision. How come only Jay is getting *this*
rounding error?
[/snip]

Perhaps it is the PHP version? I have tried this on three separate PHP
installations (all the same configs) and got the same results. I will
look to see if there is an upgraded version.

When applying round to the numbers everything works out as expected, but
makes me uncomfortable.

--- End Message ---
--- Begin Message ---
Jay Blanchard wrote:
[snip]
1.7763568394E-15 is 0. The computer just had a rounding error
somewhere. We
had this discussion a few weeks ago, the solution being to decide to
what
accuracy you want the answer. Upto 14 decimal places will give you 0
here!!

I thought we had a different discussion a couple of weeks ago about
floating point storage precision. How come only Jay is getting *this*
rounding error?
[/snip]

Perhaps it is the PHP version? I have tried this on three separate PHP
installations (all the same configs) and got the same results. I will
look to see if there is an upgraded version.

When applying round to the numbers everything works out as expected, but
makes me uncomfortable.


What is your precision in your php.ini file set to? Default is 14. If it is set to 16 or greater, then it would display the reseults you are seeing. Mine is set to 14, so it would automatically round it to 0. I think.

I will test, brb......

hmmm weird, if I set my precision to 20 and restart, I still get 0 for the value. Odd, I would have thought it would have then shown me the expected 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 ---
On Wed, 2008-08-13 at 07:47 -0700, Jim Lucas wrote:
> Jay Blanchard wrote:
> > [snip]
> >> 1.7763568394E-15 is 0. The computer just had a rounding error
> > somewhere. We
> >> had this discussion a few weeks ago, the solution being to decide to
> > what
> >> accuracy you want the answer. Upto 14 decimal places will give you 0
> > here!!
> > 
> > I thought we had a different discussion a couple of weeks ago about
> > floating point storage precision. How come only Jay is getting *this*
> > rounding error?
> > [/snip]
> > 
> > Perhaps it is the PHP version? I have tried this on three separate PHP
> > installations (all the same configs) and got the same results. I will
> > look to see if there is an upgraded version.
> > 
> > When applying round to the numbers everything works out as expected, but
> > makes me uncomfortable.
> > 
> 
> What is your precision in your php.ini file set to?  Default is 14.  If it is 
> set to 16 or greater, then it would display the reseults you are seeing.  
> Mine 
> is set to 14, so it would automatically round it to 0.  I think.
> 
> I will test, brb......
> 
> hmmm weird, if I set my precision to 20 and restart, I still get 0 for the 
> value.  Odd, I would have thought it would have then shown me the expected 
> value.

I tried the highest precision setting that PHP appears to honour... 54.
I still get 0 :)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
Jay Blanchard wrote:

> [snip]
> I am working on data migration for one mysql db to another using PHP.
> How do
> I check if a particular table has a particular column. If not alter...
> [/snip]
> 
> Use DESCRIBE TABLE;
> 

Then you'd have to parse the output - how about

SELECT <column> FROM <table> LIMIT 1  ?

The query will fail if the column doesn't exist.


/Per Jessen, Zürich


--- End Message ---
--- Begin Message ---
2008/8/12 VamVan <[EMAIL PROTECTED]>:
> Hello,
>
> I am working on data migration for one mysql db to another using PHP. How do
> I check if a particular table has a particular column. If not alter...
>
> Thanks
>

Use the information_schema:

SELECT COUNT(*) AS column_exists FROM information_schema.COLUMNS WHERE
TABLE_SCHEMA='db_name' AND TABLE_NAME='table_name' AND
COLUMN_NAME='column_name';

-robin

--- End Message ---
--- Begin Message ---
Interesting. Thanks guys!!

On Wed, Aug 13, 2008 at 1:32 AM, Robin Vickery <[EMAIL PROTECTED]> wrote:

> 2008/8/12 VamVan <[EMAIL PROTECTED]>:
> > Hello,
> >
> > I am working on data migration for one mysql db to another using PHP. How
> do
> > I check if a particular table has a particular column. If not alter...
> >
> > Thanks
> >
>
> Use the information_schema:
>
> SELECT COUNT(*) AS column_exists FROM information_schema.COLUMNS WHERE
> TABLE_SCHEMA='db_name' AND TABLE_NAME='table_name' AND
> COLUMN_NAME='column_name';
>
> -robin
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
i.e. using PUT and using a .php script as the handler for it?

I can successfully PUT a file to /path/to/file-that-doesnt-exist.txt

However, when I try to do a PUT to an existing .php script it gives me
access denied, most likely due to the fact that a file exists. I don't
want it to actually try overwriting the file, and is-readonly =
"enable" or "disable" doesn't seem to change this behavior...

Just wondering if anyone out there has done this.

I did it no problem in nginx using a .php handler and set DAV to
readonly - no issues whatsoever...

--- End Message ---
--- Begin Message ---
Hi gang:

Problem solved.

I was tired last night and used "http:www.example.com" and wondered why it wouldn't work. Duh!

I knew it was a dumb question that should have waited until I had a good night's sleep.

Cheers,

tedd


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

--- End Message ---
--- Begin Message ---
> NSW Australia

North, South, West? Can't you make up your mind? :-)

-- 
Richard Heyes

--- End Message ---
--- Begin Message ---
On Wed, 13 Aug 2008 15:32:12 +0100, Richard Heyes wrote:

>> NSW Australia
>
>North, South, West? Can't you make up your mind? :-)

:) we move around a bit... though not so much for a while now!

Good to see you backup. I mean, back up!

(NSW is the state of New South Wales, on the East Coast of Australia, or
IOW somewhat to the left of Kalifornia and down a bit)
-- 
Ross McKay, Toronto, NSW Australia
"Under the big bright yellow sun" - Fat Boy Slim

--- End Message ---
--- Begin Message ---
On Thu, 14 Aug 2008 00:47:39 +1000, Ross McKay wrote:
> On Wed, 13 Aug 2008 15:32:12 +0100, Richard Heyes wrote:
>
>>> NSW Australia
>>
>>North, South, West? Can't you make up your mind? :-)
>
>:) we move around a bit... though not so much for a while now!
>
> Good to see you backup. I mean, back up!
>
> (NSW is the state of New South Wales, on the East Coast of Australia, or
> IOW somewhat to the left of Kalifornia and down a bit)

I'd've thought with Aussie, Southern Cross-oriented globes, it would be 
to the _right_ of Kalifornia and _up_ a bit.

Jonesy


--- End Message ---
--- Begin Message ---
> I'd've thought with Aussie, Southern Cross-oriented globes

Charlaton. :-)

-- 
Richard Heyes
http://www.phpguru.org

--- End Message ---
--- Begin Message ---
> Good to see you backup. I mean, back up!

I think both would apply now... :-)

-- 
Richard Heyes
http://www.phpguru.org

--- End Message ---
--- Begin Message ---
At 12:47 AM +1000 8/14/08, Ross McKay wrote:
On Wed, 13 Aug 2008 15:32:12 +0100, Richard Heyes wrote:

 NSW Australia

North, South, West? Can't you make up your mind? :-)

:) we move around a bit... though not so much for a while now!

Good to see you backup. I mean, back up!

(NSW is the state of New South Wales, on the East Coast of Australia, or
IOW somewhat to the left of Kalifornia and down a bit)


So, you could say NSWE Australia.

Reminds me of a logo I designed for a NEWS publication.

Cheers,

tedd

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

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

I am using the PHP5 SOAP Functions...

I am trying to find some information on how to properly build a function
into my web service to return a list of quotes.  Each list will have a
QuoteID, Origin, Destination, Name.  Example:

1011, 48167, 90222, John Smith
1012, 54888, 19893, Joe Johnson
etc...

>From everything I read, I just need to build an array with this information,
and return it to the SOAP client trying to get the information.  I think the
problem lies in my WSDL, I am certain I need to setup a complexType that
handles the arrayType.  Unfortunately, I cannot find any resources on how to
setup the WSDL.

Can someone point in the direction to get going on this?  Anyone have an
example WSDL that handles this type of thing that I could look at?

-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."

--- End Message ---
--- Begin Message ---
Maybe more info will help:

Here is what I have so far for the WSDL...

    <xsd:complexType name="getQuoteHistory">
        <xsd:all>
            <xsd:element name="id" type="xsd:string"/>
            <xsd:element name="key" type="xsd:string"/>
            <xsd:element name="username" type="xsd:string"/>
            <xsd:element name="password" type="xsd:string"/>
        </xsd:all>
    </xsd:complexType>

    <xsd:complexType name="getQuoteHistoryResponse">
        <xsd:sequence>
            <xsd:element minOccurs="0" maxOccurs="1" name="getQuoteResult"
type="tns:ArrayOfgetQuoteHistoryResult" />
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="ArrayOfgetQuoteHistoryResult">
        <xsd:sequence>
            <xsd:element minOccurs="0" maxOccurs="unbounded"
name="getQuoteHistoryResult" nillable="true"
type="tns:getQuoteHistoryResult" />
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="getQuoteHistoryResult">
        <xsd:sequence>
            <xsd:element name="success" type="xsd:boolean"/>
            <xsd:element name="message" type="xsd:string"/>
            <xsd:element name="quoteid" type="xsd:string"/>
            <xsd:element name="dateentered" type="xsd:string"/>
            <xsd:element name="expirationdate" type="xsd:string"/>
            <xsd:element name="origin" type="xsd:string"/>
            <xsd:element name="destination" type="xsd:string"/>
            <xsd:element name="vehicle_type" type="xsd:string"/>
            <xsd:element name="price" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>

This validates fine in soapUI, and seems to work fine when the client
connects to it.

The piece from PHP:

            $count = 0;

            while ( $data = $this->dbconn->fetchrow( $res ) )
            {
                foreach ( $data as $key => $value )
                {
                    $quotes[$count][$key] = $value;
                }

                $count++;
            }

return $quotes;

This is the soap response:

<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="
http://schemas.xmlsoap.org/soap/encoding/"; xmlns:SOAP-ENV="
http://schemas.xmlsoap.org/soap/envelope/"; xmlns:ns1="urn:ursquoteservice"
xmlns:ns2="urn:ursquote" xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:SOAP-ENC="
http://schemas.xmlsoap.org/soap/encoding/";>
   <SOAP-ENV:Body>
      <ns1:getQuoteHistoryResponse>
         <getquotehistoryresponse xsi:type="ns2:getQuoteHistoryResponse"/>
      </ns1:getQuoteHistoryResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

It seems like I am just missing something somewhere.

Anyone able to help?

-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."

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

You'll be pleased to know (I'm sure) that phpguru.org is back up and
working (for the most part I would imagine).

-- 
Richard Heyes
http://www.phpguru.org

--- End Message ---
--- Begin Message ---
On 8/13/08, Richard Heyes <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> You'll be pleased to know (I'm sure) that phpguru.org is back up and
> working (for the most part I would imagine).


Congratulations, Richard.

Server crashes, data loss, and downtime are concerns for all of us.

--David.

--- End Message ---
--- Begin Message ---
---- Richard Heyes <[EMAIL PROTECTED]> wrote: 
> Hi,
> 
> You'll be pleased to know (I'm sure) that phpguru.org is back up and
> working (for the most part I would imagine).

Glad to hear it!

So, which backup solution are you using?  Or should I say which 12 backup 
solutions?  ;)

Wolf

--- End Message ---
--- Begin Message ---
> Congratulations, Richard.
>
> Server crashes, data loss, and downtime are concerns for all of us.

Thanks. Fortunately I managed to get away with minimal data loss, and,
unsurprisingly, I've now got backups. :-)

-- 
Richard Heyes
http://www.phpguru.org

--- End Message ---
--- Begin Message ---
> Really? It doesn't work for me.
>
> http://www.phpguru.org/
>
>
> I'm getting the following :
>
> Unable to connect
> Firefox can't establish a connection to the server at www.phpguru.org.
>     *   The site could be temporarily unavailable or too busy. Try again in
> a few
>           moments.
>     *   If you are unable to load any pages, check your computer's network
>           connection.
>     *   If your computer or network is protected by a firewall or proxy,
> make sure
>           that Firefox is permitted to access the Web.
>
>
> Looks like it resolves to an IP (67.205.76.91), which I can ping, but the
> server isn't returning a HTTP response.
>
> Although... I might be resolving to an old IP, checking on another
> connection resolves to 217.160.188.12, which seems to work.
> Guess the DNS change is still propagating.

IDD. The 217. is the correct one. If you really wanted to you could
mung your hosts file. I'm guessing you don't though...

-- 
Richard Heyes
http://www.phpguru.org

--- End Message ---
--- Begin Message ---
> So, which backup solution are you using?  Or should I say which 12 backup 
> solutions?  ;)

Lol. Not that sophisticated actually, trusty old tar and gzip, along
with regular downloads to my desktop so that they're in two locations.

-- 
Richard Heyes
http://www.phpguru.org

--- End Message ---
--- Begin Message ---
Richard Heyes wrote:
Lol. Not that sophisticated actually, trusty old tar and gzip, along
with regular downloads to my desktop so that they're in two locations
If I may suggest ... if you have a second system that doesn't have a big load, you can simply rsync the data from one to the other every 24 hours or however many times you want. This way, when your primary system bites the dust, you can easily switch to the backup one and keep running while you work on the primary one.

--
H | It's not a bug - it's an undocumented feature.
 +--------------------------------------------------------------------
 Ashley M. Kirchner <mailto:[EMAIL PROTECTED]>   .   303.442.6410 x130
 IT Director / SysAdmin / Websmith             .     800.441.3873 x130
 Photo Craft Imaging                       .     3550 Arapahoe Ave. #6
http://www.pcraft.com ..... . . . Boulder, CO 80303, U.S.A.
--- End Message ---
--- Begin Message ---
---- Richard Heyes <[EMAIL PROTECTED]> wrote: 
> > So, which backup solution are you using?  Or should I say which 12 backup 
> > solutions?  ;)
> 
> Lol. Not that sophisticated actually, trusty old tar and gzip, along
> with regular downloads to my desktop so that they're in two locations.

Before I got smart in locking down my forms, someone tried to hack my site.  
They got some of the files but not all.  Luckily the ones they got were ones 
that I had backups of.  Only it took me a couple of days to FIND them.  Now my 
DBs back themselves up hourly and my full site goes tar as well.  And the forms 
are fully secured out.  :)

--- End Message ---
--- Begin Message ---
> And the forms are fully secured out.  :)
>

You think... ;-)

-- 
Richard Heyes
http://www.phpguru.org

--- End Message ---
--- Begin Message ---
>   If I may suggest ... if you have a second system that doesn't have a big
> load, you can simply rsync the data from one to the other every 24 hours or
> however many times you want.  This way, when your primary system bites the
> dust, you can easily switch to the backup one and keep running while you
> work on the primary one.

Good for something that generates money, but not for my personal stuff
which I'm not too fussed about.

-- 
Richard Heyes
http://www.phpguru.org

--- End Message ---
--- Begin Message ---
On 13 Aug 2008, at 17:26, Richard Heyes wrote:
If I may suggest ... if you have a second system that doesn't have a big load, you can simply rsync the data from one to the other every 24 hours or however many times you want. This way, when your primary system bites the dust, you can easily switch to the backup one and keep running while you
work on the primary one.

Good for something that generates money, but not for my personal stuff
which I'm not too fussed about.

I would recommend http://www.rsync.net/ for this. They're pretty cheap ($1.60/GB/month), very reliable and their support is top-notch. If you need it you can pay a tiny bit extra ($2.80/GB/month) and get geo- redundant storage. They also have discounts if you need more than 25GB.

I am not affiliated with them in any way, but I've been using the service since it launched and have never had a problem.

-Stut

--
http://stut.net/

--- End Message ---
--- Begin Message ---
> but I've been using the service
> since it launched and have never had a problem.

Out of interest, when was that?

-- 
Richard Heyes
http://www.phpguru.org

--- End Message ---
--- Begin Message ---
At 5:04 PM +0100 8/13/08, Richard Heyes wrote:
Thanks. Fortunately I managed to get away with minimal data loss, and,
unsurprisingly, I've now got backups. :-)

--
Richard Heyes


That's good to hear -- on both counts.

Cheers,

tedd

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

--- End Message ---
--- Begin Message ---
On 13 Aug 2008, at 17:39, Richard Heyes wrote:
but I've been using the service
since it launched and have never had a problem.

Out of interest, when was that?

Now you're asking... I think it was around April 2006 but if I'm honest I can't remember. Prior to that I was using a hosting company called JohnCompanies.com and rsync.net was created by them. Based on the superior reliability and support for the hosting I immediately jumped on remote storage by the same guys.

-Stut

--
http://stut.net/

--- End Message ---
--- Begin Message ---
I'm curious, what utilities do you guys use, if any at all, to map
out/diagram your classes?  I'm looking for a decent (I don't really
need a ton of bells and whistles) freeware app but my searches thus
far have proven fruitless.

thnx,
Christoph

--- End Message ---
--- Begin Message ---
On Wed, Aug 13, 2008 at 11:33 AM, Christoph Boget <[EMAIL PROTECTED]> wrote:

> I'm curious, what utilities do you guys use, if any at all, to map
> out/diagram your classes?  I'm looking for a decent (I don't really
> need a ton of bells and whistles) freeware app but my searches thus
> far have proven fruitless.


on linux, dia is a classic ;)  however you will also find kivio (a kde dia
wrapper) and umbrello available.

-nathan

--- End Message ---
--- Begin Message ---
<?php
function blegh ($subject) {
  // I know this pattern doesn't exactly work
  $pattern = '/(.*).php\?action=([^&].*)/';
  preg_match ($pattern, $subject, $matches);
  return $matches;
}

blegh ('somePage.php?action=doSomething&id=');
?>

Ok, the important parts that I need to obtain from this are:

somePage
doSomething

How can you modify the pattern above to grab the action appropriately? Sorry, my regex is a lil rusty!

Thanks in advance,
~Phil

--- End Message ---

Reply via email to