Re: [PHP] OOP slow -- am I an idiot?

2006-10-13 Thread John Wells

On 10/13/06, Stut [EMAIL PROTECTED] wrote:

Ed Lazor wrote:
 ...Or is it something else entirely; I dunno, maybe
 UserCollection has a property defined as an array of User class?  I
 think that's what people were saying earlier in the thread as being a
 very bad thing in terms of memory utilization, etc.


I'm honestly having a difficult time thinking of any way *other* than
having an array of User objects.  In previous projects I've tried the
route of (like Richard mentioned early on):

class Customers {
   var $ids = array();
   var $names = array();
}

But found it very cumbersome and unintuitive when dealing with a
single Customer.  Moreso I got lost when I didn't know if I were
dealing with one or many customers...

As soon as I went to a Customer and CustomerCollection approach, I was
able to make sense of it all.  Even though CustomerCollection usually
didn't actually exist, except conceptually as an array of Customer
objects within my application code.  Like Stut suggested, I too have
static fetch functions derived from the base ActiveRecord class that
return arrays of objects.

Maybe all of my applications have been simple enough in that I
tended to work on single objects 95% of the time, and therefore
creating interfaces for those single objects made sense.  I think
that's what Ed means by situational?

It is occuring to me that perhaps all of my bias is centered around
the fact that I always create my models as children of an ActiveRecord
class, which is by nature based on *one record* of a table.

Is there an ActiveTable class that, if implemented, might completely
change everything???

Until then, I'm not convinced: constructing a basic building block
such as a Customer, and then an aggregate block such as a collection
of Customers, and so on, seems the most stable and scalable approach
almost without exception...and perhaps, with that, I'm revealing the
extent of my OOP naivety...

John W

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



Re: [PHP] need help to build a query

2006-10-10 Thread John Wells

On 10/10/06, Richard Lynch [EMAIL PROTECTED] wrote:


This is a lot more subtle problem than it seems at first glance, eh?


Yup, sure is.  Thanks for the detailed response, so helpful as always.

-John W



--
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?




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



Re: [PHP] need help to build a query

2006-10-09 Thread John Wells

On 10/9/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

but I know there must be much better solution then this one.


You're right: Simply JOIN your queries...

SELECT order_id, order_date, order_status, file_name
   FROM orders
   JOIN uploaded_files AS uf ON orders.order_id = uf.order_id
   ORDER BY orders.order_id DESC
   LIMIT 100

HTH,
John W




thanks for any help.

-afan

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




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



Re: [PHP] need help to build a query

2006-10-09 Thread John Wells

Yes you are right, but I guess you can decide which is worse: sending
extra data in one query or send extra queries.  I guess it depends on
how many records we're talking about...

Brad also brings up a good point I hadn't considered.  I do think an
OUTER join is possible, perhaps depending on your mysql version...

Which brings up something I had meant to say before, which is that
this isn't actually a PHP question... :)

John W

On 10/9/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

But, in this case I will have repeating order_date and order_status info?

idorder_datestatusfile_name
122006-10-09live  file1.jpg
122006-10-09live  file2.jpg
122006-10-09live  file3.jpg
132006-10-09live  file1.jpg
142006-10-09live  test.gif


right?


 On 10/9/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 but I know there must be much better solution then this one.

 You're right: Simply JOIN your queries...

 SELECT order_id, order_date, order_status, file_name
 FROM orders
 JOIN uploaded_files AS uf ON orders.order_id = uf.order_id
 ORDER BY orders.order_id DESC
 LIMIT 100

 HTH,
 John W



 thanks for any help.

 -afan

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







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



Re: [PHP] ECHO $variable

2006-10-08 Thread John Wells

On 10/9/06, benifactor [EMAIL PROTECTED] wrote:

the way i posted worked fine with out either... he doesn't need to use these
to format the way his output is displayed, he only needs to use the proper
php syntax if i am correct.


But what if the string is edited to contain single quotes as well?
Then your solution breaks anyway...

Like Chris said, you should be  using htmlentities for output...

John W


- Original Message -
From: Penthexquadium [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Sunday, October 08, 2006 1:41 AM
Subject: Re: [PHP] ECHO $variable


 On Mon, 9 Oct 2006 00:23:00 -0700, benifactor [EMAIL PROTECTED] wrote:
  you should try this...
 
  $saved_message_title = '1 Peter 5:7 Cast all your cares on Him for He
  cares about you';
  - Original Message -
  From: Ron Piggott (PHP) [EMAIL PROTECTED]
  To: PHP General php-general@lists.php.net
  Sent: Saturday, October 07, 2006 11:39 PM
  Subject: [PHP] ECHO $variable
 
 
   In one of my scripts I have
  
   input type=text name=message_title size=40 maxlength=80
value=?echo
   $saved_message_title;?
  
   where
  
   $saved_message_title is 1 Peter 5:7 Cast all your cares on Him for He
   cares about you
   --- note the 
  
   When this is displayed on the screen $saved_message_title reads
  
   1 Peter 5:7
  
   I am assuming the  closes the value=
  
   How may I echo this to the screen and have the full text be displayed,
   not just 1 Peter 5:7 ?
  
   Ron
  
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php

 His problem is in HTML, not PHP.

 Uses htmlspecialchars() or htmlentities() to convert special characters
 to HTML entities. The double quote will becomes quot; so that it can
 be display correctly.

 --
 Sorry for my poor English.

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


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




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



Re: [PHP] Uploading files / processing with a PHP script

2006-10-08 Thread John Wells

On 10/8/06, Ron Piggott (PHP) [EMAIL PROTECTED] wrote:

the owner of the file is 'www'.  Is there any way I am able to
automatically change the owner of the file to my FTP login identity (for
example 'rpiggott')


Just curious, why do you want to do this?  What are you *really*
hoping to accomplish?

John W





Ron







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



Re: [PHP] Re: Set Variable = Long HTML String?

2006-10-07 Thread John Wells

On 10/7/06, sit1way [EMAIL PROTECTED] wrote:

I'm overhauling my PHP based CMS and want to know how to set a variable
equal to an HTML string, but without having to escape all the quotes!


Noah, meet HEREDOC.  HEREDOC, meet Noah:

http://uk.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

Now you cozy two, let's make it a party with the Complex (Curly {}) syntax:

http://uk.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex

All together now!

[code]
$var =HEREDOC
form name=events method=POST action=
   select class=menus name=news onChange=MM_jumpMenu('parent',this,0);
   option selected=selectedNews Options/option
   option value={$this-doc_path}admin/news/add/1/Add/option
   option value={$this-doc_path}admin/news/update/1/Update/option
   option value={$this-doc_path}admin/news/delete/1/Delete/option
   /select
/form
HEREDOC;
[/code]

HTH,
John W


TIA,

--Noah




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




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



Re: [PHP] Re: Set Variable = Long HTML String?

2006-10-07 Thread John Wells

On 10/7/06, Noah Cutler [EMAIL PROTECTED] wrote:

Yah, John.

Just found it via Google.

I remembered seeing this somewhere a couple years back but never used it.

Very cool -- performance hit using this, or just a really useful function?



From what I understand it suffers the same hit as double quotes,

since PHP has to parse it looking for variables.  But it's not really
special, it's just not as well known.

- John W



Thanks,

--Noah




- Original Message -
From: John Wells [EMAIL PROTECTED]
To: sit1way [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Saturday, October 07, 2006 12:03 PM
Subject: Re: [PHP] Re: Set Variable = Long HTML String?


 On 10/7/06, sit1way [EMAIL PROTECTED] wrote:
 I'm overhauling my PHP based CMS and want to know how to set a variable
 equal to an HTML string, but without having to escape all the quotes!

 Noah, meet HEREDOC.  HEREDOC, meet Noah:

 
http://uk.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

 Now you cozy two, let's make it a party with the Complex (Curly {})
 syntax:

 
http://uk.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex

 All together now!

 [code]
 $var =HEREDOC
 form name=events method=POST action=
select class=menus name=news
 onChange=MM_jumpMenu('parent',this,0);
option selected=selectedNews Options/option
option value={$this-doc_path}admin/news/add/1/Add/option
option
 value={$this-doc_path}admin/news/update/1/Update/option
option
 value={$this-doc_path}admin/news/delete/1/Delete/option
/select
 /form
 HEREDOC;
 [/code]

 HTH,
 John W

 TIA,

 --Noah




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







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



Re: [PHP] Re: Really strange / TYPO

2006-10-05 Thread John Wells

On 10/5/06, Deckard [EMAIL PROTECTED] wrote:

config.inc.php is in /var/www/html
and the file that calls it is in
/var/www/html/classes


Hi Deckard,

You've said that the file that is trying to perform the include is
located in /var/www/html/classes, right?  Which suggests to me that
*that* file is probably included from another file, likely located
elsewhere...

Rather than including via a relative '../' path, try an absolute path.
You can hard-code it at first
(include_once('/var/www/html/config.inc.php');), but then if it works
switch to a method like so:

[code]
// Consider *where* you create this
// Define it as a constant if you'd like...
define('BASE_PATH', dirname(__FILE__));

// Now build the path, like (assuming it was created
// in  a file located at /var/www/html
include_once(BASE_PATH . '/config.inc.php');
[/code]

HTH,
John W

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



Re: [PHP] Re: OOP Hello World

2006-10-05 Thread John Wells

Are you sure you're not on a Spanish *Java* mailing list?

:)

On 10/5/06, Martin Alterisio [EMAIL PROTECTED] wrote:

Me... again, still boring you to death with meaningless OOP rantings.

First I would like to point out that there was a design mistake in what I
proposed in the last mail (following afterwards): the Saluter shouldn't be
an abstract class, it isn't correct to base your class hierarchy on the
ability to greet (or in the ability to do something generally speaking). If
it's done that way we'll have classes coexisting in the same branch of the
class tree, but possibly having completely different nature. Saluter should
be an interface:

  interface class Saluter {
public function greet(Salutable $receiver);
  }

  class FormalSaluter implements Saluter {
public function greet(Salutable $receiver) {
  echo Hello  . $receiver-getSalutationName() . \n;
}
  }

Then, I'll try to translate what has been said in the spanish list.

It has been proposed that World should be a singleton, since there is only
one world... but this arguable, at metaphysic level perhaps...

Also an observer pattern could be used so anyone can hear the greetings. But
I think this should be done on the design of the greeting enviroment
abstraction (to provide other places than standard output where the greeting
can be said).

The saluters factory should use a factory method pattern or an abstract
factory pattern? I think an abstract factory is not appropiate in this case,
the creation process is not that complex to require this kind of design
pattern.

Also I proposed that decorators could be used to add styles to the greeting
for outputs that allow styling (e.g.:html). In this case maybe an abstract
factory would be appropiate, so that decorated saluters are created for the
appropiate type of output, combined with a builder pattern to create the
decorated saluters (this last part I thought it just now, I'll post it later
on the spanish list)

Well, I think that sums it all up.

2006/9/29, Martin Alterisio [EMAIL PROTECTED]:

 What's up folks?

 I just wanted to tell you about a thread that's going on in the spanish
 php mailing list. A fellow software developer which had just started with
 OOP was asking for Hello World examples using OOP. The examples of code he
 had been doing was not that different from the usual Hello World example we
 all know and love(?), so I thought he was missing the point of what was the
 purpose of using OOP. This was my reply (I'll try to keep the translation as
 accurate as possible):

 I believe you have misunderstood what is the purpose of OOP, your objects
 are not proper abstractions.

 First and most important, you should define what is the problem to solve:
 greet the world.
 We build an abstraction of the problem and its main components: somebody
 who greets and something to greet.
 Here we're working with generalizations, since our main objective is to
 build reusable objects. For that purpose is useful that our saluter could
 be used to greet more than just the world.

 Therefore we'll first define what kind of interaction we expect the
 salutation receivers to have, in the following interface:

   interface Salutable {
 public function getSalutationName();
   }

 In this interface we have all we need to properly greet any entity: the
 name we should use when doing the salutation.

 Then we create the object which represents the world:

   class World implements Salutable {
 public function getSalutationName() {
   return World;
 }
   }

 Now we're missing a saluter, but we're not sure which way of greeting
 would be appropiate, so we prefer to create an abstract saluter and leave
 the child implementation to decide the appropiate greeting:

   abstract class Saluter {
 abstract public function greet(Salutable $receiver);
   }

 In our case we need a formal saluter as we should not disrespect the world
 (saying hey! wazzup world? could be offensive), then:

   class FormalSaluter extends Saluter {
 public function greet(Salutable $receiver) {
   echo Hello  . $receiver-getSalutationName() . \n;
 }
   }

 Finally we make our saluter greet the world:

   $saluter = new FormalSaluter();
   $world = new World();
   $saluter-greet($world);

 

 Other things you should keep in mind:

 * PHP's type hinting is preety limited, in this case we would like to
 indicate that the name should be provided as a string but we can't. Maybe it
 would be useful to use an object as a wrapper for native strings. EDIT: I
 remembered while translating this that type hinting can only be used in
 function parameters, therefore this point is useless.

 * En this model it seems more appropiate that the saluter is an abstract
 class, since salutation works one way, but, in the event salutations became
 a two way trip, an interface would be more appropiate for the saluters.

 * Here we're sending the salutation to the standard output, which is
 acceptable in this 

Re: [PHP] Help on objects

2006-10-05 Thread John Wells

On 10/5/06, Deckard [EMAIL PROTECTED] wrote:

Hi,

I'm trying to lay my hands on PHP OOP, but it's not easy :(
I've read several examples in the web, but cannot transpose to may case.

I'm trying to set a class to make SQL inserts in mysql.



I commend you on trying to build an OOP class for database
abstraction.  Having already been there and done that, might I
introduce you quickly to one of the great advantages of OOP: reuse.

There are already many classes out there built to help accomplish
database interaction.  Yes it's an obvious place for OOP, but as your
first foray into the discipline, I think you're biting off more than
you can chew.

Alternatively, why not download and start using one of the many stable
and community-tested DB classes?  Believe me, I completely relate to
the need to build it myself, and I don't want to squash that (it's
the best way to learn).  I just don't think it's worth doing it for
database interaction.  It's just not beginner material, and it's
something you'll be using in all of your code from here on out, so
it's best to start with something stable...

My $.02.  Er, £.01.

HTH,
John W

p.s.  I'm sure you want suggestions of good DB classes to use.
Ironically, I use my own, so I don't have extensive experience in
others, but why not look at the Zend Framework (it's what I'm
switching to)?  No need to use the whole framework.  Or others on the
list will surely have their suggestions of classes to use...

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



Re: [PHP] Re: OOP Hello World

2006-10-05 Thread John Wells

On 10/5/06, Martin Alterisio [EMAIL PROTECTED] wrote:

PHP seems to be getting more and more object oriented, I think it's the
right time to start questioning what have been done so far in terms of OOP
in PHP, because, honestly, there are too many php classes being distributed
out there that are a complete mess. Forget about spaghethi code, we have to
deal with pizza classes too.


[code]
require_once('previousEmails.php');

interface Responder {
public function respond(Salutable $receiver, $response);
public function getResponderName();
}

class WiseAssResponder implements Responder {
protected $responderName;

public function __construct($responderName) {
$this-responderName = $responderName;
}

public function getResponderName() {
return $this-responderName;
}

public function respond(Salutable $receiver, $response) {
echo Hi  . $receiver-getSalutationName()
   . .  Please read my response below: 
\n\n;
echo $response;
echo Kindest Regards,\n . $this-getResponderName();
}
}

class Martin implements Salutable {
public function getSalutationName() {
return get_class($this);
}
}

$martin = new Martin();
$johnW = new WiseAssResponder('John W');
$response=HEREDOC

Well I'm not going to argue with you that there is plenty of crap code
out there.  PHP or not.  OOP or not.

And I'm all for taking OOP in PHP seriously, but I also think it's
worth keeping in mind that the real power in PHP is not it's object
oriented capabilities, but rather its simplicity and flexibility.
And, well, I don't know if your Hello, World example keeps that in
mind.

I know that plenty of people on this list want to have a serious
conversation about OOP for PHP (should we just start using OOPHP as
the new acronym?  or maybe POOPH?  Or... PHOOP?!? Wait, that's not
taking thing seriously...), but I don't think a complex Hello, World
made of Saluters, Salutables, factories and abstractions is taking it
serious.  I think it's exhausting the theory and using various design
patterns for the sake of using design patterns...

But really all of this comes down to the imutable truth about
programming in PHP: there are a *million* ways to skin a cat.  When
you heard OOP + Hello, World, you thought about people/things
greeting each other.  When I heard it, I thought about an application
outputing a string.  The guy who started that particular thread
probably thought of something totally different.  Who's to say who is
right?

Hey, take my words as mine alone though.  Maybe I was the only one
that got my joke.  It's happened before.

HEREDOC;

$johnW-respond($martin, $response);
exit;
[/code]

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



Re: [PHP] Re: OOP Hello World

2006-10-05 Thread John Wells

On 10/5/06, Martin Alterisio [EMAIL PROTECTED] wrote:

The kind of thinking that OOP it's just a *super* feature of a programming
language that should be used only for highly complex problems, is what I
want to eradicate. OOP doesn't stand neither as a language feature nor as
extra capabilities of a language, on the contrary, it takes some freedom
away from the programmer. I see OOP as a way of thinking and working, that
should be used in the most complex problem and the most simple problem
equally.


Err.  OOP came about exclusively as a way to manage complexity.   I'm
not so sure about making a simple problem complex just so you can
simplify it with OOP.  And it *is* only a feature of PHP.  So unlike
other languages, you actually *do* have a choice.

Of course I LOVE having the choice, which is why I LOVE PHP.  I get so
much out of POOPH every time I dive into it.


Nope, I caught your joke, and I found it amusing. Though every joke hides a
truth, as I can explain a hello world in oop laughing and being serious at
the same time.


My ex girlfriend always used that line on me.  Drove me mad.  :P

I wish we could continue this over a round of beers at the pub.  I
think we'd have fun batting this back and forth.  :)  And we won't
fill up The List's inbox in the process.

Cheers,
John W

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



Re: [PHP] Miserable escape string problem

2006-10-05 Thread John Wells

On 10/5/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

Using this string:
{$var1: $var2}
of course it doesn't work as some might expect.

But why in the name of [whatever, too many to list] doesn't this one
below work?
\{$var1: $var2}

If \ is an escape character why does it also appear in the string output?
Why does the above \ escape {$var1 and not only the {?

Miserable.



First up:
http://uk2.php.net/manual/en/language.types.string.php#language.types.string.syntax.double

Excerpt:
Again, if you try to escape any other character, the backslash will be
printed too! Before PHP 5.1.1, backslash in \{$var} hasn't been
printed.

Then:
http://uk2.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex

Excerpt:
Since you can't escape '{', this syntax will only be recognised when
the $ is immediately following the {. (Use {\$ to get a literal
{$).

Does that help?

HTH,
John W

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



Re: [PHP] Re: How to Set Object Array Value || In $this-$name[] Format...

2006-10-05 Thread John Wells

On 10/5/06, sit1way [EMAIL PROTECTED] wrote:

Hey all.

I've got a simple object method that sets object vars based on a passed
array:

**
function set($arr) {

foreach($arr as $name = $value) {

if(is_array($this-name)) {
  $this-$name[] = $value;
}
else {
  $this-$name = $value;
   }
   }
}
*

Getting a fatal error when I include the file that contains this method:

Fatal error: Cannot use [] for reading in path/to/my/file on line X

Looks like PHP does not like the syntax of $this-$name[].

Any clues how to set object array value in a loop?



I think the problem is the use of the dollar sign before the property
name.  Try this instead:

[code]
if(is_array($this-name)) {
  $this-name[] = $value;
}
else...
[/code]

HTH,
John W



TIA,

--Noah

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




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



Re: [PHP] Re: Really strange / TYPO

2006-10-05 Thread John Wells

On 10/5/06, Richard Lynch [EMAIL PROTECTED] wrote:

include_path is a much more powerful and flexible construct which will
save you an inordinate amount of trouble if you just figure out how it
works and use it...


Point well taken Richard, thanks.

I've always been curious, iIs there a point in which adding some
number of paths to include_path causes a performance hit?  If my
application for example is spread out across 6 or 7 folders
(controllers, models, library, plugins, scripts, etc etc), is it
really better to shove all of those into include_path?

Thanks,
John W

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



Re: [PHP] need loop help

2006-10-03 Thread John Wells

On 10/3/06, Charles Kline [EMAIL PROTECTED] wrote:

hi all.

i am trying to modify some old code and struggling a bit with this one:

// returns an array of the names in the form post
$fields = $_SESSION['case']-getComplaintKeys();


First of all this is news to me, I'm not sure how it is that you're
getting the POST values from here.  But OK...



// here is the array returned
Array ( [0] = eligibility [1] = payment [2] = service [3] =
document [4] = licensing [5] = source [6] = date [7] = contact
[8] = description [9] = status )

for ($j = 0; $j  count($fields); $j++) {
   if (${$fields[$j]} == 'on') ${$fields[$j]} = 1;
   if (is_null(${$fields[$j]})) ${$fields[$j]} = 0;
   $data[$fields[$j]] = ${$fields[$j]};
}



Well, I'd start off by *not* using this dynamic variable everywhere
(because it's hard to read and easy to introduce a bug), but just set
it to a temp variable and use that, like so:

for ($j = 0; $j  count($fields); $j++) {
 $myField = ${$fields[$j]};
 if($myField == 'on') $myField = 1;
 if(is_null($myField) $myField = 0;
 $data[$fields[$j]] = $myField;
}


The problem I am having is that the code is now on a more secure
server with register_globals off (and I don't want to turn that on).

I am not sure how to get the POST data sorted out using this method.
Hope it is clear what I mean.


Then if you need to explicitly reference the variable name within
POST, just change that line:

for ($j = 0; $j  count($fields); $j++) {
 $myField = $_POST[$fields[$j]];
 if($myField == 'on') $myField = 1;
 if(is_null($myField) $myField = 0;
 $data[$fields[$j]] = $myField;
}

Untested.  Does that work for you?

HTH,
John W



Thanks,
Charles

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




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



Re: [PHP] array problems

2006-08-16 Thread John Wells

On 8/16/06, David Tulloh [EMAIL PROTECTED] wrote:

Chris G wrote:
foreach ($user_input_array as $user_input) {
$data_member = array(); # Create an empty array

Do SQL query stuff

foreach ($sql_results as $sql_member) {
$data_member[] = $sql_member;
}

$data[] = $data_member;
}

You can now do your function call as
$gbarplot = new GroupBarPlot($data);


The downside to this approach is that you'll end up making a SQL call
for each value in the array.  An alternative would be to build a
comma-delimited string of values and use SQL's IN() check.  Example:

[code]
// CAUTION: Validate your data to protect from SQL Injection, like David says!
// Assuming you've done this, $per_ids_array contains valid/clean/safe data
// that was originally submitted through $_GET['per_id'].
// Let's turn that array into a comma-delimited string using implode()
$per_ids_string = implode(',', $per_ids_array);

// Now plug the string into our SQL query:
$query = 'SELECT rep_l_per_id, rep_value_perc FROM report_values WHERE
rep_l_per_id IN (' . $per_ids . ') ORDER BY rep_l_per_id ASC';

// execute
$result = mysql_query($query) or die (mysql_error());

// Before looping through our result set, initialize two variables:
$gbp_data = array();// this will be the final array to be passed
to GroupBarPlot()
$temp_id = NULL;// use this to determine the result set has moved
to a new rep_|_per_id
while($line = mysql_fetch_array($result)) {
// IF $temp_id does not match the current rep_|_per_id,
// create a new element of $gbp_data as an array.
// Also, set $temp_id to this rep_|_per_id value to use in the
next iteration.
if ($temp_id != $line['rep_|_per_id']) {
 $temp_id = $line['rep_|_per_id'];
 $gbp_data[$temp_id] = array();
}

// Add rep_value_perc as an array element
$gbp_data[$temp_id][] = $line['rep_value_perc'];
}

// Now pass to your function:
$gbarplot = new GroupBarPlot($gbp_data);
[/code]

It's all untested, but I *think* will work out of the box.


And now a bit of bonus advice.  The SQL query that you provided earlier
has a giant SQL injection attack problem.  I'd recomend reading a little
about SQL injection attacks and getting it patched up.



Yeah, this cannot be stressed enough!!!

HTH,
John W

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



Re: [PHP] Greek Characters from MySQL to PHP to the Browser: ??????

2006-08-10 Thread John Wells

Thanks to everybody's suggestions, problem solved.  Yes, the default
encoding for PHP's mysql client is latin1.  So a quick query of:

SET NAMES 'utf8'

*per connection* works it all out.

The articles and links were very helpful in alluminating some of the
other particulars of working with utf-8.  These will take a bit more
reading and studying...

Thanks to all!

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



[PHP] Greek Characters from MySQL to PHP to the Browser: ??????

2006-08-08 Thread John Wells

Hi Everybody,

Despite all of my Googling and noodling, I can't seem to figure this
out, and am hoping someone might be able to point me in the right
direction.

Scenario:
- Running Apache 1.3 on OSX 10.4, PHP 5.1.4, MySQL 5.0.19
- Greek text is stored in a MySQL database, encoding set to UTF-8
- From within a db admin like CocoaMySQL, the greek text looks normal
- PHP queries the db table for the greek text
- no matter how I echo the text to screen (see below), it only
produces '?' marks

What I've tried:
- force utf-8 headers to be sent  --- header(Content-type:
text/html; charset=UTF-8);
- indicate utf-8 in the meta tag -- meta http-equiv=Content-Type
content=text/html; charset=utf-8 /
- simpley echo the string as is -- echo $greek_string;
- wrap output in htmlentities() -- echo htmlentities($greek_string,
ENT_NOQUOTES, 'UTF-8');
- wrap output in utf8_decode() -- echo utf8_decode($greek_string);
- If I copy and paste greek characters from the db table into a string
in my PHP script, and output that, it works just FINE, without any
htmlentities() or other functions.

I'm at a loss.  What am I doing wrong?

Thanks in advance,
John W

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



Re: [PHP] How to get rid off empty elements of an array?

2006-08-07 Thread John Wells

Check the 5th and 6th fields.  Something is in one of them.  Because
based on your checks, it will work:

[php]
$first_array = array(
   'first',
   'second',
   'third',
   '',
   '',
   '');

foreach ($first_array as $value)
{
if (!empty($value))$second_array[] = $value;
}

var_dump($second_array);

foreach ($first_array as $value)
{
if ($value != '')$third_array[] = $value;
}

var_dump($third_array);
[/php]

HTH,
John W

On 8/7/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

Hi to all!

I have a form with 6 text fields where visitor has to enter product serial
number (same type data). he has to enter AT LEAST ONE.

for ($i=0; $i6; $i++)
{
echo 'input type=text name=PSN['.$i.'] value='.$PSN[$i].'
size=25';
}

After the form is submitted I'm getting an array

Array
(
[0] = abc123
[1] = ddd111
[2] = poi987
[3] =
[4] =
[5] =
)

Now, I need to get rid off empty elements of the array, to get this:

Array
(
[0] = abc123
[1] = ddd111
[2] = poi987
)

To do that I tried:
foreach ($PSN as $value)
{
   if (!empty($value))$PSN_New[] = $value;
}
but every time I'm getting one additional element of the array:

I tried
foreach ($PSN as $value)
{
   if ($value != '')$PSN_New[] = $value;
}
too - same result.

Array
(
[0] = abc123
[1] = ddd111
[2] = poi987
[3] =
)

No space or anything else is entered in 4th field.

What I'm doing wrong?

Thanks for any help.

-afan

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




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



[PHP] Re: different value in array

2006-07-29 Thread John Wells

Nice tip Paul.

Weetat, I'm a bit concerned about your data as I look at it, and think
the approach I mentioned before needs a rewrite:

Do you have a a primary key in your arrays/rows?  Meaning, how can
you tell if the two arrays you're comparing are just plain
_different_, or simply out of synch?  Is it your card_serial_no?  or
card_model?  Or another column (like 'id') that you're not passing?

The point is, you need to know which is your primary key column and
do your testing based on these.

Then I think your whole update/new/delete/skip process might require
two passes: One to handle the update/skip assignments, and another for
the new/delete assignments.  Use a combo of array_intersect() and
array_diff() to help you figure out what needs what...

HTH,
John W

On 7/29/06, Paul Novitski [EMAIL PROTECTED] wrote:

At 12:20 AM 7/29/2006, Paul Novitski wrote:
You might consider concatenating all the elements in each sub-array
to make the comparison logic simpler, e.g.:

 foreach ($currenttablearr as $key = $subarray)
 {
 $comparisonArray[$key] = explode(_, $subarray);
 }

This would result in:

 $comparisonArray[0] == 1235_Malaysia_cd-12345_ws8950
 $comparisonArray[1] == 1235_Singapore_cd-890_ws1234


Sorry, of course I meant implode(), not explode()!
http://php.net/implode

Paul

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




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



Re: [PHP] COULD NOT RESEND HEADER..

2006-07-29 Thread John Wells

On 7/29/06, BBC [EMAIL PROTECTED] wrote:

The error message: could not resend header, header already sent in line..


It isn't a bug.  What it's saying is completely accurate.  You can
only send header information to the browser once.  As soon as you
output *anything* (via echo/print), headers are sent.  So if you
output something, and then try the header() functions, you'll get your
error.

Make sure that your header() calls occur before any output.  Or you
can buffer and catch your output if you can't keep it from being spit
out before your header() calls.

HTH,
John W

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



Re: [PHP] compare values in 2 array

2006-07-28 Thread John Wells

On 7/28/06, weetat [EMAIL PROTECTED] wrote:

I need to compare values in array which populated by database , below is
the code :


Without mentioning how your code performs some unnecessary actions,
and is also full of errors, here's the idea of what you want
(untested):

[code]
// assume at first they are same
$compare = true;

// compare $array1 and $array2, assuming they have same structure
foreach($array1 as $key = $val)
{
   // value doesn't match, so set $compare to false and break out of for loop
   if($array2[$key] != $val) {
   $compare = false;
   break;
   }
}

if($compare === false) {
   echo 'arrays did not match.';
}
[/code]

HTH,
John W

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



Re: [PHP] sorting array question

2006-07-26 Thread John Wells

On 7/26/06, Angelo Zanetti [EMAIL PROTECTED] wrote:

Hi all,
So they way I want to sort these rows is by total, totalPaid,
totalUnpaid all descending.


Hi Angelo,

So the first question the list will ask is if the array of data is
coming from a database.  Because then you'd be urged to perform the
sorting from within your database query.

Barring that, you can use the usort() function to create custom
sorting.  What I've done below should do what you want, and I've tried
to generalize the functions a bit, so that you can mix descending and
ascending as you wish:

[code]
// Basic function for comparing arrays based on a particular column
function compareColumn($x, $y, $idx, $lessThan, $greaterThan)
{
if ( $x[$idx] == $y[$idx] )
 return 0;
else if ( $x[$idx]  $y[$idx] )
 return $lessThan;
else
 return $greaterThan;
}

// Calls compareColumn so that it sorts in descending order
function compareColumnDesc($x, $y, $idx)
{
return compareColumn($x, $y, $idx, 1, -1);
}

// Calls compareColumn so that it sorts in ascending order
function compareColumnAsc($x, $y, $idx)
{
return compareColumn($x, $y, $idx, -1, 1);
}

// Your customer comparison function.  The order in which you call each
// compareColumn*() is the ultimate order in which your multi-dim
array is sorted.
function compare($x, $y)
{
// total is index 2 of the array
$total = compareColumnDesc($x, $y, 2);
if($total != 0) return $total;

// totalPaid is index 3 of the array
$totalPaid = compareColumnDesc($x, $y, 3);
if($totalPaid != 0) return $totalPaid;

// totalUnpaid is index 4 of the array
$totalUnpaid = compareColumnDesc($x, $y, 4);
if($totalUnpaid != 0) return $totalUnpaid;

// arrays were equal
return 0;
}

$record = array(
array(1, 'marc', 12, 5, 7),
array(5, 'berty', 30, 12, 18),
array(7, 'sarah', 19, 12, 7)
);

// sort your array
usort($record, 'compare');

// print sorted array
echo 'pre';
var_export($record);
echo '/pre';
[/code]


HTH,
John W

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



Re: [PHP] RE: How do I prevent a session from rebuilding itself?

2006-07-12 Thread John Wells

On 7/12/06, Daevid Vincent [EMAIL PROTECTED] wrote:


 I am thinking you are killing the first session, rming the
 files, then
 creating a new session. At the end of the page the data that was in
 memory is getting written to the new session file.

Yes. That's what is happening as I said. I don't want it to re-write.



Just to be clear, what exactly are you trying to do?  Are you trying
to kill a session, as in log a person off?  Then do so within PHP:

[code]
// set $_SESSION to empty array
$_SESSION = array();

// if saving session in cookie, clear that out too
if(isset($_COOKIE[session_name()]))
{
setcookie(session_name(),'',time() - 4800,'/');
}

// destroy session completely
session_destroy();
[/code]

HTH,
John W

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



Re: [PHP] global class instance

2006-07-02 Thread John Wells

On 7/1/06, sempsteen [EMAIL PROTECTED] wrote:

hi all,
i wonder if there is a way of creating an instance of a class and
reach it direcly from any scope in PHP4. basically what i want is:
...
i don't want to:
   - declare global $foo,
   - use pre-defined $GLOBALS variable,
   - or use a::print



Well I don't know what the list will feel about this one, but you
*could* create a function (or series of functions) to do what you want
with $a, since functions always live in the global scope.

If you're just looking for a generic get-me-around-scoping solution,
this obviously wouldn't be appropriate.  However if your $a is
special, for example an application-wide configuration object, then
the approach might suit your needsor wants, as it were.

-John W

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



Re: [PHP] design?

2006-07-02 Thread John Wells

On 6/30/06, Sjef [EMAIL PROTECTED] wrote:

Thanks, John,
I'm not sure I completely get the idea of a pair class.

As an question and answer are in the same database tabel I now created a
questionDepot class that gets the array from the db, does save and update
operations, and for example, sets a flag in the db tabel when a question is
accepted for the list.



Hi Sjef,

It sounds as if you've got the idea, even if I didn't explain myself
well.  My point was to *not* create a Question class that maintained
an array of questions, which was only _implicitly_ related to a
similarly-structured but disparate Answers class.  An array of
questions sitting beside an array of answers is, in my opinion, not a
proper abstraction of the objects you're dealing with.

Perhaps it is out of experience that I'm harping on this point,
because I've been burned by a similar design before.  One of my first
OO projects was a weblog, and I had built a Post class, and then for
posts with galleries, a separate Gallery class that contained *only*
image information for it's parent Post.

On it's own, this wasn't all bad, but the big mistake I made was how I
handled multiple posts and multiple galleries (like for building out
the homepage where I showed 5 recent posts and a thumbnail from each,
if they were galleries).  Within each Post and Gallery class, I turned
the properties into _arrays_.  So what originally was a string for the
post's title, now became an array of strings for many posts.  Likewise
for the Gallery class.  Arrays of thumbnails became arrays of arrays
of thumbnails.

I'm sure The List will shudder at this design, but hey, I've learned
my lesson.  Be-lieve-me.  Anyway, the point is, your initial approach
was the same (if I read it correctly).  You suggested an array of
questions, and an array of answers, which would only be implicitly
related.  Your design started with the concept of many questions, and
many answers, but my argument is that, abstractly, you should begin
with one question, and one answer.  Then think in terms of a
question-answer pair that *belong to each other*.  And then think of
many question-answer pairs.

Anyway, I'm sure that by the time you've finished reading this
hair-splitting rambling, you've already finished your app and moved on
to something else entirely.  :)

-John W

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



Re: [PHP] design?

2006-06-30 Thread John Wells

On 6/29/06, Sjef [EMAIL PROTECTED] wrote:

Hi there,


Hi Sjef,

First off, I think David has a good point with regards to the OO vs
Procedural approach.  If you're looking to do this quick and easy, it
might not be worth your time fussing with OO.  Unless you'd like to
just for the exercise, which I wholly support, so go for it!


I want to create a class Question for dealing wiht the questions and a class
answer for the answers. Each could contain an array with the their part of
the content of the database table.


As far as how to design it OO-style, I'd first urge you *not* to have
separate classes managing lists of questions and answers.  Say for
example you query your db for questions, build up your array inside
your questions class, and then while doing the same for your answers
class, you inadvertently introduce a looping bug that drops one of the
answers from the array, or possibly changes the order that you create
your array, or any other number of possible mistakes (human or
otherwise).

Point is, in the end you'd have two out-of-synch classes that really
should've been built separately to begin with.  A single question and
it's answer(s) are tied together, so keep it that way in your class
abstraction.

That said, I'd suggest building a question-answer *pair* as a class,
and then you'd have an array of these question-answer pairs
representing your entire list (which could be encapsulated into a
container class if you wished).

You could, to be even more abstract, create base question and answer
classes to represent the most basic type of question or answer, and
then hold individual, **related** instances of these within your
question-answer pair class.  Do you see the difference?

You could even take it a step further and build derivatives of your
base answer class to represent different types (string, multiple
choice with one answer, multiple choice with many answers, etc)...But
I'm sure I'm already getting far ahead of your original design.  But
David started it!  :)

HTH,
John W

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



Re: [PHP] Multiple if() statements

2006-06-30 Thread John Wells

On 6/30/06, tedd [EMAIL PROTECTED] wrote:

At 11:07 PM -0600 6/29/06, John Meyer wrote:
Larry Garfield wrote:

switch is fine if your elseif comparisons are equality based.  If they're not 
equality based, then they don't map to switch as well.



Not true.  I've come to really appreciate the structure of switches.
What helps to unlock their power is that you don't *have* to compare
your switch() param with your case() params.

Building on Paul's good advice of splitting logic from presentation:


[code]

$display_name = '';

switch('set_display_name')
{
case($row[1] == 'none'):
case($row[1] == $row[2]):
$display_name = $row[0] . ' ' . $row[2];
break;

default:
$display_name = $row[0] . ' (' . $row[1] . ') ' . $row[2];
break;

}

// now print table, using $display_name
[/code]

HTH,
John W

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



Re: [PHP] $ENV['SCRIPT_FILENAME']

2006-05-15 Thread John Wells

On 5/14/06, Ryan A [EMAIL PROTECTED] wrote:

Anyone have an idea of a variable (eg:
$_SERVER['REQUEST_METHOD'] ) that will be set only if
called via the web and ignored if called via cli?


I have no experience with CLI, and haven't tested this, but I believe
that any time a request comes through a web browser, the $_GET and
$_POST values are set, even if they're empty.  This may go for the
$_COOKIE global as well.  So you could simply check if one of these
are set:

isset($_POST)

But again I have no CLI experience, so I could be off.  But it's worth
testing...

HTH,
John W

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



Re: [PHP] Sending a lot of data to remote site

2006-05-12 Thread John Wells

On 5/12/06, Jochem Maas [EMAIL PROTECTED] wrote:

Ryan A wrote:
 Hi,

 I need to send an array of data to a remote site from
 my script, the array will contain anything from 1 to
 5000 entries of less than 150 alpha numeric characters

you could setup an XML feed that they can request at their leasure.



Ok Ryan, so when I first read your needs, I thought to myself web
service (along the lines of Jochem's XML feed concept).  But with my
limited experience with it, I'm hoping others can offer some reaction
to the idea.

So, if you consider SOAP as your web service solution:

a) Using XML eliviates your need to come up with custom serializing
that is careful to not use delimiters that might also be found in your
data.

b) If your client and server machines are running on different
languages (PHP on one, Java on the other, for example), then a WSDL
file will describe the structure of your data, so your PHP array
seamlessly becomes a Java array.  No interoperability issues.

c) You may find that after you develop this solution once, you can
easily reuse it elsewhere.

d) SOAP et al also includes a lot of custom error handling, so you
could concievably make your solution a lot more robust.

e) The standard also includes an authentication mechanism.

Ok, so that's what I'm thinking.  I know there's more work involved in
a SOAP solution than a down-and-dirty serialize-and-stream solution,
but down the road it might serve you better.

John W

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



Re: [PHP] tired of referencing static variables/constants with 'self ::'

2006-05-10 Thread John Wells

On 5/9/06, D. Dante Lorenso [EMAIL PROTECTED] wrote:

As an OOP programmer, I would expect the scope search to be as follows:

   1. LOCAL: current method
   2. THIS: current instance ($this)
   3. SELF: current class  parent classes, in order of inheritance
   4. GLOBAL: globals



Ok, so this is interesting Dante, you have me thinking... Perhaps this
is all a result of PHP being a procedural language first, and an OOP
language second?  Indeed, even if our PHP applications are fully
abstracted into objects, they still begin their lives in a procedural
way...

[thinking_aloud]
I have little experience with pure OOP, short of a quick dive into
Java, but I do recall that any J2EE web application that runs does so
as an instance of a class (which is a child of some base listener
class that handles web requests).  So your initial scope sort of is
at a local object level.  So then it would make perfect sense as a
programmer to want the ability to call an object constant or static
property without having to say hey, look for  in the same place
that I am right now. Because there's nowhere else you'd be, anyway.

But with PHP, every script starts out procedurally, and hence at the
global level.  Then we instantiate a class, step into that object,
and do our thing.  But still, we _started_ outside, and our scope
ladder does too.
[/thinking_aloud]

Yes? No? Maybe so?

-John W

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



Re: [PHP] tired of referencing static variables/constants with 'self ::'

2006-05-09 Thread John Wells

On 5/9/06, D. Dante Lorenso [EMAIL PROTECTED] wrote:

Does anyone know if it's possible to reference class constants or static
variables without having to use 'self::' all the time?


No, and the answer is actually in your example.  Copy-and-paste all of
your example code into one file, and just change the second class A to
B so that there isn't a class conflict.  Then create an instance of A,
and B, and call both test() methods.  You'll get the following result:

111

Why?  The reason is SCOPE.

A::test() echos twice, the first for the class constant MY_CONSTANT,
and the second echo's the *global* MY_CONSTANT.  Then B::test() echos
the *global* MY_CONSTANT again.

As wonderful as PHP is, it can't read your mind. So if you're looking
for a constant or variable, PHP needs to know where to look.  If you
don't specify self::', PHP will look in the global scope, as it did
in your code example.  If you want it to look within your classes, you
need to *tell* it so.

And is self:: really a lot of boiler-plate?  Really??

John W





class A {
const MY_CONSTANT = true;

public function test() {
   echo self :: MY_CONSTANT; // works
   echo MY_CONSTANT; // doesn't work
}
}

I don't think it is possible, but why not?  Can zend/php make it work?
Seems it could since this works:

define('MY_CONSTANT', true);
class A {
public function test() {
   echo MY_CONSTANT; // works
}
}

It's just annoying my how much boiler-plate I have to write all the time.

Dante

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




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



[PHP] Re: Quotation marks considered harmful

2006-05-05 Thread John Wells

On 5/4/06, John Hicks [EMAIL PROTECTED] wrote:

Why not develop a language syntax that has distinct open and close
string delimiters?


I consider HEREDOC to be the answer to that kind of prayer.  For quick
one-liners I find it overkill, but I felt so freed when I discovered
it for creating large string blocks, like HTML templates with PHP
intermixed.

The only thing I wish HEREDOC could do is evaluate functions within
the string blocks.  But at least it will evaluate object methods, so
if you're a staunch OOPer, you're set. (Yet another reason why I'm a
convert)

All other comments about having to escape alternative delimiters are valid.

-John W

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



Re: [PHP] Avoiding user refresh of pages with forms

2006-05-04 Thread John Wells

On 5/3/06, Satyam [EMAIL PROTECTED] wrote:

I used that method initially, some months ago, but finally dropped it.  It
looked nice at first, but then I started getting into problems and required
too many special cases to make it work.   In the end, it wasn't a clean nor
elegant solution.


Satyam,

Would you care to give some more details as to those edge cases that
swayed you to drop the unique id approach?  I've just recently added
it to my forms (for those that I find need it), in addition to the
redirect method you outlined below.  Those two combined seem to really
go the distance in creating a reliable exchange of data between client
and server, as well as a better experience for the user (since the
form is capable of handling a larger set of error cases).

Also, with regards to sending success/failure messages across the
redirection of your forms, I'd recommend considering sessions for
passing the data.  It keeps your URLs clean, and allows you to send
complex data a bit easier (IMHO).  For example if a user makes an
error on a few different form elements, you can send back an array of
messages to the user without having to serialize/unserialize in the
ugly URL.

-John W

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



Re: [PHP] mod_rewrite help

2006-05-04 Thread John Wells

On 5/3/06, Jay Blanchard [EMAIL PROTECTED] wrote:

[aha moment]
I finally get it. PHP developers are the smartest people on the planet
and therefore we know and use everything. JavaScript, Java, C++, SQL,
network management, Apache internals, women and even PHP. That is why
people come on this list to ask questions totally unrelated to PHP even
if they try to relate it to PHP by including the URL of a PHP page
within the request.
[/aha moment]


[dream_sequence]
Beautiful Woman:   So how do you useFFP to make all of those
pretty-looking website adresses?

Me:   Well actually, *P.H.P.* doesn't do it, but if you're running
your website on Apache, you can use mod_rewrite and some regex pattern
matching to forward your requests onto the appropriate page.  And then
you can parse any number of your server's global variables, like
SCRIPT_URL, to handle the request.

Beautiful Woman:That's hot. Let's make out!
[/dream_sequence]


[gratuitous_back_patting]
This probably is a good opportunity to send out general thanks and
acknowledgement at just how active and *helpful* this list is on a
daily basis (sarcasm included).  In contrast, I just subscribed to the
RubyOnRails list to see what sort of chatter goes on within their
community.  In less than a week the list has already seen well over
300 messages, and the majority of them are never replied to.  Sure,
the RoR world is still in its infancy, but even so.

And at least on our list, if you don't feel like answering a
JavaScript question you don't have to; but on the RoR list you have
little choice, since it's all tied together.

Cheers to the PHP list.  I love it here.
[/gratuitous_back_patting]

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



Re: [PHP] Sanity checker?

2006-05-04 Thread John Wells

On Wed, May 3, 2006 12:51 pm, Ezra Nugroho wrote:
 I envision a tool that would audit your php code, and tell you if your
 code is good or not, if it has scaling issues, etc, etc. Basically it
 tells if your php code is sane or not.



No, but

If you're in a team environment, the best advice I've heard is to have
the team share accountability.  Meaning, if you write a piece of code,
you _must_ have a colleague double-check it and sign off on it.  Then
if a bug is discovered down the road, _both_ of you will be held
responsible.  This will do two things:

1. Ensure that code you write is readable.  If someone else simply
can't understand it or consider it too confusing, they can hand it
back to you and say clean this up.

2. It increases the chance of catching bugs or weak code prcocesses.

Also, develop/adopt specific coding standards (refer to PEAR's
standards as a flavor), and the steps above will help adherence to
that as well.

I'm willing to say that those two techniques will make you sleep much
sounder at night then just stuffing thousands of lines of code through
some regex checker.

Oh, plus some solid QA testing. Your last defense.

There will always be newbies in PHP (and elsewhere).  The solution is
education (being proactive), not sanity checking (being reactive)...

Although I don't blame you for asking.  :)

-John W

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



Re: [PHP] Echo a value from an arrays position

2006-05-04 Thread John Wells

On 5/4/06, Brad Bonkoski [EMAIL PROTECTED] wrote:

Will this also work with an associative array?  If this is what he is
talking about, I tried it and it does not work



I think you're correct.  This is because PHP arrays are a mash-up
(as Jochem put it) of numerical indexes/hashtables/assoc.
arrays/etc

Example:

[php]
   $jonas = array('color' = 'blue', 'number' = 'three');

   echo $jonas[1];  // prints nothing

   $jonas = array('color' = 'blue', 'number' = 'three', 1 = 'readme');
   echo $jonas[1];  // prints 'readme', even though it's technically
the third element
[/php]

So, your solution might be to first pull all of the array values out
into a new array, like this:

[php]

   $jonas = array('color' = 'blue', 'number' = 'three', 1 = 'readme');

   $jonas_new = array_values($jonas);
   echo $jonas_new[1];   // prints 'three', as you'd hoped
[/php]

p.s.  Bonus: If you wanted to get the keys out, use array_keys()

And yes, as Jay said, RTFM.  It's very very helpful.

HTH,
John W

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



Re: [PHP] can't work out the syntax error

2006-05-04 Thread John Wells

On 5/4/06, Brad Bonkoski [EMAIL PROTECTED] wrote:


try this:

echo TD WIDTH=\25%\ ALIGN=\CENTER\
A
HREF=\javascript:open_window('.$_SERVER['PHP_SELF'].?action=view_recorduserid=$userid');\View/A

---^---^
concatenate the $_SERVER variable to the string...



Or wrap the variables with curly braces so that PHP knows what's a
variable and what's not:

[php]
echo TD WIDTH=\25%\ ALIGN=\CENTER\ A
HREF=\javascript:open_window('{$_SERVER['PHP_SELF']}?action=view_recorduserid=$userid');\View/A
[/php]

Personally, I get tired (and confused) when having to escape all of
those quotes like in the string you're trying to echo above.  Perhaps
you'd consider HEREDOC as an alternative approach:

[php]
echoHEREDOC
TD WIDTH=25% ALIGN=CENTER A
HREF=javascript:open_window('{$_SERVER['PHP_SELF']}?action=view_recorduserid=$userid');View/A

HEREDOC;
[/php]

If you haven't read about HEREDOC before, RTFM because there are some
rules you should know about it...

HTH,
John W

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



Re: [PHP] Echo a value from an arrays position

2006-05-04 Thread John Wells

On 5/4/06, Ford, Mike [EMAIL PROTECTED] wrote:

They're not even that. They're pure associative arrays, or maps -- it's just 
that integer keys are treated somewhat specially so that an array with *only* 
integer keys will look like a traditional array.



True true, thanks for making it crystal clear!

-John W

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



Re: [PHP] Problem with usort

2006-05-04 Thread John Wells

On 5/4/06, Stut [EMAIL PROTECTED] wrote:

Jon Earle wrote:

  $ret_val = 0;
  if ($aday == $bday) {$ret_val = 0;}
  else {$ret_val = ($aday  $bday) ? -1 : 1;}
  return ret_val;



I could be wrong, but I think you need some extra brackets on the else
line...

else {$ret_val = (($aday  $bday) ? -1 : 1);}



Not true actually, it's a quick if/else using the ternary operator. 
It's also difficult to read all on one line:


$ret_val = 0;
if ($aday == $bday)
{
   $ret_val = 0;
} else {
   // what this does is test if $aday is less than $bday.
   // If so, it sets $ret_val to -1.  If not, it sets $ret_val to 1.
   $ret_val = ($aday  $bday) ? -1 : 1;
}
return ret_val;

HTH,
John W

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



Re: [PHP] Problem with usort

2006-05-04 Thread John Wells

On 5/4/06, Stut [EMAIL PROTECTED] wrote:


Anyway, as someone else has pointed out, there is a missing $ on the
return value.

-Stut



Yup, missed that one too.  :)

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



Re: [PHP] array_push in array maps

2006-05-03 Thread John Wells

On 5/3/06, Jochem Maas [EMAIL PROTECTED] wrote:

Jonas Said:
 But when I want to have a value from a special column i a row the
 followint
 doesn't work:

$test[$row[2]] = $row[5];

 Or:

$test[$row(2)] = $row[5];

 Do I need to do some kind of concatenating?



Ah, Lasso! I coded that in my previous job.  Left it to commit to the
world of PHP, but I saw lots of potential in Lasso 8 (we were in
3/4/5).  Sort of miss it sometimes...*sniff*

Anyway, all of the comments are in the right direction.  A couple
things to fill in the gaps:

PHP Arrays are indeed a mash-up like Jochem said.  If you want to
get at an array element using a numerical key, then simply use the
number without any quotes, like so:

echo $array[2];

However if you want to get at an array element using a string key,
then it must be surrounded in quotes (single or double, but see below
for more):

echo $array['my_key'];

Now, single quotes and double quotes are slightly (and also very)
different in PHP.  Read the manual for the details
(http://uk.php.net/manual/en/language.types.string.php), but one thing
to know is that the $ sign is a literal $ sign when it is in a string
surrounded by single quotes; but surround it with double quotes, and
it will help you create a variable (assuming you follow it with legal
variable naming characters).

So if you have a variable:
$lang = 'Lasso';

And try to print it in a string with single quotes, it won't work:
echo 'I used to program in $lang';  //  this prints 'I used to program in $lang'

But around double quotes, all is well:
echo I used to program in $lang; //  this prints 'I used to program in Lasso'

And if you have a complex variable within a string and you want to
help PHP figure out what's a variable and what's not, use { } to
frame the variable name:
echo Look at my class {$my_class-get('name')} and my array
{$my_array['key']} !;

Make sense?  The manual explains a lot more, so be sure to read up.

Also, unless Lasso changed in 8+, there's one other thing to remember
about arrays.  In PHP, arrays will keep their order of elements as you
have created it.  IIRC, Lasso never guaranteed this, so you always had
to take extra measure to build your arrays such that you could iterate
through them in a reliable fashion.  No worries in PHP, the order
sticks (and you can of course re-order it).

HTH, Good luck,
John W

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



Re: [PHP] Printing with php

2006-05-03 Thread John Wells

On 5/3/06, Mace Eliason [EMAIL PROTECTED] wrote:

Hi

I am working on a project that creates invoices.  It will allow the
client to print out these invoices after they have been created.

Something that I have always noticed is that when you print form the
internet you always get the site address and other info on the print out.

Is there a way to eliminate this?  I just want the invoice to print.

Thanks


Has nothing to do with PHP (or any code for that matter), it's all in
the browser settings.  You can't do a thing about it.  If you're
really concerned, convert it to a PDF that the user downloads and
prints.

HTH,
John W

p.s. Ok technically I  think that if you're in an PC IE-only
environment you can use ActiveX or something else to control this, but
even so I'm categorically against controlling a user's local
settings/prefs/etc.

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



Re: [PHP] undefined variable

2006-04-29 Thread John Wells

 2006/4/29, Smart Software [EMAIL PROTECTED]:
 How can i add the content of the textbox?
 i tried this:
 td width=40% a href=? echo
 products.php?cat=$catquantity=$quantitytoevoegen=1id=$rowType[7];
 ?img src=images/bestel1.gif border=0/a/td

 but all i get is an error telling me there is a undefined varable



It looks like you're trying to get at $quantity, but have you pulled
it from the submitted form yet? If your form's method is post then
reference the quantity value with $_POST['quantity']; if your form's
method is get, use $_GET['quantity'].

You sound very new to this, and the fact that you're building a
shopping cart is worrisome...so please read up on the importance of
verifying your form data, i.e. always sanitize submitted values
before using them in SQL calls. And simply check that the values you
get are what you expect, i.e. if you're expecting a number in
$_POST['quantity'], make sure it's a number...

By the way, values submitted in a form will be strings, so in the
example above you'd actually be checking for the *existence of numbers
only* in the string.  Good luck.

HTH,
John W

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



Re: [PHP] cgi.fix_pathinfo and iis 5

2006-04-28 Thread John Wells

On 4/28/06, Mariano Guadagnini [EMAIL PROTECTED] wrote:

Mariano Guadagnini wrote:

 Hi people,
 I have the following issue: I´m using PHP 5 on IIS 5 and Windows XP
 Pro, and when trying to pass values through the path to my scripts,
 iis rejects them.  After some googling, I found an advice to set


So... without some code examples or something a bit more substantial
than iis rejects them it's difficult to help out.  I have no
experience with the cgi.fix_pathinfo, but I'm _guessing_ that you're
trying to do something like this:

http://www.mariano.com/script.php/var1/var2

And get var1 and var2 out of the path?

If so, you've likely tried getting at them with:

$_SERVER['PATH_INFO']

or even

getenv('PATH_INFO');

?  And if so, what exactly does iis do?  Run phpinfo() and see what
environment variables your server is setting (VERY_HELPFUL).  For
example, on the 3rd party hosting server I use, PATH_INFO is empty,
but an ORIG_PATH_INFO contains the value I need.

As I said at the start, please give us some more information, and
perhaps we can be a bit more helpful...and I can stop asking you more
questions than you asked us.

Cheers,
John

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



Re: [PHP] how should MS Access DATETIME be handled in PHP?

2006-04-20 Thread John Wells
I don't know if MS Access will behave the same, but in MySQL you can
have a query like so:

SELECT *, DATE_FORMAT(end_date, '%d %m %Y') as end_date_formatted FROM projects;

And it will retrieve all columns from your projects table, plus the
extra one you've created on the fly, and it will be named
end_date_formatted.

HTH,
John W

On 4/19/06, Bing Du [EMAIL PROTECTED] wrote:
  Do the search as Richard suggested.
 
  MS Access might have a similar function you can use, but you'll need
  to do some searching yourself to find the answer.
 
 Sure.  I always appreciate various opinions.  I've checked with an Access
 expert.  It can be done for Access like Format([DateFieldName],  
 ).  But if fields of date type should be formated as needed in the
 query, there is one situation in which I'm not clear how that would work.
 Say, I need to query all the fields from a table which has quite a fields.
  Some of the fields are of some kind of date type.  Enumerating the fields
 is not feasible.

 SELECT * from table;

 So in this case, how should the date fields be formated in the query?

 Thanks,

 Bing

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



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



Re: [PHP] Re: no offense to Rasmus... are you kidding me

2006-04-20 Thread John Wells
Here's an invitation to take this off-list.  I've posted my thoughts
on my (currently design-less and under massive construction 
relocation) website.

Direct link to post:
http://s153531379.onlinehome.us/index.php/journal/the-clash-of-the-php-mailing-list-and-the-proverbial-web-2-0-iceberg

Permanent Site:
http://www.johndwells.com

Cheers,
John W

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



Re: [PHP] Date time Comparison

2006-04-19 Thread John Wells
I'd agree with what Richard is alluding to: turn your two dates into
timestamps, and then compare those.  mktime() or strtotime() should
help you out.

HTH,
John W

On 4/18/06, Richard Lynch [EMAIL PROTECTED] wrote:
 http://php.net/mktime may be more suitable, depending on the date
 range of the input.

 That said, as far as I can tell, your $formated_expiry_date is the
 SAME as your $expiry_date, except possibly for some separation
 characters.

 If the separation characters are ALWAYS the same, you could just do:

 $current_date = date('Y/m/d H:i:s'); //match formatting of expiry date.
 return $current_date  $expiry_date;


 On Tue, April 18, 2006 5:02 pm, Murtaza Chang wrote:
  Hi everyone,
  this is the function I have written for comparing a date time please
  tell me
  if my logic is correct ? and if there's a better alternative please
  let me
  know of that as well.
  // This function will return 1 if supplied date is expired
  function is_expire($expiry_date){
  $current_date=date('YmdHis');
  $year=substr($expiry_date,0,4);
  $month=substr($expiry_date,5,2);
  $day=substr($expiry_date,8,2);
  $hour=substr($expiry_date,11,2);
  $min=substr($expiry_date,14,2);
  $sec=substr($expiry_date,17,2);
  $formated_expiry_date=$year.$month.$day.$hour.$min.$sec;
  if ($current_date=$formated_expiry_date)
  return 1;
  else
  return 0;
  }
  --
  Murtaza Chang
 


 --
 Like Music?
 http://l-i-e.com/artists.htm

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



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



Re: [PHP] 2 questions: Search in array and detect JS

2006-04-15 Thread John Wells
On 4/14/06, Ryan A [EMAIL PROTECTED] wrote:
 The reason I ask is before serving an AJAX page I would like to make sure JS
 is enabled, if not, serve the other normal page... I am sure I am not the
 first person to come accross this little problem, how did you solve it?

Dan eluded to a big problem here, regarding the potential exit trap
of redirecting a user to a different page.  However there's even more
at stake--this solution would require you to manage *two* versions of
your page.  Come on, we can do better than that...

What you should do is create your normal page as is, and then write
your javascript to attach itself to whatever things you want to
AJAXify on that page.  Research unobtrusive javascript, it should
get you in the right direction.

The idea is, you build your page to function normally without any
javascript.  Then you attempt to hook up the javascript via your
page's onload event (there are other methods too I believe, Google
it).  If javascript is enabled, then the javascript will be hooked in;
if not, then no AJAX will be loaded, but your page will still function
as needed.

HTH,

John W

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



Re: [PHP] help with multidimentional arrays

2006-04-12 Thread John Wells
On 4/11/06, Bing Du [EMAIL PROTECTED] wrote:
 ==
 foreach ($sponsor_id as $sponsor = $arr)
 echo $sponsor:;
 foreach ($arr[$sponsor] as $project) {
 echo $projectbr;
 }
 ==


It looks like you're building your array just fine.  Here though, your
second foreach needs to look like this:

[code]
foreach ($arr as $project)
{
 echo $projectbr;
}
[/code]

Your temprorary $arr variable contains only your array of titles, not
an entire row of your 2-dimensional $sonsor_id array.  So you do not
need to use the $sponsor key to get at that array.

HTH,

John W

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



Re: [PHP] Is it a bug of CakePHP?

2006-04-08 Thread John Wells
  Pham Huu Le Quoc Phuc a écrit :
   I catch an error, could you tell me if you have some ideas?
  
   Error message: Undefined index: start_date in
   c:\Inetpub\wwwroot\Cake\app\controllers\dsptrainings_controller.php on
 line
   33
  

PHP is telling you that what you are trying to access doesn't exist. 
This is is a matter of you trying to access something that doesn't
exist.

So the question is, what does $data look like?  My suggestion is to
print_r($data) to see.  Perhaps findBySql() doesn't return the results
as an associative array?  Or since you're sending a query for only one
record, it doesn't send a 2-dimensional array back? Maybe your start
date can be accessed simply by $data['start_date']?  I don't know, I
don't use CakePHP.

Again, print your $data variable to the screen to find out what it contains.

Consider this to be a powerful tool in your bag of debugging tricks. 
I print variables to the screen all the time to find out what's wrong.
 In fact, I'll do it in a two step process:

print_r($my_variable);
die(hrfilename.php:line_num);

The first line prints the variable I'm after to the screen.  The
second line kills the script, but outputs the text I send it first. 
So it draws a horizontal rule across the page, and then prints out the
file name and line number that the script was killed at.

So if I'm tracing a particularly elusive bug, I can place these two
lines in various places across my app, and walk through it step by
step.  The important part is knowing the filename and location of your
debugging marks, so that you can clean them up easily.

HTH,
John W

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



Re: [PHP] Problems with Arrays and print and echo

2006-04-08 Thread John Wells
  echo $this-name[5]\n;
  echo $this-ID[5]\n;
  $a1 = $this-name;
  $a2 = $this-ID;
  echo \n$a1[5] $a2[5]\n;

use curly brackets to help PHP understand what you're after:

echo {$this-name[5]}\n;

When you're in a string like this, PHP has a hard time knowing when
you're wanting to access a variable, and when you're simply trying to
output text.  Using curly brackets clears it up.

HTH,
John W

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



Re: [PHP] IF or SWITCH

2006-04-06 Thread John Wells
 ...Either way,
 internally, switch behaves like if/elseif/else and generally only
 provides an advantage with respect to code organization or if you want a
 particular condition to drop through to other case blocks.


Considering this is regarding an if/else with ***57*** conditional
checks, wouldn't we be wise in suggesting switch/case if one of its
benefits is code organization and readability?

Imagine having to come back to this code block in a months time to trace a bug.

*shudder*

I would look very long and hard at how the solution may be simplified,
although it's hard to offer ideas without understanding the business
logic.  I'm just hoping for your sake that there is a way.

Good luck!

John W

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



Re: [PHP] newbie question

2006-04-05 Thread John Wells
On 4/5/06, David Doonan [EMAIL PROTECTED] wrote:
 The only difference is the textarea tag from the form. What am I
 missing?

nl2br is short for newline to br.  If you pass a string of
content that contains newline characters (these signal the ending of a
line of text) to nl2br(), it will replace those newlines with br
tags, so that when outputted to the screen, you will see the line
breaks.

The reason why you see the line breaks when contained within the
textarea / tags is that browsers honor newline characters (and
other whitespace) when wrapped in textarea /.  This is similar to
the pre / tags.

HTH,

John W

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



Re: [PHP] Multidimentional array problems

2006-04-04 Thread John Wells
On 4/3/06, Mace Eliason [EMAIL PROTECTED] wrote:
 This is what I am doing and the output (for testing) seems correct
 while($row=mysql_fetch_array($result))
 {
   $banner= array($arrayIndex = $row);

   echo $banner[$arrayIndex][image]. br;
   echo $banner[$arrayIndex][url]. br;
   echo $banner[$arrayIndex][display_type]. br;
   $arrayIndex++;
 }


Tom is correct, you're overwriting $banner each time.  While the
following is a bit verbose (Tom's assignment step is all you need),
this might help to show what's happening:

[code]
$banner_array = array();
while ($row = mysql_fetch_array($result))
{
 $banner_array[] = array(
   url = $row[url],
   image = $row[image],
   display_type = $row[display_type]
   );

}
[/code]

 $value=0;
  while($value  $number_of_banners_db )
  {
 echo $banner[$value][url]. br;
 echo $banner[$value][image]. br;
 echo $banner[$value][display_type]. br;
  }

Here you're also not incrementing your loop counter.  Try this:

[code]
foreach($banner_array as $banner)
{
 echo $banner[url] . br;
 echo $banner[image] . br;
 echo $banner[display_type] . br;
}
[/code]

HTH,

John W

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



[PHP] Failing to write to a file when a class is being implicitly destroyed

2006-03-31 Thread John Wells
I hope I can explain my problem/questions clearly. Thanks in advance:


Scenario:
I'm working on a Log class that my app will use to write
debug/error/etc messages to a file.  I've created it so that as the
application logs messages, these messages are queued within a property
of the Log class, and only written to the file when the Log object is
being destroyed.

I wanted to place all of the file writing to within __destruct() to
avoid holding a connection to the log file throughout the life of the
app's state.


Problem:
Everything works fine, UNLESS I move the fopen('log-file-name') call
to within the __destruct() method.  If I open a handle to the log file
within the __construct() method, or any other class method, it works
fine.  But I receive a permissions error if it's called within
__destruct().

Error reads: Warning: fopen(20060331.txt) [function.fopen]: failed to
open stream: Permission denied in ...


Caveat:
I have found that if I explicitly destroy an instance of Log with
unset(), then fopen() will work even when it is within the
__destruct() method.  However I don't like that solution...and
besides, I'm planning on creating an instance of the Log class from
within the __construct() of my Controller class, and trying to
explicitly destroy Log with an implicit __destruct() of my Controller
doesn't work either. :P


Question(s):
1. Could anyone explain a bit more as to why fopen() won't work within
an implicit call to __destruct()?  What permissions has my app lost at
this point?
2.  Am I at least correct in my intention to limit the duration that
the handle to the log file is open?
3. Is there workaround to this little conundrum that anyone can think of?


Code:
Here's a simplified version of the code (it's complete, feel free to
copy-and-paste-and-play).  I've commented the fopen code block in
question.

[code]
// Create an instance of Log
$log = new Log();
// Attempt to log a message
Log::debug(Here is a debug message.);

class Log
{
protected static $handle;
protected static $location;
protected static $message;

public function __construct()
{
self::$location = date(Ymd)..txt;
/* Begin fopen() */
/* When placed here, it works */
if (!self::$handle = fopen(self::$location,a))
{
echo Error. Please check permissions.;
die;
}
/* End fopen() */
}

public static function debug($message)
{
$timestamp = date(Y-m-d H:i:s T);
self::$message .= $timestamp.\tdebug\t.$message.\n;
}

public function __destruct()
{
if(self::$message)
{
/* Begin fopen() */
/* If it's here, it won't work!
if (!self::$handle = fopen(self::$location,a))
{
echo There was an error attempting to 
open the log file. Please
check permissions.;
die;
}
/* End fopen() */
if (fwrite(self::$handle, self::$message) === 
FALSE)
{
echo Cannot write to file 
({$this-location});
exit;
}
@fclose(self::$handle);
}
}
}

[/code]

-John W

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



Re: [PHP] webservice

2006-03-30 Thread John Wells
[snip]
 soap_fault Object ( [error_message_prefix] = [mode] = 1 [level] = 1024
 [code] = WSDL [message] = no operation readpackageabstract in wsdl
[/snip]

It appears as though you're attempting to invoke a method that doesn't
exist. Are you sure readPackageAbstract() is defined  registered in
the WSDL you're pointing to?

John W

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



Re: [PHP] Re: session vars

2006-03-23 Thread John Wells
U, is your top.php code being printed AT ALL? Because in the code
you gave us, you're attempting to include topo.php.

HTH,
John

On 3/21/06, João Cândido de Souza Neto [EMAIL PROTECTED] wrote:
 tedd wrote:

  Hi:
 
  I hate this.
 
 Ok guy, don't fight with me. hehehe
 
 Follow's all code of files.
 
  Yeah ! Where's rodape.php ?
 
  If we're going to spend our time looking at your code, shouldn't you
  spend the time to provide all of it?
 
  tedd
 

 I'm sorry for do that.

 I'm stressed today. Forgive me.

 Follow's the rodape.php code:

 table width=780 height=61 border=0 cellpadding=0 cellspacing=0
 bgcolor=#FF align=center
 tr
 td height=61 bgcolor=#009EFF
 div align=center
 font color=#FF
 strong
 Buffet Online - 
 www.buffetonline.com.br
 /strong
 br
 Copyright (c) 2006 - Todos os 
 direitos reservados
 /font
 /div
 /td
 /tr
 /table

 --
 ---
 João Cândido de Souza Neto
 Web Developer

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



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



Re: [PHP] Clear POST variables

2006-02-18 Thread John Wells
[snip]
If it's not wrong for me to push the back button, why are you
breaking it with all your re-directs :-)
[/snip]

I was a bit short in my explanation -- I tend to use the redirect
method so that users *can* use the back button (or refresh).  I'm
trying to *not* break it. :)

That said, the unique token method is very interesting, I'll
definitely check it out.  But I'm curious, if you check for an
existing token and do find one (so the user has possibly refreshed the
browser), don't you have to program a particular way to handle it? And
might that handling method be different for each type of action being
taken? Does this run the risk of overcomplicating the code as well?

Then again, being forced to consider and handle *exceptions* is a very
good thing when developing a stable application...

I'll enjoy playing around with these ideas...

John




On 2/17/06, Curt Zirzow [EMAIL PROTECTED] wrote:
 On Thu, Feb 16, 2006 at 09:34:12PM -0600, Mike Tuller wrote:
  ...
 
  This is how I learned in some book somewhere. Is everyone saying that
  I need to either use sessions, or redirect so that when someone
  refreshes insert.php, it doesn't submit the information again? To me
  it seems that there has to be a more efficient way. I don't
  understand the token thing that some are suggesting.

 Since  web requests are stateless you need to protect yourself
 in some ways, this is a method to prevent those duplicate entries
 in the db when someone refreshes the browser and reposts the data.

 The only difference with richards code with what I have is that he stores it
 differently than I generally do. The concept is as follows:

 form.php:
 ?php

 // generate a token
 $my_token = md5(uniqid('thisformid', true));

 // store the token in a place that can be retrieved
 // on the next place, richard uses a db, i usually just use the
 // _SESSION where it is stored isn't relevent

 $_SESSION['tokens'][$my_token] = time(); // use time() so we can expire

 // put the token in the form to be passed to the next page
 ?
 form
   input type=hidden name=form_token value=?php echo $my_token?
 /form


 action.php:
 ?php

 // grab the token in the form:
 $token = $_POST['form_token'];

 // test it against what we stored in the previous page.
 if (isset($_SESSION['tokens'][$token]) ) {

   // forget the token
   unset($_SESSION['tokens'][$token]); // very important

   // do stuff..

 } else {
   // form submitted twice or they tried to access this page
   // directly.. a no no.
 }


 Curt.
 --
 cat .signature: No such file or directory

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



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



Re: [PHP] Clear POST variables

2006-02-16 Thread John Wells
I'm curious to hear what others say, but I tend to build into my
application flow a header(Location: someurl) redirect after a form
submission.  It's just as if you were to include(somefile) the
resulting page, but by using header() you are moving the user away
from the action so that this sort of thing won't happen.  In my
experience it also helps with a user's tendency to use the back
button--which is not wrong, it can just get in the way of rich
applications.

Cheers,
John


On 2/16/06, Mike Tuller [EMAIL PROTECTED] wrote:
 I have a page that submits form information into a database, and all is
 good, but someone testing the page pointed out something to me that I
 didn't notice. I have a form that sends you to another page that submits
 the data into a database. If you refresh the page, the information is
 submitted again. Here is what I have.

  $name = $_POST['name'];
  $address = $_POST['address'];
  $city = $_POST['city'];
  $state = $_POST['state'];
  $zipcode = $_POST['zipcode'];
  $phone = $_POST['phone'];
  $notes = $_POST['notes'];

  $query = insert into Locations
  (name, address, city, loc_state,
 main_phone, zipcode, notes)
  values
  ('$name', '$address', '$city',
 '$state', '$phone', '$zipcode',
 '$notes');

  mysql_query($query, $link) or die
 (mysql_error());


 How do I clear out the POST variables, or the variables that I have
 set from the POST variables, so that when the page is refreshed it
 will not resubmit.  I have tried unset() and have tried to set it to and
 empty value, but it doesn't seem to work.


 Thanks.

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



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



Re: [PHP] PHP Devel Environments???

2003-03-20 Thread John Wells
Henrik,

Why not use Smarty and create your own functions for your designers to
use?  That's one of it's purposes, after all.

John

Henrik Hudson said:
 Hey List-

 Any one have some input on some good GUI WYSIWYG devel enviroments for
 creating PHP scriptlets. The boss wants to lose the dependancy on the
 2  programmers (myself and another person) for every little piece of
 PHP code.  Of course, the graphic designers have no desire to learn
 source code, so we  have to see if there are any WYSIWYG's out there
 that will allow them to  create code chunks to either do webforms or
 handle simple variable passing  between pages?

 My argument is that it is to wide open and there are too many
 variables that  need to be taken into account for this to happen.

 We did look at Dreamweaver MX, but it's PHP support is limited to syntax
  highlighting and being able to insert if and else clauses. I'd tell'em
 to use  gvim, but I don't think that would fly :) The boss says there
 are some  Dreamweaver extensions for doing some of this stuff, but I
 still question  their quality for open ended stuff like writing PHP.

 Thanks.

 Henrik

 --

 Henrik Hudson
 [EMAIL PROTECTED]

 You know, Hobbes, some days even my lucky
 rocket ship underpants don't help.  Calvin

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




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



Re: [PHP] What happened to phpEdit???

2003-02-17 Thread John Wells
Hmm...doesn't work here.  Interesting.  Partial blackout?

John Nichel said:
 It works fine for me.  So does www.phpedit.net

 Al wrote:
 Did you try the URL you posted?

 I tried that one and several others listed for phpEdit.

 All say the site is not responding.

 Bryan Lipscy wrote:

 Did you check google?
 http://ozu.arecom-sa.com/~marms/phpedit.net/

 -Original Message-
 From: Al [mailto:[EMAIL PROTECTED]] Sent: Sunday, February 16, 2003
 8:39 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] What happened to phpEdit???


 Their site no longer responds.

 Surely, we haven't lost one of the best php editors.







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




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




[PHP] PHP Style Conventions

2003-02-15 Thread John Wells
Looking for info on recommended PHP style conventions.  I've seen the Pear
style conventions, and they seem fairly good, but I'm interested in
something that covers more ground, like what's the best way to name
included files (*.inc?) class files, etc., what's the recommended dir
structure for large projects (i.e., does efficiency decrease with greater
numbers of include directories)?

Is there anything out there that will answer my questions?  Anything
driven by php.net?

Thanks,

John




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




Re: [PHP] Object In a class

2003-02-09 Thread John Wells
Justin Mazzi said:
 Can anyone tell me how to use an object within an object. Example


 class blah {
   var $test;
   var $test2;

   function test() {
   $this-do();
   }

 }


 then you want to use that class in a new one.


 class blah2 {
   var $test;
   var $test2;

   function do() {
   $blah = new blah();
   }

 }


Well, you could use the blah object you created exclusively in function
do(), or you could create it as a attribute of your class and use it in
your instantiated objects, as:

class blah2 {
var $test;
var $test2;
var $myBlah;

function blah2()
{
$this-myBlah = new blah();
}

function do() {
$this-myBlah-test();
}

}

$myobj = new blah2();

$myobj-do();





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




Re: [PHP] Reporting tools for PHP?

2003-01-30 Thread John Wells
Denis,

I've been looking as well.  My solution?  Run Jasper Reports
(http://jasperreports.sf.net) from a Tomcat container integrated with
Apache via mod_jk.so.  Don't have any reports finished yet, so not sure of
speed, etc., but Jasper looks to be pretty full featured and it freely
available.

HTH,

John

Denis L. Menezes said:
 hello Friends?

 Is there any reporting toold for PNH/MySQL like there is Crystal Reports
 etc?

 Thanks
 denis




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




Re: [PHP] Reporting tools for PHP?

2003-01-30 Thread John Wells
Because Crystal Reports is an overpriced rip-off.  To get full web report
functionality, you have to pay anywhere from $1-$10 for their
enterprise edition.  If you pay anything less, you're limited to only
three connections.

Why buy anything when good open source solutions exist?  Makes no sense. 
Just support the OS projects...make a donation.

John

Tyler Lane said:
 On Thu, 2003-01-30 at 08:57, Denis L. Menezes wrote:
 hello Friends?

 Is there any reporting toold for PNH/MySQL like there is Crystal
 Reports etc?
 Do you mean PHP/MySQL?

 if that is the case, why not use Crystal Reports?
 Setup MyODBC for your MySQL server and use ODBC to connect to it using
 Crystal Reports.


 Thanks
 denis
 --
 Tyler Lane
 [EMAIL PROTECTED]

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






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




[PHP] Best PHP db wrapper?

2003-01-29 Thread John Wells
Trying to decide between wrappers for a rather large application, and
wanted some input from the group as I haven't used any of these to any
degree.  So far, I've found PearDB, metabase, adodb, and MDB.

What's the best option?  My main concerns are speed and good community
support.

All input is *greatly* appreciated.

Thanks,
John





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




[PHP] Java call on object causes segfault.

2003-01-26 Thread John Wells
Working on getting Java integration going.  I was able to get it to work
with the online example and can create an object of java.lang.System and
print various properties returned from there.

However, if I create my own class, I can instantiate it, but if I call a
method on that class it causes a SIGSEV.

Could anyone provide some insight?

Here's the code and backtrace:

This is with Sun jdk 1.4.1_1, php-4.2.3 on Red Hat 8.0.

?

$obj = new Java('com.x.reports.Serv');

print $obj-getMsg();
?

--- java code stored off of class path in com/x/reports ---
package com.x.reports;

class Serv
{
public String msg = THIS IS A TEST MESSAGE;

Serv()
{

}

public String getMsg()
{
return this.msg;
}

}

-- BACKTRACE ---
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 8192 (LWP 9303)]
0x402da2cb in java_call_function_handler (ht=0, return_value=0x8114d14,
this_ptr=0x810d604, return_value_used=1, property_reference=0xbfffdf54)
at java.c:464
464 obj = zend_list_find(Z_LVAL_PP(handle), type);
(gdb) bt
#0  0x402da2cb in java_call_function_handler (ht=0,
return_value=0x8114d14, this_ptr=0x810d604, return_value_used=1,
property_reference=0xbfffdf54) at java.c:464
#1  0x40191553 in call_overloaded_function (T=0xbfffdf48, arg_count=0,
return_value=0x8114d14) at zend_execute.c:953
#2  0x40194636 in execute (op_array=0x8114b6c) at zend_execute.c:1660
#3  0x401a40a3 in zend_execute_scripts (type=8, retval=0x0,
file_count=3) at zend.c:812
#4  0x401b5aaf in php_execute_script (primary_file=0xb450) at
main.c:1383
#5  0x401b0aba in apache_php_module_main (r=0x8107004,
display_source_mode=0) at sapi_apache.c:90
#6  0x401b18ea in send_php (r=0x8107004, display_source_mode=0,
filename=0x8107b34 /opt/apache_1.3.27/htdocs/t.php) at mod_php4.c:575
#7  0x401b1963 in send_parsed_php (r=0x8107004) at mod_php4.c:590
#8  0x08074880 in ap_invoke_handler ()
#9  0x08088c76 in process_request_internal ()
#10 0x08088cd6 in ap_process_request ()
#11 0x0807ff9a in child_main ()
#12 0x0808013a in make_child ()
#13 0x080802a1 in startup_children ()
#14 0x080808ce in standalone_main ()
#15 0x080810ec in main ()
#16 0x420158d4 in __libc_start_main () from /lib/i686/libc.so.6




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




Re: [PHP] Java call on object causes segfault.

2003-01-26 Thread John Wells
Philip,

Thanks.  I did submit a bug report and also compiled with debug.  That's
where the backtrace captured in my email came from.  If you'd like to veiw
the bug report, it can be found at: http://bugs.php.net/bug.php?id=21881

I'll try 4.3.0 and see what happens.  I was holding back because I use the
Zend Debug Server, and it doesn't support 4.3.0 just yet.  But, it will
soo, so might as well.

Thanks!
John


Philip Olson said:

 Whenever you get a segfault, try the latest
 stable release and during compile be sure to
 use --enable-debug
 :
   http://snaps.php.net/

 If the segfault exists here, write a bug report
 and include the backtrace:

   http://bugs.php.net/how-to-report.php
   http://bugs.php.net/

 This will be of great help to the php-dev team. Also
 I believe many changes to the Java extension went
 into 4.3.0 so maybe it'll work for you.

 Regards,
 Philip


 On Sun, 26 Jan 2003, John Wells wrote:

 Working on getting Java integration going.  I was able to get it to
 work with the online example and can create an object of
 java.lang.System and print various properties returned from there.

 However, if I create my own class, I can instantiate it, but if I
 call a method on that class it causes a SIGSEV.

 Could anyone provide some insight?

 Here's the code and backtrace:

 This is with Sun jdk 1.4.1_1, php-4.2.3 on Red Hat 8.0.

 ?

 $obj = new Java('com.x.reports.Serv');

 print $obj-getMsg();
 ?

 --- java code stored off of class path in com/x/reports ---
 package com.x.reports;

 class Serv
 {
 public String msg = THIS IS A TEST MESSAGE;

 Serv()
 {

 }

 public String getMsg()
 {
 return this.msg;
 }

 }

 -- BACKTRACE ---
 Program received signal SIGSEGV, Segmentation fault.
 [Switching to Thread 8192 (LWP 9303)]
 0x402da2cb in java_call_function_handler (ht=0,
 return_value=0x8114d14, this_ptr=0x810d604, return_value_used=1,
 property_reference=0xbfffdf54) at java.c:464
 464 obj = zend_list_find(Z_LVAL_PP(handle), type);
 (gdb) bt
 #0  0x402da2cb in java_call_function_handler (ht=0,
 return_value=0x8114d14, this_ptr=0x810d604, return_value_used=1,
 property_reference=0xbfffdf54) at java.c:464
 #1  0x40191553 in call_overloaded_function (T=0xbfffdf48,
 arg_count=0, return_value=0x8114d14) at zend_execute.c:953
 #2  0x40194636 in execute (op_array=0x8114b6c) at zend_execute.c:1660
 #3  0x401a40a3 in zend_execute_scripts (type=8, retval=0x0,
 file_count=3) at zend.c:812
 #4  0x401b5aaf in php_execute_script (primary_file=0xb450) at
 main.c:1383
 #5  0x401b0aba in apache_php_module_main (r=0x8107004,
 display_source_mode=0) at sapi_apache.c:90
 #6  0x401b18ea in send_php (r=0x8107004, display_source_mode=0,
 filename=0x8107b34 /opt/apache_1.3.27/htdocs/t.php) at
 mod_php4.c:575 #7  0x401b1963 in send_parsed_php (r=0x8107004) at
 mod_php4.c:590 #8  0x08074880 in ap_invoke_handler ()
 #9  0x08088c76 in process_request_internal ()
 #10 0x08088cd6 in ap_process_request ()
 #11 0x0807ff9a in child_main ()
 #12 0x0808013a in make_child ()
 #13 0x080802a1 in startup_children ()
 #14 0x080808ce in standalone_main ()
 #15 0x080810ec in main ()
 #16 0x420158d4 in __libc_start_main () from /lib/i686/libc.so.6




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



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




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




[PHP] Java problem...need advice.

2003-01-25 Thread John Wells
Trying to get java working so I can make native calls.

I've got php.ini setup and it seems to work (i.e., I can use the online
(php.net) example and create a java.lang.System object, and access
properties from it).

However, created my own class in a directory I specified in my
java.class.path directive and it doesn't seem to work.  I get Document
contains no data.  I can comment out the method call on $obj and it
prints my message, so I can only assume it's creating the object.

However, if I call a method on the object, I get the message.  By watching
the task bar, I see the Connecting to localhost.../Sending request to
localhost sequence being repeated every 5 secs or so.

Can anyone help me out?  I'd really appreciate it.  See code below:

?


$obj = new Java('com.x.reports.Serv');

print $obj-getMsg();
?

--- java code stored off of class path in com/x/reports ---
package com.x.reports;

class Serv
{
public String msg = THIS IS A TEST MESSAGE;

Serv()
{

}

public String getMsg()
{
return this.msg;
}

}



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




[PHP] Php support for Java

2003-01-24 Thread John Wells
In an app I'm developing I have a need to call java classes, and am hoping
to use PHP's java integration.

However, the manual page (http://www.php.net/manual/en/ref.java.php) says
This extension is EXPERIMENTAL. The behaviour of this extension --
including the names of its functions and anything else documented about
this extension -- may change without notice in a future release of PHP.
Use this extension at your own risk.

My question is, how EXPERIMENTAL is it?  Anyone using it in a production
system?  Have any problems yet?  I may be willing to risk it, but wanted
to hear lessons learned from others on the list.

Thanks,
John





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




Re: [PHP] php performance

2003-01-23 Thread John Wells
Chris,

Can we see your test code?

John

arch said:
 Nope. It's tested with a typical client/server setup, as in a real use
 case.


 Chris McCluskey [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]..
 .
 I'm going to ask the really stupid question... Is mysql, php, apache
 running on the same box as the box you are using to test from?

 -Chris

 -Original Message-
 From: arch [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, January 23, 2003 1:42 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] php performance


 I'm running php4 on apache on linux. I'm having performance problems
 with php getting data from the mysql database. With one user at a given
 instant, performance is fine, even with the massive size of the data
 table. But when do very rudimentary load testing (basically, opening a
 few browser and performing the same requests), the performance is awful.
 I suppose the issue is with mysql, but I can't be sure.

 What are some solutions to performance issues such as these? I've
 already done mysql indexing, which is how I got the current level of
 performance. But again, performance is unsatisfactory with just a few
 simultaneous requests.

 Thanks in advance.



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




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




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




Re: [PHP] Who is foo what is bar?

2003-01-23 Thread John Wells
Ummm...and this has what to do with PHP?

http://www.catb.org/~esr/jargon/html/entry/foobar.html



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




[PHP] PHP App Frameworks

2003-01-22 Thread John Wells
Ramping up on a large project and was wondering if there are any freely
(as in speech) available app frameworks or toolkits for PHP that would
save me from recreating the wheel.

I'd prefer something relatively mature and well documented.

Thanks for any input!

John





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




[PHP] A Licensing Question

2003-01-22 Thread John Wells
I was wondering what the licensing issues for app frameworks (or any
included PHP classes/libs) are.  I'm creating a rather large PHP
application for a company, and they'd like to potentially resell it to
some of their customers.

Can I safely use GPL'd libraries, classes, etc. (i.e. PearDB) and
resources that fall under other open source licenses when developing the
app and let them redistribute accordingly, or would that be a violation? 
Also, thinking ahead here a bit, if they wanted to use something like Zend
Encoder on the project, what sort of added gotchas could that bring up?

Thanks guys!

John





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




Re: [PHP] A Licensing Question

2003-01-22 Thread John Wells
 However - if you want to sell software under a closed licence you will
 need to be carefull to avoid 'linking' with gpl'd code.
 The problem is that 'linking' as used in the gpl seems to refer to C
 programming - and is an unclear term when refering to php.


Yeah...that's really what I'm wondering.  If I have my own code, but make
function calls and the like to script libraries licensed under the GPL,
does it mean my code will have to be GPL'd as well?  It's not dynamically
linking binary code in.  I've read the GPL faq and it's very vague here. 
It considers interpreted programs data, but doesn't consider cases the
that data is licensed under the GPL.

Say, for instance, that I use a GPL'd library that provides a class called
myGPLClass.  If I create instances of myGPLClass in my own scripts, does
that make my code in violation of the GPL?

Damn, I need a law degree ;-).

John



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




Re: [PHP] A Licensing Question

2003-01-22 Thread John Wells
Peter Hutnick said:
 Yeah...that's really what I'm wondering.  If I have my own code, but
 make function calls and the like to script libraries licensed under
 the GPL, does it mean my code will have to be GPL'd as well?

 In a word, yes.

Even if the script libraries are themselves just PHP scripts...not any
binary code being linked into the interpreter?  I'm still unclear here.

 Say, for instance, that I use a GPL'd library that provides a class
 called myGPLClass.  If I create instances of myGPLClass in my own
 scripts, does that make my code in violation of the GPL?

 No.  Use is not restricted in any way by the GPL.  In fact, you needn't
 even /agree/ to the GPL in order to use GPLed software in any way you'd
 like, only to (re)distribute it.

Hmmmnow I think I understand what you mean, but if I consider it in
the context of my question and with your above statement, it seems
contradictory.  I don't think it's that you're misunderstanding me...I
think it's me misunderstanding you ;-).

Let me lay it out:

Say you create a set of class libraries, called PeterLib, and release it
under the GPL.  I download these libraries...like what you've done...and
decide to use them in my development.  Your library makes available a
class called FooBar that I really like, and I decide to make use of it in
a number of my own files.

So, one of the core files in my application contains:

?
require_once(/PeterLib/FooBar.inc);

$myObj = new FooBar();

$myObj-getFoo();

$myObj-printBar();

?

Now, futher assume that I want to sell my application under my own
company's license and I label all my files as such, but still retain your
GPL license it the PeterLib files.  I rush to market and have an
overwhelming amount of customers in the first month.

Four issues:
1. Have I violated the GPL by distributing your code with my propietary,
non-open source app?  I'm still distributing source, but my specific files
(including a few that call PeterLib classes) are not GPL'd.

2. If I decided to only distribute my own source for money under my own
propietary license, but told my customers that in order for my application
to function correctly, they'd need to download PeterLib.  Is this a
violation?

3.  If the above are considered violations, I assume only using libraries
licensed under licenses like the LGPL or PHP would make it safe for me to
redistribute with my proprietary app?

4.  How do the above change if/when I decide to encode my self-written
files with Zend Encoder?

Thanks very much for all your input.  Very helpful.  I really appreciate it.

John








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




Re: [PHP] A Licensing Question

2003-01-22 Thread John Wells
Chris,

Sheesh.  I'd read it about 5 times but revisited just now.  Somehow I
missed the key phrase which are themselves interpreted..

Here's the full relevant excerpt:

Another similar and very common case is to provide libraries with the
interpreter which are themselves interpreted. For instance, Perl comes
with many Perl modules, and a Java implementation comes with many Java
classes. These libraries and the programs that call them are always
dynamically linked together.

A consequence is that if you choose to use GPL'd Perl modules or Java
classes in your program, you must release the program in a GPL-compatible
way, regardless of the license used in the Perl or Java interpreter that
the combined Perl or Java program will run on. 

That answers my question.  If following the scenario I described
previously, my code would have to be GPL'd as well.

Thanks!
John





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




RE: [PHP] NEED HELP URGENTLY

2003-01-22 Thread John Wells
AND PLEASE STOP YELLING

HiTCHO said:
 Global Variables are turned off!!! check php.ini!!



 Timothy Hitchens (HiTCHO)
 Open Source Consulting
 e-mail: [EMAIL PROTECTED]

 -Original Message-
 From: Dale [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, 23 January 2003 10:02 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] NEED HELP URGENTLY


 I SETUP THE PHP PARSE ENGINE ON ABOUT A YEAR AGO ON ONE OF MY
 WEB SERVERS AND EVERYTHING WORKED JUST FINE. I, HOWEVER,
 RECENTLY ACQUIRED A NEW SERVER AND TRIED TO SETUP PHP AGAIN
 ON IIS 5.0 ON A WIN 2K SERVER PLATFORM. EVERYTHING SEEMS TO
 BE WORKING CORRECTLY, BUT FOR SOME REASONS WHEN I TRY TO
 ACCESS ANY VARIABLES PASSED FROM A HTML FORM, I ALWAYS GET AN ERROR.

 FOR EXAMPLE IF I HAVE A FORM THAT PASSES THE VARIABLE $ACTION
 I GET THE FOLLOW ERROR WHEN I TRY TO ACCESS THE SAME VARIABLE
 IN PHP PAGE:

 Notice: Undefined variable: action in
 C:\...\otelzoo.com\cust_care.php on line 9

 I HAVE REINSTALLED THE PHP PARSER THREE TIMES NOW AND I HAVE
 HAD NO LUCK IN GETTING RID OF THIS PROBLEM. I KNOW MOST
 PEOPLE WILL JUMP TO THE CONCLUSION THAT THERE IS A SIMPLE
 ERROR IN THE ACTUAL SOURCE CODE ITSELF, BUT I PROMISE YOU
 THAT I HAVE BEEN PROGRAMMING IN THIS LANGUAGE FOR AT LEAST
 TWO YEARS AND I AM 100% SURE THAT I AM PASSING THE VARIABLE CORRECTLY.

 PLEASE HELP.

 THANK YOU.
 - DALE




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



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




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




[PHP] Jasper Reports and PHP

2003-01-22 Thread John Wells
Anyone tried to use Jasper Reports with PHP?  Jasper is a java reporting
tool, but I need an os alternative to Crystal Reports and am hoping it
might fit the bill.

I *think* I could integrate Jasper into my app fairly well with PHP's
ability to call Java classes, but wanted to hear from anyone else with
experience in this area.

Thanks,
John





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




[PHP] Speed concerns with OOP and PHP4

2003-01-16 Thread John Wells
I'm working on a large VB/Sql Server to Php/Postgresql conversion (approx.
60k lines of code).

I'd like to design this thing as OO as possible, because I think
ultimately it leads to better, more extendable and readable software. 
However, since php does the whole copy thing with objects, I'm a little
concerned.

Is this deficiency on the part of PHP 4 something I should be concerned
about?  If I have a 60k loc fully object-oriented php app with a large
amount (approx. 500 or so) queries to a db, am I making a mistake by going
OO?  Will it really slow down the app *that* much, or consume memory like
a pack of hungry piranhas?

Thanks for the input, guys.

John





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




[PHP] Gotchas with Php and Postgresql?

2003-01-14 Thread John Wells
I'm preparing for a large project in which I'm the sole
designer/developer.  I've just about made the decision to go with
Postgresql, as part of the project is converting a MS Sql Server db to a
open source db and I think Postgresql provides some features that will
make this port easier.

However, just wondering if there're any gotchas I need to consider here.
 I'm definitely using PHP to write the app, and I can attest to PHP's
great support for mysql (used it many, many times), but I have no
experience using it with Postgresql.

While I suspect that it's just as easy to work with via PHP as is MySql,
I'm looking for any hardened, trenches-earned wisdom anyone would like to
bestow.

Thanks very much.

John





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




Re: [PHP] Zend IDE vs. PhpEd

2003-01-06 Thread John Wells
I've tried phpEdit, but unfortunately it's a Windows-only IDE and has
quite a few reproduceable bugs (I get an access violation almost everytime
I use the latest version.  I do all my development in Linux, so it won't
cut it.

Thanks!

John





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




Re: [PHP] MySQL vs PostgreSQL

2003-01-06 Thread John Wells
 See MySQL 4.x. They also have subselects now (HUGE!). As for an

Well, not really.  Nested queries are scheduled for 4.1.   4.0 is in
gamma, 4.1 isn't even available for download as alpha.  You'll have to go
with Postgres for now if you need subselects.

Regarding row locking and transactions, look at the InnoDB table type,
which is fully ACID compliant.

John





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




[PHP] Designing in PHP4 with PHP5 in mind...

2003-01-06 Thread John Wells
I'm preparing for a project in which I'll be porting and redesigning a
large, ugly Visual Basic/Sql Server app to a PHP/Mysql or Postgresql based
web application.

I'd like to code in a way that will be at the same time easily ported to
PHP5 and that will take advantage of PHP5's new object handling
efficiencies.  I've read varying reports of whether syntax will be
different.

Is there anything I should watch for, add, or specifically avoid while
coding this application to make the transition as easy as possible?

Thanks!
John





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




[PHP] Zend IDE vs. PhpEd

2003-01-05 Thread John Wells
Can anyone who's familiar with both give an honest, open evaluation?  I'm
in a rush project and need something quickly (have to purchase tomorrow),
but I'm on the fence when it comes to these two products.

Zend costs $100 less than Phped, so I'm leaning that way.  But if there's
anything you know that could make my decision easier, please forward it
on.  They seem pretty comparable, with the exception of PhpEd's db
browser.

Thanks!

John



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




Re: [PHP] Zend IDE vs. PhpEd

2003-01-05 Thread John Wells
Sterling,

Thanks for the reply.  I'm also impressed with Zend's autocompletion...I
can't even get PHPEd to autocomplete on objects.

I wonder if Zend uses dbg as well.  It'd be nice to see a profiler thrown
into a future version.

Finally, one frustrating thing on the part of both editors is the
inability to autocomplete on arrays of object references...but I suppose
that's a little difficult with a dynamically typed language.

Thanks!

John




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




[PHP] Where the hell did my session vars go?!?

2001-05-18 Thread John Wells


I'm having serious issues with session management in PHP and am trying
to
determine if it's a problem with my hosting company or a problem in my
code.

The flow of my site is:

login_page - session_start_page - form_page - display_results_page

Upon login a POST is made to session_start_page.  This page checks that
the user
exists in the database and then creates a session and populates a
session
variable ($session_id) to 123456.  session_start_page then calls
header(location) to forward to the form_page.  I output the $session_id
for
debugging purposes on every page following the session_start_page

The problem occurs as such:

Upon initial login, when the user reaches the form_page the $session_id
is
populated and prints 123456.  However, when a user submits the form
and a GET
is made to display_results_page, the $session_id has been deleted (i.e.,
prints
no value).  Since my code relies on the $session_id variable for
security, this
causes the user to be forwarded to an intermediate error page and then
back to
the login_page.

Upon the second login, everything functions as I would expect it
to...the
session_id variable is populated on every screen and no error occurs.

At first I thought the problem might be the version of PHP my hoster was
using.
Up until a week ago, the version was 4.0.4pl1.  However, the server was
upgraded
to PHP 4.0.5 last week.  Now, the problem seems to be fixed in Netscape
4.07 but
still occurs when using IE 4.

I'm at a loss. I've done quite a bit of research in to this problem and
haven't
found an answer.  Any help anyone could provide would be much
appreciated.  The
code is as follows:

---

host.php (configuration file)
---

?
$base_href=http://x/membership/;;
$dbuser=user;
$dbpass=pass;
$dbhost=localhost;
$database=members;
$member_table=MEMBERS;
$login_table=LOGIN;
?
---

login_page.php
---

HTML
HEADTITLELogin/TITLE
/HEAD
BODY BGCOLOR=white
h4Please login to view the member database:/h4
FORM name=login ACTION=session_start_page.php METHOD=POST
TABLE name=login_table
TRTDUsername: /TDTDINPUT NAME=username
TYPE=text/INPUT/TD/TR
TRTDPassword: /TDTDINPUT NAME=password
TYPE=password/INPUT/TD/TR
TRTD COLSPAN=2INPUT TYPE=submit value=login/INPUT/TD/TR
/TABLE
/FORM
/BODY
/HTML
---

session_start_page.php
---

?
include(host.php);

mysql_pconnect($dbhost, $dbuser, $dbpass);

$db= $database;

$table = $member_table;

$result = mysql_db_query($db, select username, password from
$login_table);

while ($row=mysql_fetch_row($result))
{
 if (($username==$row[0])($password==$row[1]))
{
$logged=true;
}
}
if ($logged==true)
{

 session_start();

session_register('session_id');

$session_id = 123456;

header(location:form_page.php);
}
else
{
print Invalid login!;
}
?
---

form_page.php
---

?
include(host.php);

session_start();

if($session_id)
{
?
HTML
HEADTITLEMember Information/TITLE
BASE HREF=?=$base_href?
/HEAD
BODY BGCOLOR=WHITE
? print SESSION: $session_idBR; ?
FORM NAME=SEARCH_MEMBERS METHOD=POST
ACTION=display_results_page.php
TABLE
TR
TDLast Name: /TDTDINPUT TYPE=TEXT NAME=LASTNAME/INPUT/TD
/TR
TR
TDFirst Name: /TDTDINPUT TYPE=TEXT NAME=FIRSTNAME/INPUT/TD
/TR
TR
TDStreet: /TDTDINPUT TYPE=TEXT NAME=STREET/INPUT/TD
/TR
TR
TDCity: /TDTDINPUT TYPE=TEXT NAME=CITY/INPUT/TD
/TR
TR
TDState: /TDTDINPUT TYPE=TEXT NAME=STATE/INPUT/TD
/TR
TR
TDZip: /TDTDINPUT TYPE=TEXT NAME=ZIP/INPUT/TD
/TR
TR
TDPhone: /TDTDINPUT TYPE=TEXT NAME=PHONE/INPUT/TD
/TR
TR
TD COLSPAN=2INPUT TYPE=SUBMIT VALUE=SEARCH/INPUT/TD
/TR
/TABLE
/FORM
/BODY
/HTML
? }
   else
   {
?
HTML
BODY onLoad=location.href='error.html'
/BODY
/HTML
? } ?
---

display_results_page.php
---

?
include(host.php);

session_start();

if(session_is_registered(session_id))
{
?
HTML
HEADTITLERESULTS/TITLE
BASE HREF=?=$base_href?
/HEAD
BODY BGCOLOR=white
?
 print Session_id: $session_idBR;

if ($COMMAND==0)
{
 $dbh = mysql_connect($dbhost, $dbuser, $dbpass);

 mysql_select_db($database);

 $stmt = SELECT * FROM $member_table ;

 if ($LASTNAME)
 {
 $TEMP .= (($TEMP) ?  AND  :  WHERE ) . LAST_NAME LIKE

Re: [PHP] Where the hell did my session vars go?!?

2001-05-18 Thread John Wells

Here's the server config if it's more help.  Thanks!!!
John

PHP Version 4.0.5

System Linux xxx 2.2.16-3 #1 Mon Jun 19 18:10:14 EDT 2000 i686
unknown
Build Date May 17 2001
Configure Command './configure' '--with-mysql' '--with-apache=../apache_1.3.19'
'--enable-track-vars' '--with-xml' '--enable-memory-limit=yes' '--enable-bcmath'
'--with-gd=/usr/local/' '--with-gdbm=/usr/include' '--with-zlib=/usr/include'
'--with-ttf' '--with-jpeg-dir=/usr/local/lib' '--with-mcrypt' '--with-sablot='
'/usr/local/lib' '--enable-sablot-errors-descriptive'
Server API Apache
Virtual Directory Support disabled
Configuration File (php.ini) Path /usr/local/lib/php.ini
ZEND_DEBUG disabled
Thread Safety disabled

 This program makes use of the Zend scripting language engine:
Zend Engine v1.0.5, Copyright (c) 1998-2001 Zend Technologies



PHP 4.0 Credits

Configuration
PHP Core
Directive Local Value Master Value
allow_call_time_pass_reference
 On On
allow_url_fopen
 1 1
arg_separator
  
arg_separator.input
  
arg_separator.output
  
asp_tags
 On On
auto_append_file
 no value no value
auto_prepend_file
 no value no value
browscap
 no value no value
default_charset
 no value no value
default_mimetype
 text/html text/html
define_syslog_variables
 Off Off
disable_functions
 no value no value
display_errors
 On On
display_startup_errors
 Off Off
doc_root
 no value no value
enable_dl
 On On
error_append_string
 Off Off
error_log
 no value no value
error_prepend_string
 Off Off
error_reporting
 2039 2039
expose_php
 On On
extension_dir
 ./ ./
file_uploads
 1 1
gpc_order
 GPC GPC
highlight.bg
 #FF #FF
highlight.comment
 #FF8000 #FF8000
highlight.default
 #BB #BB
highlight.html
 #00 #00
highlight.keyword
 #007700 #007700
highlight.string
 #DD #DD
html_errors
 On On
ignore_user_abort
 Off Off
implicit_flush
 Off Off
include_path
 .:/usr/local/lib/php .:/usr/local/lib/php
log_errors
 Off Off
magic_quotes_gpc
 On On
magic_quotes_runtime
 Off Off
magic_quotes_sybase
 Off Off
max_execution_time
 30 30
memory_limit
 8M 8M
open_basedir
 no value no value
output_buffering
 Off Off
output_handler
 no value no value
post_max_size
 8M 8M
precision
 14 14
register_argc_argv
 On On
register_globals
 On On
safe_mode
 Off Off
safe_mode_exec_dir
 no value no value
sendmail_from
 [EMAIL PROTECTED] [EMAIL PROTECTED]
sendmail_path
 /usr/sbin/sendmail -t -i  /usr/sbin/sendmail -t -i
short_open_tag
 On On
SMTP
 localhost localhost
sql.safe_mode
 Off Off
track_errors
 Off Off
upload_max_filesize
 1M 1M
upload_tmp_dir
 /tmp /tmp
user_dir
 no value no value
variables_order
 EGPCS EGPCS
y2k_compliance
 Off Off
zlib
ZLib Support enabled
'zlib:' fopen wrapper enabled
Compiled Version 1.1.3
Linked Version 1.1.3
xml
XML Support active
XML Namespace Support active
standard
Regex Library Bundled library enabled
Dynamic Library Support enabled
Path to sendmail /usr/sbin/sendmail -t -i

Directive Local Value Master Value
assert.active
 1 1
assert.bail
 0 0
assert.callback
 no value no value
assert.quiet_eval
 0 0
assert.warning
 1 1
safe_mode_allowed_env_vars
 PHP_ PHP_
safe_mode_protected_env_vars
 LD_LIBRARY_PATH LD_LIBRARY_PATH
session.use_trans_sid
 1 1
session
Session Support enabled

Directive Local Value Master Value
session.auto_start
 Off Off
session.cache_expire
 180 180
session.cache_limiter
 nocache nocache
session.cookie_domain
 no value no value
session.cookie_lifetime
 0 0
session.cookie_path
 / /
session.cookie_secure
 Off Off
session.entropy_file
 no value no value
session.entropy_length
 0 0
session.gc_maxlifetime
 1440 1440
session.gc_probability
 1 1
session.name
 PHPSESSID PHPSESSID
session.referer_check
 no value no value
session.save_handler
 files files
session.save_path
 /tmp /tmp
session.serialize_handler
 php php
session.use_cookies
 On On
sablot
Sablotron XSLT support enabled
posix
Revision $Revision: 1.27 $
pcre
PCRE (Perl Compatible Regular Expressions) Support enabled
PCRE Library Version 3.4 22-Aug-2000
mysql
MySQL Support enabled
Active Persistent Links 0
Active Links 0
Client API version 3.23.32
MYSQL_INCLUDE
MYSQL_LFLAGS
MYSQL_LIBS

Directive Local Value Master Value
mysql.allow_persistent
 Off Off
mysql.default_host
 no value no value
mysql.default_password
 no value no value
mysql.default_port
 no value no value
mysql.default_socket
 /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock
mysql.default_user
 no value no value
mysql.max_links
 Unlimited Unlimited
mysql.max_persistent
 5 5
mcrypt
mcrypt support enabled
version 2.4.x
Supported ciphers twofish rijndael-128 rijndael-192 rijndael-256 saferplus rc2 xtea
serpent safer-sk64 safer-sk128 cast-256 loki97 gost threeway cast-128 des tripledes
enigma arcfour panama wake
Supported modes ofb cfb nofb cbc ecb stream

Directive Local Value Master Value
mcrypt.algorithms_dir
 no value no value
mcrypt.modes_dir
 no value no value
gd
GD Support enabled
GD Version 1.6.2 or higher
JPG Support enabled
PNG Support enabled
WBMP Support enabled

Re: [PHP] IIS5.0/PHP4.03 killing all sessions. HELP!!!!

2001-05-18 Thread John Wells

I have this problem as well (see Where the hell did my session vars go?).

We were using 4.0.4pl1 and it was occuring under both Netscape 4.74 and IE 5.5.

We upgraded PHP to version 4.0.5 and everything works nicely under Netscape, but IE 
5.5 is
still screwing up.

Just for info...

Thanks,
John

Diego Fulgueira wrote:

 Hi!. I have the following problem (we are going crazy about it!!) and i
 think there's many people out there that have experienced the same thing:

 A session created in one page is killed on the next one. Check an example:
 PAGE 1:
 session_start();
 session_register(myvar);
 $myvar=hello;
 PAGE 2:
 session_start();//A new session_id is generated...!!
 //...Instead of using the already created one...!
 //...Even when PHPSESSID is passed on as a 
get-variable!!.
 echo $myvar;  //$myvar does not exist!!!.
 echo $HTTP_SESSION_VARS[myvar]; //$HTTP_SESSION_VARS[myvar] does not
 exist either!!!.

 Here are some configuration parameters I am using:

 session.use_cookies ON (I tried OFF also without success).
 session.auto_start  OFF (I tried ON also without success).
 session.use_trans_sid ON (I tried OFF also without success).
 register_globals ON
 track_vars ON

 HERE ARE SOME CLUES:
 1.The session files in the server are being written fine, their contents
 look fine MOST of the time, although sometimes not all session vars or
 values are being written or files are empty. Read and write permissions in
 the directory have been double checked.

 2.Sometimes sessions last trough one or two pages after the first
 session_start(), but then they are killed on each and every page.

 HELP PLEASE!!
 Any ideas will be greatly appreciated since I've tried almost all that has
 come to my mind.

 THANKS A LOT IN ADVANCE.
 Cheers to everyone,
 Diego.

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]