Re: [PHP] Is this a missing feature?
> > 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] Is this a missing feature?
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 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] HTTP compression
Carsten Gehling wrote: > > From: "Teodor Cimpoesu" <[EMAIL PROTECTED]> > Sent: Sunday, February 04, 2001 7:08 PM > > > 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 :) > > Where can I get the specs on the compression algorithm? Is it specified in a > RFC? erm, it's gzip I guess. PHP uses zlib to send compressed output, afaik [i.e. you must have --with-zlib in order to use the output compression handler ] -- 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...
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? ... -- 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 compression
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] try - catch ?
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]
Re: [PHP] ini_get() vs. get_cfg_var()
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]
[PHP] ini_get() vs. get_cfg_var()
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] passing arrays of objects
"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] [Q] Domxml: unlink() method?
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] session question
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] HowTo: IBM DB2 w/PHP
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] strings
[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] Cookie with Netscape
"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)"; 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] Variable Problem when UPGRADING...
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 and in the form do: $PV = $HTTP_POST_VARS; $action = isset ($PV['action']) ? key($PV['action']) : ''; 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] PEAR?
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] header problems
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]
Re: [PHP] Modulus
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] Zend hit (Encoder price)
Hi Sander! On Thu, 25 Jan 2001, Sander Pilon wrote: > > > > > Hello, > > > > What do you think about Zend position? > > http://php.weblogs.com/ > > http://zend.com/phorum/read.php?num=3&id=6277&loc=0&thread=6277 > > > > I think that if Zend wants to sell it for $6000, then they have all right > to. These guys have worked hard, and they deserve some cash for it. > > If people can't afford it at $6000, then that's their problem. Software is > intellectual property, it shouldn't be free, and authors should be able to > charge any price for it they want to charge for it. > > But, I don't think it's a wise decision to sell it at $6000, personally I > think I would sell it between $1000 and $4000, but that's just me. ($6000 is > a bit on the high side, considering what alternatives one haves for that > price, and considering that anyone who paid $1000 a year back (I recall > something about 'sponsoring') gets it all.) > Also, there are Perl,Python,Java. All have `encoders', all free. ain't it cool when you have choices :) -- 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
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]
Re: [PHP] Re: HTTP_USER_AGENT and preg_match
Hi John! On Tue, 23 Jan 2001, John Hinsley wrote: > Got it in the end. It should be: > > > > > if ((preg_match("/Mozilla/i", "$agent")) && (preg_match("/Gecko/i", > "$agent"))) { > $result = "You are using Netscape 6 or a later version of Mozilla."; > > > > But the thought occurs that there must be a site out there somewhere > which lists the HTTP_USER_AGENT tags for *all* browsers? I've got a nice browsecap.ini file from php4win.de. You can then simply use get_browser() [ listed under Miscellaneous functions] -- 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
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]
[PHP] Re: XML dillema
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] > > > > > > MySQL > MySQL Manual > > > > PostgreSQL > PostgreSQL Manuals > > > > > > [xmltest.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
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] XML dillema
Hey, I've been playing w/ DOM functions (not very documented, but cool :) and had the following: [categories.xml] MySQL MySQL Manual PostgreSQL PostgreSQL Manuals [xmltest.php] 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] url hide
Hi AJDIN! On Mon, 22 Jan 2001, AJDIN BRANDIC wrote: > OK, I don't have access to the server (except ftp). All I can use is PHP > or JavaScript. I just thought that I could use some thing that will just > hide it. Like that NoRightClick javascript script where if you try to > view the source code of a page it stops you but you can still use > View/Source Code option on your main menu to view the code. > have a look on how it is implemented on http://www.ravantivirus.com. [0 size frame ] Done it recently :) -- 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 Processing Instruction ( was "
Brian White wrote: > > At 10:50 AM 1/19/12 +0200, Teodor Cimpoesu wrote: > > >I was refering to whole story of using ` > Part of the problems is that multiple different applications > can use PI's, so they need to be able to tell which ones are > their's - therefore the first thing that should go in a PI > is some kind of indication as to which application requires > it. > > Therefore: Always " my follow-up was from an suggest of using <% though :) it exists in C, ASP and JSP. We have it in PHP, why not use it? besides moving a site arround into a configuration you cannot control I see no other reason. -- 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]
Hi Alex! On Thu, 18 Jan 2001, Alex Black wrote: > xml problems? > > _what_ xml problems? > I was refering to whole story of using `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]
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???
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] fetch html-page without file()
Hi mailing_list! On Fri, 12 Jan 2001, [EMAIL PROTECTED] wrote: > Hi! > > Something strange: > A script, that uses file("http://xyz.com") does work on one sever! > Then I copied it to another server (physically more far away from the > server from which I fetch the html-page with file()) - same PHP ... > Now file() returns always an empty string (about in 1 try out of 1000 it > is successful - I tested it!!) > > Is there another method, to fetch a html-page? > yap, fopen() the location, then test is the return code != false. $tries = 3; while (($fd = fopen("http://foo.bar","r")) == false && $tries) { sleep (4 - $tries); --$tries; } if (!$fd) die ("Page not available or server foo.bar is down"); -- 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]
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] Shopping Cart Schema - Sessions
Hi Alexander! On Thu, 11 Jan 2001, Alexander Wagner wrote: > Paul K Egell-Johnsen wrote: > > When in doubt, follow the stream... Check out this, Amazon uses cookies, > > Amazon does a lot of business. Do you really feel that Amazon misses out > > on a lot of customers? Do you know of any large websites doing shopping > > carts which doesn't rely on cookies? > > I don't fear cookies. As many other (geeks, mainly), I just don't like them. > Especially those that don't serve a purpose (at least not for me). > I don't know much about Amazon and other shops, but what is wrong about using > a fallback to GET when cookies are not supported? this is how the session works in PHP, and if you have --enable-trans-sid at configure time, you don't have to worry for carrying the SID over the pages. -- 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
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 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
Hi JB! On Wed, 10 Jan 2001, JB wrote: > ok, this all looks good, but then I again I am having a problem figuring out > that code you wrote below. the code i'm attempting to write isn't going to > be complex. there's maybe 10 or 15 items going to be sold. it would be very > rare if the customer ever had 1 or 2 things in their basket, let alone more > than that. i think i'm looking for a simpler solution. from what i had read, > though i couldn't get to work, this would be an acceptable method of > starting a sessions and trapping the variables without a million > session_register calls. > > session_start(); > session_register("sessvar"); > $sessvar["user"]["name"] = $login_name; > $sessvar["cart"]["item1"] = $prod_id; > $sessvar["cart"]["qty1"] = $qty; > > Then.. I should be able to access them like: > > print "$sessvar['user']['name']"; > etc... > yap, just like that! have you tried it yet? Just remember to test if the array variable isn't already set so not to overwrite the old values by accident (use session_is_registered(), I think) > all i need is a sure fire way to easily hold a few variables throughout the > site. i'm not concerned about holding the keys in a db, as with the small > activity on this site, and the fact the writing to a local file will not > rpoduce any noticable difference over a db query on my machine w/ its > traffic, the db is not needed for this. > My advice is to have a clear idea of what you really want, and write it down first. Clearely formulate your problem to solve, and don't jump at coding as most guru coders do :) Start simple. > so.. all i need is a good simple method to register the following variables: > uid (user id) > p1 (product id for item 1) > q1 (qty for item 1) > [products.php][cart.php] {uid, product_id, quantity} ---> {$cart, $user} in cart.php you do: session_start(); // don't mix different data (products w/ user data) // have them in separate entities if (!session_is_registered('cart')) { $cart = array(); session_register('cart'); } if (!session_is_registered('user')) { $user = array(); session_register('user'); } // you may have different operations on the cart. // let's say we add something, so we receive {uid,product_id, quantity} // from products.php ... $cart[$product_id] = $quantity; I am not sure why do you need user id, as every session is `customized' for a user, who has a corresponding session_id in your application. > and a method to increase the next variable to p2, q2, p3,q3 etc to represent > other items in the cart. for this example, I thought the `key' in the array to be the product_id (a user can have one or more products identified by their id). > i think i should be able to figure out how to manipulate/extract the data > and work with it from there (in an array) once i am able to get them > registered. really i would just need a method for walking through the > array(s) to pull out the data. but if anyone has any suggestions on that too > i'd love to hear em. You must view it this way when writing your php code for the problem: you have a session associated with a user (1 to 1 relationship) in which you store pertinent data related to users actions. We call it session because it persists over several requests. A user can request one or more products (a 1 to n relationship), and the information will be stored in the session. Simple, isn't it? :) 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]
Re: [PHP] Shopping Cart Schema - Sessions
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]
Re: [PHP] PHP vs. qmail
Hi Nicklas! On Tue, 09 Jan 2001, Nicklas af Ekenstam wrote: > I have a server running qmail and php on which I'm trying to do some php > processing of incoming e-mail. > I have a virtual domain set up like this: > > '.qmail-virtualdomain.com-default' > which contains the following: > '|/usr/local/php-4.0.1pl2/php /home/nille/script.php -q' > nice :) > What I would like to know is if there is a nice way of parsing out the body > of the incoming message and place that into a variable and also the same > thing with the subject so that I can process these using som regular > expressions and respond to certain keywords using custom templates. > well, IIRC, the mail is available at the stdin, right? So in your script.php you may do a fopen ("php://stdin") and read it. You can either save it to a temporary file (assuming it's a big one) or process it in memory. Now, I dunno if qmail also sends via environ the mail size, but I guess there should be a way to figure it out. Given the mail into a temp. file, you can use all imap_* functions on it, of particular interest being imap_rfc822*() functions for example. I once wrote a small and clumsy code for a freemail application (long ago) and now I was considering something like that for preparsing of the mails at the incoming time, not reading time as most do, so I'll dig too and if I find something more interesting I'll let you know :) 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]