php-general Digest 17 Aug 2008 06:51:22 -0000 Issue 5628

Topics (messages 278227 through 278238):

Licensing
        278227 by: Richard Heyes
        278228 by: Eric Butera
        278230 by: Matty Sarro

Re: SESSION problem
        278229 by: Eric Butera
        278231 by: Ashley Sheridan
        278232 by: tedd
        278233 by: Stut
        278234 by: Sabine Richter
        278235 by: tedd
        278236 by: tedd
        278237 by: Sabine Richter

Re: import XLS sheet into DB
        278238 by: Simcha

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

Don't think me a money grabbing bast (well, I guess I am...) but I'd
just like to know if you've got any input on trying to get people to
cough up some readies in return for the mounds of free code I give
away. I've updated my licensing page just now, and hopefully this will
convince more people to buy one:
http://www.phpguru.org/static/license.html

Thanks for any pointers.

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

--- End Message ---
--- Begin Message ---
On Sat, Aug 16, 2008 at 10:34 AM, Richard Heyes <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Don't think me a money grabbing bast (well, I guess I am...) but I'd
> just like to know if you've got any input on trying to get people to
> cough up some readies in return for the mounds of free code I give
> away. I've updated my licensing page just now, and hopefully this will
> convince more people to buy one:
> http://www.phpguru.org/static/license.html
>
> Thanks for any pointers.
>
> --
> Richard Heyes
> http://www.phpguru.org

Sell support like everyone else does.

--- End Message ---
--- Begin Message ---
Sell support.
Sell obfuscated code.
Sell your software but make the source available upon sale (completely
allowed under all open source licenses).

On Sat, Aug 16, 2008 at 10:47 AM, Eric Butera <[EMAIL PROTECTED]> wrote:

> On Sat, Aug 16, 2008 at 10:34 AM, Richard Heyes <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > Don't think me a money grabbing bast (well, I guess I am...) but I'd
> > just like to know if you've got any input on trying to get people to
> > cough up some readies in return for the mounds of free code I give
> > away. I've updated my licensing page just now, and hopefully this will
> > convince more people to buy one:
> > http://www.phpguru.org/static/license.html
> >
> > Thanks for any pointers.
> >
> > --
> > Richard Heyes
> > http://www.phpguru.org
>
> Sell support like everyone else does.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Sat, Aug 16, 2008 at 10:06 AM, Stut <[EMAIL PROTECTED]> wrote:
> I wish I understood the reason why it's like this but I've never looked into
> the session extension in that level of detail, but I doubt such a limitation
> would exist if there was not a very good reason for it. But again, I don't
> see how this is relevant.
>
> It's natural to me to see the session array as a filing cabinet. At the top
> level you would have files with names that indicate what they are. Within
> each file it may be further divided into numbered sections. Given that I
> can't see into the future, even if I currently only have one set of data
> (file) to store in the session (the filing cabinet) I wouldn't just chuck
> the bits of paper from the file into the filing cabinet. I'd leave them in
> the file such that when I need to add a new file I don't need to gather up
> all the other bit of paper into a single file to get it organised again.
>
> Ok, that didn't quite make it as clear as I wanted it to but I hope it
> illustrates the point I'm trying to make. The root level of the session
> array (IMHO) should contain descriptive keys, and I've never been in a
> situation where 5318008 is descriptive and gives context to the data unless
> you turn it upside down!
>
> -Stut
>
> --
> http://stut.net/

Just to add on a thought...  The session extension is a global
variable.  We should make sure our applications play nicely with any
other piece of code.  We do this by prefixing our functions and
classes with something to fake namespaces.  The same ideas carry over
to any other global construct.  So at the very least if I am using the
session class I will have $_SESSION['appname'] as my base.  Same goes
for $GLOBALS, etc.

--- End Message ---
--- Begin Message ---
I tend to prefer assigning all my session variables to an array, which
itself is a member of the $_SESSION array. For example:

$_SESSION[]
Array
(
        [myarray] => Array
                (
                        [someitem] => x
                        [someitem2] => y
                        [someitem3] => z
                )
)


Ash
www.ashleysheridan.co.uk
--- Begin Message ---
On Sat, Aug 16, 2008 at 10:06 AM, Stut <[EMAIL PROTECTED]> wrote:
> I wish I understood the reason why it's like this but I've never looked into
> the session extension in that level of detail, but I doubt such a limitation
> would exist if there was not a very good reason for it. But again, I don't
> see how this is relevant.
>
> It's natural to me to see the session array as a filing cabinet. At the top
> level you would have files with names that indicate what they are. Within
> each file it may be further divided into numbered sections. Given that I
> can't see into the future, even if I currently only have one set of data
> (file) to store in the session (the filing cabinet) I wouldn't just chuck
> the bits of paper from the file into the filing cabinet. I'd leave them in
> the file such that when I need to add a new file I don't need to gather up
> all the other bit of paper into a single file to get it organised again.
>
> Ok, that didn't quite make it as clear as I wanted it to but I hope it
> illustrates the point I'm trying to make. The root level of the session
> array (IMHO) should contain descriptive keys, and I've never been in a
> situation where 5318008 is descriptive and gives context to the data unless
> you turn it upside down!
>
> -Stut
>
> --
> http://stut.net/

Just to add on a thought...  The session extension is a global
variable.  We should make sure our applications play nicely with any
other piece of code.  We do this by prefixing our functions and
classes with something to fake namespaces.  The same ideas carry over
to any other global construct.  So at the very least if I am using the
session class I will have $_SESSION['appname'] as my base.  Same goes
for $GLOBALS, etc.

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


--- End Message ---

--- End Message ---
--- Begin Message ---
At 3:06 PM +0100 8/16/08, Stut wrote:
Not really, since I would never name a session variable 1, or 2, or 5318008 - I would always put those in the session in a named array.

That's understandable. But, if you came from a background that predated associate arrays, then using numeric indexes would seem more natural. To me arrays come in two types, those with numeric indexes and those with string indexes. I use both.

I wish I understood the reason why it's like this but I've never looked into the session extension in that level of detail, but I doubt such a limitation would exist if there was not a very good reason for it. But again, I don't see how this is relevant.

I never said it was relevant.

I am sure too that whatever the reason was, it made sense at the time and for the problem of the time -- similar to the a1 < z discussion of a couple of years back.

It's natural to me to see the session array as a filing cabinet. At the top level you would have files with names that indicate what they are. Within each file it may be further divided into numbered sections. Given that I can't see into the future, even if I currently only have one set of data (file) to store in the session (the filing cabinet) I wouldn't just chuck the bits of paper from the file into the filing cabinet. I'd leave them in the file such that when I need to add a new file I don't need to gather up all the other bit of paper into a single file to get it organised again.

Ok, that didn't quite make it as clear as I wanted it to but I hope it illustrates the point I'm trying to make. The root level of the session array (IMHO) should contain descriptive keys, and I've never been in a situation where 5318008 is descriptive and gives context to the data unless you turn it upside down!

I understand what you are saying -- semantics are important. But if there is a need for temporary place to store values I don't consider it bad form to store them in a numerically indexed array.

For example, if a user was going to purchase up to 10 items, I see nothing wrong is using:

user_purchase[0] = $item0;
...
user_purchase[9] = $item9;

And as such, one can easily extract what the user purchased by simply using for().

However, in this case I don't see the gain provided by using:

user_purchase['item1'] = $item0;
...
user_purchase['item9'] = $item9;

But that distinction would be required IF you were using SESSIONs. And that's one of my points -- normal arrays come in two types and the SESSION array don't.

Cheers,

tedd


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

--- End Message ---
--- Begin Message ---
On 16 Aug 2008, at 17:03, tedd wrote:
I understand what you are saying -- semantics are important. But if there is a need for temporary place to store values I don't consider it bad form to store them in a numerically indexed array.

For example, if a user was going to purchase up to 10 items, I see nothing wrong is using:

user_purchase[0] = $item0;
...
user_purchase[9] = $item9;

And as such, one can easily extract what the user purchased by simply using for().

However, in this case I don't see the gain provided by using:

user_purchase['item1'] = $item0;
...
user_purchase['item9'] = $item9;

But that distinction would be required IF you were using SESSIONs. And that's one of my points -- normal arrays come in two types and the SESSION array don't.

I think you're missing the core of my point. My point only refers to the root level of the $_SESSION array. I have no problem with using numerically-indexed arrays elsewhere - I come from a C background so it's where I started too and frequently use them.

However, in the example above you would not use...

$_SESSION[0] = $item0;
...
$_SESSION[9] = $item9;

Instead I assert you would have...

$_SESSION['user_purchase'][0] = $item0;
...
$_SESSION['user_purchase'][9] = $item9;

which is perfectly valid.

I'll try to re-word my basic point... I personally consider it bad to even want to use numeric indexes at the root level of the $_SESSION array because it creates data with no context in a globally accessible location.

-Stut

--
http://stut.net/

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

tedd schrieb:
At 2:45 PM +0200 8/16/08, Sabine Richter wrote:
Yes, our mails overlaped each other (Do you say that in english? My english is not the best.)

Sabine:

Your English is fine -- much better than my de for certain.
Thanks :-)

By the way: I tried your initial code and I had no problem with the variable declared after the numeric ones. (your $_SESSION['test']). I tried on a Version 5.2.5 an Win XP.

That's interesting.

Let's make sure we're talking about the same thing here.

This is the demo:

http://www.webbytedd.com/b2/session-test1/index.php

In my browser Step 1 shows:

SESSION[20] => good morning
SESSION[test2] => good night

In Step 2:

Neither are there.

Is that what you see?

I tried the script from your first example on http://www.webbytedd.com/b2/session-test/index1.php

I just deleted the header and footer includes and set the error reporting to E_ALL.

That's what I get:

index.php:
f411abf8cb6cb7e0f2d091251c1906dd
Step 1 -- SESSIONs Recorded
1 = 1
2 = 2
3 = 3
4 = 4
5 = 5
6 = 6
7 = 7
8 = 8
9 = 9
10 = 10
hello

Code:

<?php
// Session problem tedd sperling, php liste 15.08.2008

ini_set('error_reporting', E_ALL );



    if (session_id() == "")
        {
        session_start();
        }

    echo(session_id());

    for ($i = 1; $i <= 10; $i++)
        {
        $_SESSION[$i] = $i;
        }

    $_SESSION['test'] = 'hello';

?>


        <h1>Step 1 -- SESSIONs Recorded</h1>

<?php
        for ($i = 1; $i <= 10; $i++)
            {
            echo("$i = $_SESSION[$i] <br/>");
            }

        echo($_SESSION['test']);

?>

    <br/>
    <br/>

    <form action="index1.php" method="post">

        <input type="submit" value="Proceed to Step 2">

    </form>

    <hr/>
    Code:
    <br/>
    <br/>

    <?php highlight_file ("index.php"); ?>


Notice: Unknown: Skipping numeric key 1. in Unknown on line 0

Notice: Unknown: Skipping numeric key 2. in Unknown on line 0

Notice: Unknown: Skipping numeric key 3. in Unknown on line 0

Notice: Unknown: Skipping numeric key 4. in Unknown on line 0

Notice: Unknown: Skipping numeric key 5. in Unknown on line 0

Notice: Unknown: Skipping numeric key 6. in Unknown on line 0

Notice: Unknown: Skipping numeric key 7. in Unknown on line 0

Notice: Unknown: Skipping numeric key 8. in Unknown on line 0

Notice: Unknown: Skipping numeric key 9. in Unknown on line 0

Notice: Unknown: Skipping numeric key 10. in Unknown on line 0


index1.php:
f411abf8cb6cb7e0f2d091251c1906dd
Step 2 -- Results of SESSIONs passed

Notice: Undefined offset: 1 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21
1 =

Notice: Undefined offset: 2 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21
2 =

Notice: Undefined offset: 3 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21
3 =

Notice: Undefined offset: 4 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21
4 =

Notice: Undefined offset: 5 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21
5 =

Notice: Undefined offset: 6 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21
6 =

Notice: Undefined offset: 7 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21
7 =

Notice: Undefined offset: 8 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21
8 =

Notice: Undefined offset: 9 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21
9 =

Notice: Undefined offset: 10 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21
10 =
hello

Code:

<?php
// Session problem tedd sperling, php liste 15.08.2008
ini_set('error_reporting', E_ALL );


    if (session_id() == "")
        {
        session_start();
        }

    echo(session_id());

?>


        <h1>Step 2 -- Results of SESSIONs passed</h1>

<?php
        for ($i = 1; $i <= 10; $i++)
            {
            echo("$i = $_SESSION[$i] <br/>");
            }

        echo($_SESSION['test']);



?>

    <br/>
    <br/>

    <form action="index.php" method="post">

        <input type="submit" value="Go Back to Step 1">

    </form>

    <hr/>
    Code:
    <br/>
    <br/>

    <?php highlight_file ("index1.php"); ?>


You see, I get the content of $_SESSION['test'] in index1.php.
It's the same as in your second example, isn't it?
I would try your second example too, but you highlighted the code of index.php in index1.php too. So I can't.




Cheers
Sabine





Cheers,

tedd



--- End Message ---
--- Begin Message ---
At 5:15 PM +0100 8/16/08, Stut wrote:
Instead I assert you would have...

$_SESSION['user_purchase'][0] = $item0;
...
$_SESSION['user_purchase'][9] = $item9;

which is perfectly valid.

I'll try to re-word my basic point... I personally consider it bad to even want to use numeric indexes at the root level of the $_SESSION array because it creates data with no context in a globally accessible location.


Ahhh, I see with what you're saying -- that's a good point.

For my temp variables, I should have used some like:

$_SESSION['tedd_temps'][0] = $item0;
...
$_SESSION['tedd_temps'][9] = $item9;

That would have fit much better if I had been programming in a group.

Thanks for taking the time to explain that.

Cheers,

tedd


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

--- End Message ---
--- Begin Message ---
Sabine:

I understand the problem now.

But to get to my basic question to you, namely using this link:

http://www.webbytedd.com/b2/session-test1/index.php

-- does SESSION[20] and SESSION[test2] show anything in the second step (Step 2) or are the results blank?

Cheers,

tedd

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

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


tedd schrieb:
Sabine:

I understand the problem now.

But to get to my basic question to you, namely using this link:

http://www.webbytedd.com/b2/session-test1/index.php

-- does SESSION[20] and SESSION[test2] show anything in the second step (Step 2) or are the results blank?

Oh, ok, when I just call your URL: they are both blank!

Cheers,
Sabine

Cheers,

tedd


--- End Message ---
--- Begin Message ---
Try using:
http://sourceforge.net/docman/display_doc.php?docid=22092&group_id=99160


I have never used it, but it looks very straightforward. Docs are here: 
http://sourceforge.net/docman/display_doc.php?docid=22092&group_id=99160

        
code should be something like this: (for mysql, based on docs)
<?php
include('reader.php');
//Make an instance of the class:
$xl_reader = new Spreadsheet_Excel_Reader();
$xl_reader->read("filename.xls");
$data = $xl_reader->sheets[0]['cells'];
Foreach($cells as $c){
        foreach($c as $cd) $row[] = "\"".$cd."\"";
        $row = implode(",", $row);
        mysql_query("insert into `table` values(".$row.")");
        }
?>


-----Original Message-----
From: Jason Pruim [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 15, 2008 12:29 PM
To: Alain R.
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] import XLS sheet into DB


On Aug 15, 2008, at 4:29 AM, Alain R. wrote:

> Hi,
>
> I would like to import content of an XLS sheet into a PostgreSQL DB  
> (table).
>
> How can i do that ?
> thanks a lot,
>
> A.

Alain,

I haven't done it with PostgreSQL... But assuming it's not far from  
MySQL just save the excel file as a csv, or a tab separated file and  
import that. If you find away to import a strict xls file let me know,  
I have a project that could really benefit from that :)


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]





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

No virus found in this incoming message.
Checked by AVG - http://www.avg.com 
Version: 8.0.138 / Virus Database: 270.6.3/1612 - Release Date: 14/08/2008
18:03


--- End Message ---

Reply via email to