Re: [PHP] HTTP compression

2001-02-04 Thread Teodor Cimpoesu



Alain Fontaine wrote:
 
 Sean,
 
 Thanks, I see. How about headers ? Do they need to be compressed, too; in
 other words, do headers "belong" to the output ?

a HTTP response is made of response header(s) and the response body.
Only the body
is compressed, and this is signaled in the headers so the User Agent
will know
not to stare to a bunch of binary data :)

-- teodor

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




Re: [PHP] Newbie:Cannot send session cookie...

2001-02-04 Thread Teodor Cimpoesu



james wrote:
 
 1. Cannot send session cookie - headers already sent by (output started at
 c:/program files/apache group/apache/htdocs/index.php4:10) in c:/program
 files/apache group/apache/htdocs/index.php4 on line 11
 
 What does it mean?
 
 Any hints?
the error message is quite explicit. By the time it reaches the line 11
in index.php4
you already sent something to output, so if you have on index.php4:11
something like
header(), setCookie() or session_start() which imply sending a header,
is no longer 
possible [ you cannot send a header after you already started sending
the body ].

 
 2. Another problem:
 
 My htm page has two frames (left and right).
 I activate php4 script from button on left frame.
 
 Question: How can I print the result of query on the right frame?

frame name="that_one_with_the_button" action="show.php"
target="left_frame_name"
...
 
-- teodor

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




Re: [PHP] Is this a missing feature?

2001-02-04 Thread Teodor Cimpoesu



Lux wrote:
 
 Where do I make a formal request for a feature?  In Perl or Ruby, I
 could have said:
 
 foo ({ 'var1' = 'value', 'var2' = 'value'});
 
 and it is so much more elegant than having to say:
 
 $hash = array (
'var1' = 'value',
'var2' = 'value'
 );
 foo ($hash);
 
 elegance is everything, man.
 
 lux
lux in latin means 'light' right? :) let me enlighten then :-P
  foo ($hash = array('var1'='value', 'var2'='value'));
should work.

Now, I don't undestand why exactly do you need references. By default
everything is passed in a referenced manner, if I undestood correct the
explanation Zeev wrote right after 4.0 was out, or so.

Don't take references like something that will boost your skript speed
to 200%.
Use them only when you need them, and to find out when you actually need
them
check out an article on references at zend.com.

Now, let me tell you that somehow I agreed with you :) cause I love
Python way
of dealing with arrays, but we are in PHP, so we have to figure PHP way,
not 
your-fav-lang way.

ciao 

-- teodor

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




Re: [PHP] Is this a missing feature?

2001-02-04 Thread Teodor Cimpoesu


foo ($hash = array('var1'='value', 'var2'='value'));
 should work.

 You don't need the $hash in that function call unless you need to use
 it later on in your main program, so you can just say:
 
 foo (array('var1'='value', 'var2'='value'));

that won't work (Lux's complaint) when foo() is declared function foo
($hash)
cause PHP cannot extract the reference of an array unbound to any PHP
variable.

There is only one exception, which is for objects created with new.

-- teodor

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




Re: [PHP] try - catch ?

2001-02-03 Thread Teodor Cimpoesu



Alain Fontaine wrote:
 
 Hi,
 
 Are there any plans on implementing something like Exception handling into
 future versions of PHP? That would be great.
 
I do remember Zeev saying it is considered for future implementation. I
don't
remember if it was on this list or php-dev one, though.

-- teodor

-- 
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] ini_get() vs. get_cfg_var()

2001-02-02 Thread Teodor Cimpoesu

What's the difference between these two functions?
from the manual I couldn't figure any:

get_cfg_var -- Get the value of a PHP configuration option. 
ini_get -- Get the value of a configuration option

is ini_get just an alias to get_cfg_var() or vice versa somehow?
dunno :)

TIA

-- teodor

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




Re: [PHP] ini_get() vs. get_cfg_var()

2001-02-02 Thread Teodor Cimpoesu

Hi Zeev!
On Fri, 02 Feb 2001, Zeev Suraski wrote:

 get_cfg_var() is an old PHP 3.0 era function, that returns the value for a 
 directive in the php.ini file.  This value may be valid or invalid, 
 depending on whether it was overwritten by other configuration methods 
 (e.g., httpd.conf or .htaccess).  This function will always return the 
 value that was typed in php.ini, if any.
 
 ini_get() is a new PHP 4.0 function, that uses the new INI subsystem 
 introduced in 4.0.  It will always return the active value, and not 
 necessarily the value that was in the php.ini.  Generally, unless you're 
 writing a script that actually deals with the php.ini file, you should 
 always use this function and not get_cfg_var().
 
That was also my guess, thank you very much for clarifing on it :)
I was mislead by the ini prefix, and though it refers only to the php.ini
file. So the ini_get() will return the `local' value not the `master' one.

Good to know.

-- teodor

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




Re: [PHP] [Q] Domxml: unlink() method?

2001-02-01 Thread Teodor Cimpoesu



Peter Sabaini wrote:
 
 hello,
 
 i am rather desperately trying to figure out how to delete a node
 object from the DOM.
 
 say i have a node $node by manually traversing the DOM tree or by an
 xpath_eval() function call. i can access the children
 ($node-children()) or the parent ($node-parent()) or add a sub-node
 ($node-new_child()) but there seems to be no $node-unlink() or
 something like that to remove $node from my DOM tree.
 
 in libxml which the php domxml extension is built upon there's a
 function xmlUnlinkNode() which seems to do just that, but there is no
 binding for this function in php (or i didn't find it. i looked in
 ext/domxml/php_domxml.c).
 
 any solutions / workarounds / patches anyone? or am i being plain
 dumb -- i am pretty a php novice so chances are i overlooked the very
 very obvious.
 
I've been playing w/ DOM XML extension for my documentation catalog 
(docs.digiro.net still work in progress ;), and my first shot would be
to unset the node from the children list of its parent. I also dig for
what
methods a DomNode, DomAttribute etc. have and figured out some. I would
like 
to see them documented somewhere ...

-- teodor

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




Re: [PHP] passing arrays of objects

2001-02-01 Thread Teodor Cimpoesu



"Conover, Ryan" wrote:
 
 I was wondering if I can pass an array that has serialized objects to next
 page via url encoding
 
 $foo  //array with serialized objects in it
 
 with the following encoding
 
 something/something/foobar.php?foo=echo($foo)
 
 and be able too unserialize $foo on the next page(foovar.php)

I would go with rawurlencode (serialize ($foo)), as the value, and
I guess it will work.

BTW, why aren't you using the session support? In that case it will pass
only the session ID,and the data associated w/ it will be un/serialized
only
on the server, w/o being passed back and forth.

-- teodor

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




Re: [PHP] PEAR?

2001-01-30 Thread Teodor Cimpoesu


Jonathan Sharp wrote:
 
 I came across http://pear.php.net/ So what is this? I found this in the PHP
 Developers Cookbook by SAMS...Right now it only has a few documentation and
 coding standards...are there more plans for this?

It comes (and installs by default) in every PHP distribution for some
releases now.
Just grab the sources, and look for pear directory. There you will find
some g00dies :)

-- teodor

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




Re: [PHP] Variable Problem when UPGRADING...

2001-01-30 Thread Teodor Cimpoesu

James Smith wrote:
 
 Alright, when i was programming with PHP3, I would use
 if statements like this:
 
 if(!$submit) {
// display form
 } else {
// display signup complete
 }
 
 to make multiple pages.  Or I would do this:
 
 if($action == "signup") {
if(!$submit) {
   //display form
} else {
   // display signup complete
}
 }
 if($action == "login") {
// show login screen
 }
 
 But now I get an error like this:
 
 Warning: Undefined variable: submit in
 c:\apache\htdocs\test.php on line 3
 
 I don't know if I misconfigured my php.ini file or
 what.
 
Very likely you used the optimized version of php.ini which has global
variables
registration off.

As for your question, I can tell you my tip:
I use
input type="submit" name="action[login]" value="Login"
input type="submit" name="action[signup]" value="SignUp"

and in the form do:
$PV = $HTTP_POST_VARS;
$action = isset ($PV['action']) ? key($PV['action']) :
'default-action-here';

switch ($action) { // allows lots of action w/o too many ifs and such
case 'login':
// login 
break;
case 'signup':
// signup
break;
case 'default-action':
default:
// evetually
break;
}
so on.
hope it helps

ciao

-- teodor

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




Re: [PHP] Cookie with Netscape

2001-01-30 Thread Teodor Cimpoesu



"Eugene Yi (InfoSpace Inc)" wrote:
 
 Thank you for your feedback!  I tried it but it didn't make a difference.  I
 printed the var right after the set and it returns null.
 
 setcookie("cbcookie1",$domain,0,"/","mydomain.com");
 $domain   = $HTTP_COOKIE_VARS["cbcookie1"];
 echo "domain($domain)br";

ahem, I think you shall see the cookie after a round trip to the
browser.
if you set it w/ setCookie() it won't be available right away in
HTTP_COOKIE_VARS.

only on the next calls to the page, cause the client has to receive it,
accept it (eventually) and send it back. when she sends it back, it is
in fact a HTTP header,
so it will be parsed and avaiable in that http array.

-- teodor

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




Re: [PHP] strings

2001-01-30 Thread Teodor Cimpoesu



[EMAIL PROTECTED] wrote:
 
 How can i make http://www.something.com/blah/blah.zip into
 
 blah/blah.zip
 
 http://www.somethingcom is a constant.. always the same thing
 
 how can i cut it out?
 
what comes to my mind right now is str_replace
('http://www.../','',$url)
where $url is the full URL.

oh, there is also parse_url() :)
so what you want would be:
$purl = parse_url ("http://.../blah.zip");
$whatiwant = $purl['path'];


-- teodor

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




Re: [PHP] HowTo: IBM DB2 w/PHP

2001-01-30 Thread Teodor Cimpoesu

Hi Karl!
On Tue, 30 Jan 2001, Karl J. Stubsjoen wrote:

 Hello,
 
 We have succesfully installed the IBM DB2 RDMS on our Linux box and have
 successfully made a connection to our AS400.  All through command line
 though.
 I am new to PHP, and am wondering:
 How do I instantiate the IBM DB2 in PHP, call commands, run queries, etc...?
 I'm not looking for all the answers, but tips on How to Get Started.
 
you won't run commands on the command line, but write function calls in PHP.
Check out the documentation to see what functions are available. I guess your
best path would be using the Unified ODBC ones.

try the `hello world' and if you don't manage by your own, maybe someone w/
DB2 will help you further.

ciao

-- teodor

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




Re: [PHP] session question

2001-01-30 Thread Teodor Cimpoesu

Hi Mark!
On Wed, 31 Jan 2001, Mark Green wrote:

 How about this:
 
  session_start();
  session_register($funky_session_var);
  $funky_session_var ++;
  print $funky_session_var;

the order doesn't matter (as it did in PHPLib sessions).
If it doesn't work I guess it's because you have register_globals off.

-- teodor

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




Re: [PHP] Modulus

2001-01-26 Thread Teodor Cimpoesu

Hi Mike!
On Thu, 25 Jan 2001, Mike P wrote:

 I know i'm a liitle slow but why does 2%4 = 2 and not 0 or 1
cause 4*0+2=2

 thanks
 Mike
 [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]
-- teodor

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




Re: [PHP] header problems

2001-01-26 Thread Teodor Cimpoesu



Kurth Bemis wrote:
 
 when i put this
 header('location: $url');
 
 i get this
 
 http://domain.com/$url
 
 what the hell am i doing wrong?
 
erm,
header ("Location: $url");

[double quotes, so PHP will consider your dollars, yens or whatever]

--teodor

-- 
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] Re: [PHP-DEV] vchkpw qmail

2001-01-23 Thread Teodor Cimpoesu

Hi php4!
On Tue, 23 Jan 2001, [EMAIL PROTECTED] wrote:

 Is anyone doing anything with PHP and vchkpw?
 
 There isn't much about it in the archives, but I'd hate to wast a bunch
 of time and find out there is already something in progress.
 
 
 I just built a mail server using these packages, and I'm quite
 impressed.  I like the way vchkpw only needs a single user/group to
 manage unlimited virtual domains.
 
Is it freeware? You made me curious :)


-- teodor

-- 
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] XML dillema

2001-01-22 Thread Teodor Cimpoesu

Hey,
I've been playing w/ DOM functions (not very documented, but cool :)
and had the following:

[categories.xml]

?xml version="1.0"?
catalog
category id="db" name="Databases"
topic
  nameMySQL/name
  descriptionMySQL Manual/description
/topic

topic
  namePostgreSQL/name
  descriptionPostgreSQL Manuals/description
/topic

/category
 /catalog

[xmltest.php]
?php
header ('Content-Type: text/plain');

$doc  = new DomDocument();
$node = new DomNode();

$doc  = xmldocfile ('categories.xml');
$root = $doc-root();
$cats = $root-children();

$node = $cats[0];

print_r ($node-name);


It outputs "text" and I would expect "Databases".

running xmllint gives:

[teo@teo xml]$ xmllint --debug categories.xml 
DOCUMENT
version=1.0
URL=categories.xml
standalone=true
  ELEMENT catalog
TEXT
  content=
ELEMENT category
  ATTRIBUTE id
TEXT
  content=db
  ATTRIBUTE name
TEXT
  content=Databases
  TEXT
[...]


Any idea what's wrong?

TIA


-- teodor

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




Re: [PHP] $HTTP_SERVER_VARS has only 1 value

2001-01-22 Thread Teodor Cimpoesu

Hi Todd!
On Mon, 22 Jan 2001, Todd Cary wrote:

 Rasmus -
 
 I am running Apache on my notebook so that I can do some development
 while I am "on-the-road".  My code needs to obtain the URL and SERVER
 and I do this with $HTTP_SERVER_VARS.  However, under Apache (I use IIS
 on the Win 2K server and $HTTP_SERVER_VARS contains many items) I am
 only getting the PHP_SELF item.
 
Why don't you get them from environment?

$sn = getenv('SERVER_NAME');
$ru = getenv('REQUEST_URI'); or 'SCRIPT_NAME', depending on what you need.


-- teodor

-- 
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] Re: XML dillema

2001-01-22 Thread Teodor Cimpoesu

Hi Brinkman,!
On Mon, 22 Jan 2001, Brinkman, Theodore wrote:

 Maybe I'm missing something, but I'm thinking it's giving the correct
 output.
 
 The 'TEXT' that is showing up just seems to be some sort of indication as to
 what type of data it found.
 
 ELEMENT catalog   //the parser found an element named
 'catalog'
   TEXT//the element 'catalog' is of type TEXT
 content=  //it had no content of its own
 ELEMENT category  //inside it found an element named
 'category'
   ATTRIBUTE id//'category' has an attribute named 'id'
 TEXT  //  the attribute 'id' is of type TEXT
   content=db  //  the attribute 'id' has a value of 'db'
   ATTRIBUTE name  //'category' has an attribute named 'name'
 TEXT  //  the attribute 'name' is of type TEXT
   content=Databases   //  the attribute 'name' has a value of
 'Databases'
   TEXT//the element 'category' is of type
 TEXT
 [...] //[...]
 
 Somebody who knows better please correct me if I'm wrong.
 
Point made! xmllint gives +1 but the first found node looks like:
[result of print_r ($node) ]

DomNode Object
(
[name] = text
[content] = 

[node] = Resource id #3
[type] = 3
)

I don't get it why `name' is `text'. Maybe I should file a bug report.
Just wanted to be sure it's not me being wrong.


 
 Hey,
 I've been playing w/ DOM functions (not very documented, but cool :)
 and had the following:
 
 [categories.xml]
 
 ?xml version="1.0"?
 catalog
 category id="db" name="Databases"
 topic
   nameMySQL/name
   descriptionMySQL Manual/description
 /topic
 
 topic
   namePostgreSQL/name
   descriptionPostgreSQL Manuals/description
 /topic
 
 /category
  /catalog
 
 [xmltest.php]
 ?php
 header ('Content-Type: text/plain');
 
 $doc  = new DomDocument();
 $node = new DomNode();
 
 $doc  = xmldocfile ('categories.xml');
 $root = $doc-root();
 $cats = $root-children();
 
 $node = $cats[0];
 
 print_r ($node-name);
 
 
 It outputs "text" and I would expect "Databases".
 
 running xmllint gives:
 
 [teo@teo xml]$ xmllint --debug categories.xml 
 DOCUMENT
 version=1.0
 URL=categories.xml
 standalone=true
   ELEMENT catalog
 TEXT
   content=
 ELEMENT category
   ATTRIBUTE id
 TEXT
   content=db
   ATTRIBUTE name
 TEXT
   content=Databases
   TEXT
 [...]
 
 
 Any idea what's wrong?
 
 TIA
 
 
-- teodor

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




Re: [PHP] $HTTP_SERVER_VARS has only 1 value

2001-01-22 Thread Teodor Cimpoesu

Hi Todd!
On Mon, 22 Jan 2001, Todd Cary wrote:

 Teo -
 
 That works great for Apache but not for my ISAPI installation that is
 using IIS on a Win 2K platform.  Is there a way to tell if I am using an
 ISAPI server or not?  Otherwise I will put that in my parameter file.
 
Yap, I think it's php_sapi_name(). [I get `cgi' for the CGI version, and 
`apache' for Apache module, so I guess you'll get `iis' for the iis one ]


-- teodor

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




Re: [PHP] ? PHP vs. ?

2001-01-19 Thread Teodor Cimpoesu

Hi Alex!
On Thu, 18 Jan 2001, Alex Black wrote:

 xml problems?
 
 _what_ xml problems?
 
I was refering to whole story of using `?' in xml docs.

-- teodor

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




Re: [PHP] ? PHP vs. ?

2001-01-17 Thread Teodor Cimpoesu

Hi Philip!
On Wed, 17 Jan 2001, Philip Olson wrote:

 
  Short open tags won't work with xml.  Therefore they won't work with
  xhtml.  They conflict with where the Web is going.
 
 Aha!  Yet another reason not to use ?=
 
 :-)
 
you can always use % and %= instead. 
No XML problems, and you may confuse your {A,J}SP coders :)

-- teodor.

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




Re: [PHP] Session, register_globals, $HTTP_SESSION_VARS???

2001-01-17 Thread Teodor Cimpoesu

Hi Andrew!
On Wed, 17 Jan 2001, Andrew Sitnikov wrote:

 Hello ,
 
 sess.php
 ?
  $var_name = 'TEST_VAR';
 
  session_register($var_name);
 
  if (isset($HTTP_SESSION_VARS[$var_name])){
$HTTP_SESSION_VARS[$var_name] ++;
  }else{
$HTTP_SESSION_VARS[$var_name] = 0;
  }
 
  echo "\$HTTP_SESSION_VARS[$var_name] : ".$HTTP_SESSION_VARS[$var_name];
 ?
 
 Result:
 
 
 if register_globals = On
 
 always : $HTTP_SESSION_VARS[TEST_VAR] : 0
 
if register_globals is on the variablea aren't stored anymore in
$HTTP_SESSION_VARS but in $GLOBALS.

-- teodor

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




Re: [PHP] ?= was born when?

2001-01-12 Thread Teodor Cimpoesu

Hi Toby!
On Thu, 11 Jan 2001, Toby Butzon wrote:

 Manual suggests 3.0.3, but I can't find any proof of it in
 the changelogs...
it is not in 3.0.12 for sure. So probably from later (I guess 3.0.15).

-- teodor

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




Re: [PHP] Cannot send session cache limiter - headers already sent Cannot send session cookie - headers already sent by

2001-01-11 Thread Teodor Cimpoesu

Hi JB!
On Wed, 10 Jan 2001, JB wrote:

 actually.. still give me the same error after i fixed that. new code as
 follows along with the error:
 
 if (!session_is_registered('cart')) {
 $cart = array();
 session_register('cart');
 }
 else {
 session_start();
 }
 
 any other ideas?   =)

be sure you don't output *anything* before the session_start() 
or session_register() call. They imply sending a cookie header to
the browser, and having something already sent means the headers cannot
be sent anymore like in:

Content-Type: text/html

html
output already here
Set-Cookie: foobar=baz;
^... cannot see this as a header, cause it's in the body of the response.


-- teodor

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




Re: [PHP] Shopping Cart Schema - Sessions

2001-01-10 Thread Teodor Cimpoesu

Hi Jason!
On Wed, 10 Jan 2001, Jason Beebe wrote:

 Hey, 
 
 I'm looking for little information from those who have coded their own shopping cart 
apps. what would you say the best way to setup a cart would be? more specificly, the 
method for adding items to the cart.
 
eww, lost wrapping ...

 say the user is broswing around. when they entered the website a new session was 
created. when they go to add an item, what is the best way store variables (such as 
what they bought and quantity) in the session. i have read that it is possible to put 
all of your session variables in a single associative array. however, i have not had 
any luck doing this myself. Under such a method of an array, how would i store each 
item (product id and quantity, possibly price as well) in the cart into the session. 
obviously i don't expect anyone to write an entire app. i am comfortable starting the 
session, and doing th db extraction and presentation. i just need to know how to 
store a variable in a session (passed through post) and how to extract it when need 
be (considering it is an array). Thanks a lot!

I codded a shopping cart which allowed `thin sessions' and `fat sessions'.

Thin would mean I store only the IDs, then retrieve the rest of the
information about the product from the DB (more DB queries, but smaller
session data), while `fat' would mean I store all the data I need to display
when the user invetories his/her cart, namely name, price |short desc.,
quantity.

Some code snippets would be:

if (!$SES-isRegistered ('cart.object')) {
 $CART = new Cart();
 $CART-setLanguage (CART_LANGUAGE);
 $SES-setAttribute ('cart.object', $CART);
}

$CART = $SES-getAttribute ('cart.object');

then go ahead and use the cart object:
...
$CART-addItem ($sku, 1, new Product($arr_attr));
$CART-dropItem ($sku);

And the Product class has among others, these two methods:

 __setStorageType ($t) 
{  
if ($t == CART_FAT_SESS) {
$this-_slots = array_keys (get_object_vars ($this));
unset ($this-_slots['_desc']);
}
}

function __sleep ()
{
return  (isset ($this-_slots) ? $this-_slots : array ('_quant')); 
}

This is in the manner of Session class from PHPLIB which records what is to
be saved in the session (in this case, what attributes.)

And the Cart class has:

function __wakeup ()
{
 if ($this-STORAGE == CART_THIN_SESS) {
$pr_attrs = Cart::getItemsAttr (array_keys($this-_items));

foreach ($pr_attrs as $sku = $attrs) {
$attrs['quant'] = $this-_items[$sku]-getQuantity();
$this-_items[$sku] = new Product ($attrs);
}
 }
}

Note that __sleep() and __wakeup() are PHP serialisation hooks, which can customize
the marshalling/unmarshalling process (e.g. restore DB connections, etc.)

cheers,

-- teodor

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