Re: [PHP] Headers on smart phone browsers
On Feb 6, 2012, at 4:01 PM, Stuart Dallas wrote: > Generally speaking you're better off with a design that automatically adapts > to the viewport on which it's being displayed. While there's more than one > reason for this, the overriding reason is that the same software (i.e. the > same user agent) could be running on any size of device, from watch to huge > flat panel screen on a wall. > > I think the world needs to move on from "is it a mobile device or not" to > accepting the reality which is that the browser / OS is irrelevant, and that > the way your site renders should be purely based upon the size of the > display. Responsive designs such as that described in the A List Apart > article Mari posted are fantastic tools for achieving this goal. > > -Stuart > Agreed. Not only the size of the display -- but what's a size of a pixel? http://www.alistapart.com/articles/a-pixel-identity-crisis/ Presentation is a difficult problem to solve, but I don't think PHP enters into the equation. From my view, the only thing that PHP can do is device-sniff, which is clearly a losing proposition. I believe that a presentation solution will be solved by presentation languages (i.e, client-side). Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
> There is only one drawback to using CSS media queries to alter the way a > page is displayed on different resolutions, and that is that any media > (i.e. background images, etc) referenced in a stylesheet is downloaded, > regardless of if it is ever used. Another one worth mentionning is that a lot of mobile devices still in use do not support media queries - their being a relatively recent development. Same goes for javascript, even if it claims to support it. Older Blackberrys claim JS support but fail miserably in real life. Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
On Mon, 2012-02-06 at 18:09 -0600, Donovan Brooke wrote: > Mari Masuda wrote: > [snip] > > For a concrete example of responsive design in action, point your browser > > to http://www.sasquatchfestival.com/ and then slowly make the window > > wider/skinnier to see how the design adapts to different viewport sizes. > > > Very nice... makes for an easy display to a wide range of circumstances > I think.. especially image resizing (in the blog example), which looks > pretty smooth. But, in both the examples, it appears it can produce a > "choppy" user experience when resizing the window as well... > > I suppose that resizing could be viewed as one of those 80/20 percent > rule things.. meaning, window resizing is probably not a prevalent > action for a user and it could be argued that one shouldn't code a site > worrying too much about dynamic window resizing... but then there is a > form of resizing, which is turning your iPAD to landscape view, etc.. > > I suppose one could probably still do some UA detection and serve up > content based on the "type" of UA (ie. mobile, IE, game-based) and at > that point, still incorporate responsive web design, but to that > more-limited-category of UA's. > > Donovan > > > > > > -- > D Brooke > There is only one drawback to using CSS media queries to alter the way a page is displayed on different resolutions, and that is that any media (i.e. background images, etc) referenced in a stylesheet is downloaded, regardless of if it is ever used. So if you have two background images for the body, one large for nice wide screens, and a smaller one for smaller screens, they will both be downloaded by the browser. The way around this is to use Javascript to load only the stylesheets required, but then you're relying on Javascript and you don't need media queries. It's a pain finding the right balance. -- Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Headers on smart phone browsers
Mari Masuda wrote: [snip] For a concrete example of responsive design in action, point your browser to http://www.sasquatchfestival.com/ and then slowly make the window wider/skinnier to see how the design adapts to different viewport sizes. Very nice... makes for an easy display to a wide range of circumstances I think.. especially image resizing (in the blog example), which looks pretty smooth. But, in both the examples, it appears it can produce a "choppy" user experience when resizing the window as well... I suppose that resizing could be viewed as one of those 80/20 percent rule things.. meaning, window resizing is probably not a prevalent action for a user and it could be argued that one shouldn't code a site worrying too much about dynamic window resizing... but then there is a form of resizing, which is turning your iPAD to landscape view, etc.. I suppose one could probably still do some UA detection and serve up content based on the "type" of UA (ie. mobile, IE, game-based) and at that point, still incorporate responsive web design, but to that more-limited-category of UA's. Donovan -- D Brooke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
Paul M Foster wrote: [snip] How about this: those of you with iPhones, Androids and the like, point your phones at a page which reports $_SERVER['HTTP_USER_AGENT'] (like a page which runs the phpinfo() function), and post what you get back from that exercise and what device made the query. I'd like to see if there is anything significant which indicates handheld platforms. Paul Logical, but I can save you that step :-) as I've been there done that.. Here is a PHP script (uses $_SESSION) for mobile users that I have found to work fairly well. I'm absolutely sure that it contains false positives, and potentially other minor bugs.. as it's just hard to keep up with the ever changing UA's... but it's a start. If it gets munged from email returns, I can zip it up. Donovan *INCLUDE IN HEAD --start " with your mobile URL below ** // Head include('device_detect.php');// session_start(); $is_mobile = mobile_device_detect(); if ($is_mobile) { header("Location: "); die(); } ?> --end SAVE TO A FILE CALLED 'device_detect.php' --start if (isset($_SERVER['HTTP_X_WAP_PROFILE']) || isset($_SERVER['HTTP_PROFILE'])) { $_SESSION['mobiledevicedetect'] = true; return true; } $user_agent = $_SERVER['HTTP_USER_AGENT']; // get the user agent value - this should be cleaned to ensure no nefarious input gets executed $accept = $_SERVER['HTTP_ACCEPT']; // get the accept header value switch(true){ // using a switch against the following statements which could return true is more efficient than the previous method of using if statements case (eregi('ipod',$user_agent)||eregi('iphone',$user_agent)); // we find the words iphone or ipod in the user agent $_SESSION['mobiledevicedetect'] = true; return true; break; case (preg_match('/(nokia|sonyericsson|samsung|up.browser|up.link)/i',$user_agent)); // we find palm os in the user agent - the i at the end makes it case insensitive $_SESSION['mobiledevicedetect'] = true; return true; break; case (eregi('android',$user_agent)); // we find android in the user agent $_SESSION['mobiledevicedetect'] = true; return true; break; case (eregi('opera mini',$user_agent)); // we find opera mini in the user agent $_SESSION['mobiledevicedetect'] = true; return true; break; case (eregi('blackberry',$user_agent)); // we find blackberry in the user agent $_SESSION['mobiledevicedetect'] = true; return true; break; case (preg_match('/(palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine|treo)/i',$user_agent)); // we find palm os in the user agent - the i at the end makes it case insensitive $_SESSION['mobiledevicedetect'] = true; return true; break; case (preg_match('/(windows ce; ppc;|windows ce; smartphone;|windows ce; iemobile)/i',$user_agent)); // we find windows mobile in the user agent - the i at the end makes it case insensitive $_SESSION['mobiledevicedetect'] = true; return true; break; case ((strpos($accept,'text/vnd.wap.wml')>0)||(strpos($accept,'application/vnd.wap.xhtml+xml')>0)); // is the device showing signs of support for text/vnd.wap.wml or application/vnd.wap.xhtml+xml $_SESSION['mobiledevicedetect'] = true; return true; break; case (in_array(strtolower(substr($user_agent,0,4)),array('1207'=>'1207','3gso'=>'3gso','4thp'=>'4thp','501i'=>'501i','502i'=>'502i','503i'=>'503i','504i'=>'504i','505i'=>'505i','506i'=>'506i','6310'=>'6310','6590'=>'6590','770s'=>'770s','802s'=>'802s','a wa'=>'a wa','acer'=>'acer','acs-'=>'acs-','airn'=>'airn','alav'=>'alav','asus'=>'asus','attw'=>'attw','au-m'=>'au-m','aur '=>'aur ','aus '=>'aus ','abac'=>'abac','acoo'=>'acoo','aiko'=>'aiko','alco'=>'alco','alca'=>'alca','amoi'=>'amoi','anex'=>'anex','anny'=>'anny','anyw'=>'anyw','aptu'=>'aptu','arch'=>'arch','argo'=>'argo','bell'=>'bell','bird'=>'bird','bw-n'=>'bw-n','bw-u'=>'bw-u','beck'=>'beck','benq'=>'benq','bilb'=>'bilb','blac'=>'blac','c55/'=>'c55/','cdm-'=>'cdm-','chtm'=>'chtm','capi'=>'capi','comp'=>'comp','cond'=>'cond','craw'=>'craw','dall'=>'dall','dbte'=> ;'dbte','dc-s'=>'dc-s','dica'=>'dica','ds-d'=>'ds-d','ds12'=>'ds12','dait'=>'dait','devi'=>'devi','dmob'=>'dmob','doco'=>
Re: [PHP] Headers on smart phone browsers
On Mon, Feb 06, 2012 at 09:01:45PM +, Stuart Dallas wrote: > On 6 Feb 2012, at 05:58, Paul M Foster wrote: > > > This is sort of obliquely related to PHP. > > > > I don't have a smart phone, but I need to know a couple of things: > > There are simulators available for most smartphones. > > > 1) Do smart phones use the same browsers as the desktop, or do they > > have their own stripped down versions of browsers? > > The trend is certainly moving towards full desktop capability, but > personally I still think that if you expect a significant amount of > traffic from mobile devices then your site should adapt accordingly. > > > 2) When a browser broadcasts its header telling the server what kind > > of browser is involved, do they broadcast anything in the header to > > indicate that they're being run on a smart phone? > > Yes, but there's no standard at the moment so detection requires > something similar to https://gist.github.com/1124666. That code is > pretty old, and I can't remember where I got it, but at the time it > worked really well. > > > 3) Bonus question: Is there a preferred method amongst coders to > > determine what type of environment is being browsed from, so as to > > serve up the proper type of page (desktop or smart phone version of > > a webpage)? > > Generally speaking you're better off with a design that automatically > adapts to the viewport on which it's being displayed. While there's > more than one reason for this, the overriding reason is that the same > software (i.e. the same user agent) could be running on any size of > device, from watch to huge flat panel screen on a wall. > > I think the world needs to move on from "is it a mobile device or not" > to accepting the reality which is that the browser / OS is irrelevant, > and that the way your site renders should be purely based upon the > size of the display. Responsive designs such as that described in the > A List Apart article Mari posted are fantastic tools for achieving > this goal. > I'm inclined to agree. In fact, my daughter, who owns an iPhone, hates the mobile-only webpages and will normally opt to see the full (desktop) website, even on her iPhone. She'd rather gesture around the original website than see a vastly simplified version with everything vertically stacked, as it often is on strictly mobile sites. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
On Mon, Feb 06, 2012 at 04:04:28PM -0500, Adam Richardson wrote: >On Mon, Feb 6, 2012 at 3:50 PM, Adam Richardson <[1]simples...@gmail.com> >wrote: > > On Mon, Feb 6, 2012 at 12:58 AM, Paul M Foster > <[2]pa...@quillandmouse.com> wrote: > >This is sort of obliquely related to PHP. > >I don't have a smart phone, but I need to know a couple of things: > >1) Do smart phones use the same browsers as the desktop, or do they >have >their own stripped down versions of browsers? > > Both, although more and more smart phones join the ranks of the > desktop-quality browser every day (iPhone and Android both have very > capable browsers, with the iPhone's omission of flash support being the > biggest difference between these two.) > � > >2) When a browser broadcasts its header telling the server what kind >of >browser is involved, do they broadcast anything in the header to >indicate that they're being run on a smart phone? > > Yes, but that gets complicated quickly: > [3]http://www.zytrax.com/tech/web/mobile_ids.html > � This gets directly at the answer, but also proves that there's no practical way of using the information. There are simply too many variations, and more to come. Great reference. I didn't find it in my prior research on Google. > >3) Bonus question: Is there a preferred method amongst coders to >determine what type of environment is being browsed from, so as to >serve >up the proper type of page (desktop or smart phone version of a >webpage)? > > To supplement the alistapart link already mentioned, here's another > recent writeup: > > [4]http://dev.opera.com/articles/view/how-to-serve-the-right-content-to-mobile/ > >Apologies, I sent the wrong link last time: >[5]http://dev.opera.com/articles/view/the-mobile-web-optimization-guide/ >Adam Thanks, Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
Stuart Dallas wrote: On 6 Feb 2012, at 21:12, Marc Guay wrote: the way your site renders should be purely based upon the size of the display. Although I mostly agree with this statement, it ignores the most interesting aspects of mobile technology, such as being able to ask the user for their GPS location and deliver content accordingly. I worked on some real estate websites that would show the user the houses for sale within a certai distance from where they were standing, and then leverage Google Maps for a "get directions from where you are" feature. The Mobile Web list has had some interesting discussions regarding this stuff... http://groups.yahoo.com/group/mobile-web/ On the contrary, my statement dealt only with the way a site renders, not the content it renders. We should definitely be taking advantage of the additional features of mobile devices where it makes sense because that's where the real game-changing power lies. -Stuart Right, the OP doesn't state the purpose exactly (design, function, etc..)... but even if it was design, as noted in Mari's link toward the bottom, responsive web design is not supported the same in all platforms... this is why I think, in many situations, a mix of UA detection and versatile design is still relevant (even in design). Donovan -- D Brooke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
Ashley Sheridan wrote: [snip] Keeping a PHP angle to this, have you looked at using an up-to-date browscap.ini file with PHP? Basically, you can use that to read in the raw user agent string from the browser, and it then finds a matching entry in the ini file and gives you back some values about what it can assume about that device, such as whether it is known to support Java (although this is something you should be careful of, as it only tells you if it's is supported, not if there is an available JVM), if it is a mobile or search bot, what version of CSS it should support, etc. I use it myself in a personal web stats script, and as long as you keep the copy of the ini file recent, you should be OK. Interesting, I will check that out. Donovan -- D Brooke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
On Mon, Feb 06, 2012 at 09:02:34PM +, Ashley Sheridan wrote: [snip] > > > Keeping a PHP angle to this, have you looked at using an up-to-date > browscap.ini file with PHP? Basically, you can use that to read in the > raw user agent string from the browser, and it then finds a matching > entry in the ini file and gives you back some values about what it can > assume about that device, such as whether it is known to support Java > (although this is something you should be careful of, as it only tells > you if it's is supported, not if there is an available JVM), if it is a > mobile or search bot, what version of CSS it should support, etc. I use > it myself in a personal web stats script, and as long as you keep the > copy of the ini file recent, you should be OK. The issue with this (according to the get_browser() docs) is that the browsecap file is 300K long, will get longer, and significantly slows loading of your applications. Moreover, the parsing of the UA string and other data is far more extensive than anything I'd want or could use. The only thing I'd want to know is whether I'm serving pages to a handheld or desktop device. >From what I've seen, pages built for handheld devices (see, for example, yahoo.mobi) are considerably stripped down, often with no CSS styling. For now, if I have to make the decision on whether to serve up desktop or handheld versions of a page, all I want to know is a yes or no answer to the question of, "Is this a handheld?" The native PHP get_browser() function appears to be overkill for that, and may, in fact be insufficient. That was the origin of the original questions-- was there some definitive way of knowing the platform when the page request came in. And from all the research I've done, the answer is, "No". The UA string may not work as intended. There are javascript sniffers and CSS triggers, but neither are they definitive. For example, the CSS triggers test for resolution or screen width or the like. This is fine, so long as handhelds remain at crappy resolutions. But I don't expect that to be the case forever. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
On Mon, Feb 06, 2012 at 02:28:42PM -0600, Donovan Brooke wrote: > Paul M Foster wrote: > >This is sort of obliquely related to PHP. > > > >I don't have a smart phone, but I need to know a couple of things: > > > >1) Do smart phones use the same browsers as the desktop, or do they have > >their own stripped down versions of browsers? > > > >2) When a browser broadcasts its header telling the server what kind of > >browser is involved, do they broadcast anything in the header to > >indicate that they're being run on a smart phone? > > > >3) Bonus question: Is there a preferred method amongst coders to > >determine what type of environment is being browsed from, so as to serve > >up the proper type of page (desktop or smart phone version of a > >webpage)? > > > >Paul > > Hi Paul, I think this is a great PHP conversation.. and I don't > understand why GOTO threads always get way more replies than > something like this ;-) See religion (n), defs 1-10. > > Diverse User Agent compatibility is going to be more and more of a > challenge for us.. gone are the days of a few known browsers that > are viewing our sites. From bots, to browsers, to mobile devices, > to game UA's, to app UA's.., to IE's stubborn outlook on the web... > the idea of user experience is growing complicated! ;-) Well, cursory research shows there are at least 12 different major layout engines underneath modern browsers. Multiply that by versions of same, different OSes on which each run, versions of the OSes themselves, etc. etc. etc. I don't envy the job of any piece of code which tries to analyze all this. Plus, I believe that in the future, handhelds (specifically smart phones) will approach desktops in screen resolution. > > I really liked Mari's posted link to the "a list apart" blog about > "responsive web design" using "media query" (CSS).. however, it > seems to me that it takes the use of many languages and techniques > in many cases to get the job done... user agent serving (using PHP > or JS or alike), flexible CSS and web design, and a keen eye on your > target audience may all play apart. Not to mention that W3C has all but abandoned its efforts to standardize HTML5. They will likely follow the path of browsers in simple de facto standardization. > > However, this is a PHP list.. and I think we can better approach > this topic by limiting our scope to talk about how PHP could be > useful. > > My first question, being that my first language is not PHP, is; is > their any core PHP mobile detection functions/tools that exist? >From what I've seen, only the get_browser() function, which depends on the existence of a browsecap file, which may or may not be installed on your system. And if it is, it's 300K in size, and introduces significant latency to page loads as a result. > > I have a running list of mobile UA's that I picked up somewhere that > I often use and edit to distribute content accordingly. I also have > a PHP mobile detection script that I picked up somewhere. I'm sure > these things can be found via google as well. The problem, as Mari's > link suggests, is that UA "list's" and browser sniffing scripts need > maintaining quite regularly, since mobile UA's are being added on a > weekly basis perhaps. I suspect that's more as a result of everything sniffer scripts do. They don't just detect the platform, but a variety of other things as well. > > Many of my projects do some PC UA (browser) sniffing.. especially > for IE., as IE has it's own system that it uses for how to render > content. > > Anyway, I'm happy to share what I have.. but like I said, PHP is not > my first language, so I am interested to see what the more > established PHP'ers may have to say. How about this: those of you with iPhones, Androids and the like, point your phones at a page which reports $_SERVER['HTTP_USER_AGENT'] (like a page which runs the phpinfo() function), and post what you get back from that exercise and what device made the query. I'd like to see if there is anything significant which indicates handheld platforms. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
On 6 Feb 2012, at 21:12, Marc Guay wrote: >> the way your site renders should be purely based upon the size of the >> display. > > Although I mostly agree with this statement, it ignores the most > interesting aspects of mobile technology, such as being able to ask > the user for their GPS location and deliver content accordingly. I > worked on some real estate websites that would show the user the > houses for sale within a certai distance from where they were > standing, and then leverage Google Maps for a "get directions from > where you are" feature. > > The Mobile Web list has had some interesting discussions regarding this > stuff... > > http://groups.yahoo.com/group/mobile-web/ On the contrary, my statement dealt only with the way a site renders, not the content it renders. We should definitely be taking advantage of the additional features of mobile devices where it makes sense because that's where the real game-changing power lies. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
On Feb 6, 2012, at 1:01 PM, Stuart Dallas wrote: [snip] > Generally speaking you're better off with a design that automatically adapts > to the viewport on which it's being displayed. [snip] For a concrete example of responsive design in action, point your browser to http://www.sasquatchfestival.com/ and then slowly make the window wider/skinnier to see how the design adapts to different viewport sizes. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
> the way your site renders should be purely based upon the size of the display. Although I mostly agree with this statement, it ignores the most interesting aspects of mobile technology, such as being able to ask the user for their GPS location and deliver content accordingly. I worked on some real estate websites that would show the user the houses for sale within a certai distance from where they were standing, and then leverage Google Maps for a "get directions from where you are" feature. The Mobile Web list has had some interesting discussions regarding this stuff... http://groups.yahoo.com/group/mobile-web/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
On Mon, Feb 6, 2012 at 3:50 PM, Adam Richardson wrote: > On Mon, Feb 6, 2012 at 12:58 AM, Paul M Foster wrote: > >> This is sort of obliquely related to PHP. >> >> I don't have a smart phone, but I need to know a couple of things: >> >> 1) Do smart phones use the same browsers as the desktop, or do they have >> their own stripped down versions of browsers? >> > > Both, although more and more smart phones join the ranks of the > desktop-quality browser every day (iPhone and Android both have very > capable browsers, with the iPhone's omission of flash support being the > biggest difference between these two.) > > >> >> 2) When a browser broadcasts its header telling the server what kind of >> browser is involved, do they broadcast anything in the header to >> indicate that they're being run on a smart phone? >> > > Yes, but that gets complicated quickly: > http://www.zytrax.com/tech/web/mobile_ids.html > > >> >> 3) Bonus question: Is there a preferred method amongst coders to >> determine what type of environment is being browsed from, so as to serve >> up the proper type of page (desktop or smart phone version of a >> webpage)? >> > > To supplement the alistapart link already mentioned, here's another recent > writeup: > > http://dev.opera.com/articles/view/how-to-serve-the-right-content-to-mobile/ > Apologies, I sent the wrong link last time: http://dev.opera.com/articles/view/the-mobile-web-optimization-guide/ Adam
Re: [PHP] Headers on smart phone browsers
On 6 Feb 2012, at 05:58, Paul M Foster wrote: > This is sort of obliquely related to PHP. > > I don't have a smart phone, but I need to know a couple of things: There are simulators available for most smartphones. > 1) Do smart phones use the same browsers as the desktop, or do they have > their own stripped down versions of browsers? The trend is certainly moving towards full desktop capability, but personally I still think that if you expect a significant amount of traffic from mobile devices then your site should adapt accordingly. > 2) When a browser broadcasts its header telling the server what kind of > browser is involved, do they broadcast anything in the header to > indicate that they're being run on a smart phone? Yes, but there's no standard at the moment so detection requires something similar to https://gist.github.com/1124666. That code is pretty old, and I can't remember where I got it, but at the time it worked really well. > 3) Bonus question: Is there a preferred method amongst coders to > determine what type of environment is being browsed from, so as to serve > up the proper type of page (desktop or smart phone version of a > webpage)? Generally speaking you're better off with a design that automatically adapts to the viewport on which it's being displayed. While there's more than one reason for this, the overriding reason is that the same software (i.e. the same user agent) could be running on any size of device, from watch to huge flat panel screen on a wall. I think the world needs to move on from "is it a mobile device or not" to accepting the reality which is that the browser / OS is irrelevant, and that the way your site renders should be purely based upon the size of the display. Responsive designs such as that described in the A List Apart article Mari posted are fantastic tools for achieving this goal. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
On Mon, 2012-02-06 at 14:28 -0600, Donovan Brooke wrote: > Paul M Foster wrote: > > This is sort of obliquely related to PHP. > > > > I don't have a smart phone, but I need to know a couple of things: > > > > 1) Do smart phones use the same browsers as the desktop, or do they have > > their own stripped down versions of browsers? > > > > 2) When a browser broadcasts its header telling the server what kind of > > browser is involved, do they broadcast anything in the header to > > indicate that they're being run on a smart phone? > > > > 3) Bonus question: Is there a preferred method amongst coders to > > determine what type of environment is being browsed from, so as to serve > > up the proper type of page (desktop or smart phone version of a > > webpage)? > > > > Paul > > Hi Paul, I think this is a great PHP conversation.. and I don't > understand why GOTO threads always get way more replies than something > like this ;-) > > Diverse User Agent compatibility is going to be more and more of a > challenge for us.. gone are the days of a few known browsers that are > viewing our sites. From bots, to browsers, to mobile devices, to game > UA's, to app UA's.., to IE's stubborn outlook on the web... the idea of > user experience is growing complicated! ;-) > > I really liked Mari's posted link to the "a list apart" blog about > "responsive web design" using "media query" (CSS).. however, it seems to > me that it takes the use of many languages and techniques in many cases > to get the job done... user agent serving (using PHP or JS or alike), > flexible CSS and web design, and a keen eye on your target audience may > all play apart. > > However, this is a PHP list.. and I think we can better approach this > topic by limiting our scope to talk about how PHP could be useful. > > My first question, being that my first language is not PHP, is; is their > any core PHP mobile detection functions/tools that exist? > > I have a running list of mobile UA's that I picked up somewhere that I > often use and edit to distribute content accordingly. I also have a PHP > mobile detection script that I picked up somewhere. I'm sure these > things can be found via google as well. The problem, as Mari's link > suggests, is that UA "list's" and browser sniffing scripts need > maintaining quite regularly, since mobile UA's are being added on a > weekly basis perhaps. > > Many of my projects do some PC UA (browser) sniffing.. especially for > IE., as IE has it's own system that it uses for how to render content. > > Anyway, I'm happy to share what I have.. but like I said, PHP is not my > first language, so I am interested to see what the more established > PHP'ers may have to say. > > Donovan > > > > -- > D Brooke > Keeping a PHP angle to this, have you looked at using an up-to-date browscap.ini file with PHP? Basically, you can use that to read in the raw user agent string from the browser, and it then finds a matching entry in the ini file and gives you back some values about what it can assume about that device, such as whether it is known to support Java (although this is something you should be careful of, as it only tells you if it's is supported, not if there is an available JVM), if it is a mobile or search bot, what version of CSS it should support, etc. I use it myself in a personal web stats script, and as long as you keep the copy of the ini file recent, you should be OK. -- Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Headers on smart phone browsers
On Mon, Feb 6, 2012 at 12:58 AM, Paul M Foster wrote: > This is sort of obliquely related to PHP. > > I don't have a smart phone, but I need to know a couple of things: > > 1) Do smart phones use the same browsers as the desktop, or do they have > their own stripped down versions of browsers? > Both, although more and more smart phones join the ranks of the desktop-quality browser every day (iPhone and Android both have very capable browsers, with the iPhone's omission of flash support being the biggest difference between these two.) > > 2) When a browser broadcasts its header telling the server what kind of > browser is involved, do they broadcast anything in the header to > indicate that they're being run on a smart phone? > Yes, but that gets complicated quickly: http://www.zytrax.com/tech/web/mobile_ids.html > > 3) Bonus question: Is there a preferred method amongst coders to > determine what type of environment is being browsed from, so as to serve > up the proper type of page (desktop or smart phone version of a > webpage)? > To supplement the alistapart link already mentioned, here's another recent writeup: http://dev.opera.com/articles/view/how-to-serve-the-right-content-to-mobile/ I develop mobile games and websites, and I never use the User Agent to alter site/presentation. Media queries and types are the way I handle this (sometimes creating separate mobile resources, but most of the time creating designs that adapt accordingly.) All this to say, I don't use PHP to handle this aspect of the development. Adam -- Nephtali: A simple, flexible, fast, and security-focused PHP framework http://nephtaliproject.com
Re: [PHP] Headers on smart phone browsers
Paul M Foster wrote: This is sort of obliquely related to PHP. I don't have a smart phone, but I need to know a couple of things: 1) Do smart phones use the same browsers as the desktop, or do they have their own stripped down versions of browsers? 2) When a browser broadcasts its header telling the server what kind of browser is involved, do they broadcast anything in the header to indicate that they're being run on a smart phone? 3) Bonus question: Is there a preferred method amongst coders to determine what type of environment is being browsed from, so as to serve up the proper type of page (desktop or smart phone version of a webpage)? Paul Hi Paul, I think this is a great PHP conversation.. and I don't understand why GOTO threads always get way more replies than something like this ;-) Diverse User Agent compatibility is going to be more and more of a challenge for us.. gone are the days of a few known browsers that are viewing our sites. From bots, to browsers, to mobile devices, to game UA's, to app UA's.., to IE's stubborn outlook on the web... the idea of user experience is growing complicated! ;-) I really liked Mari's posted link to the "a list apart" blog about "responsive web design" using "media query" (CSS).. however, it seems to me that it takes the use of many languages and techniques in many cases to get the job done... user agent serving (using PHP or JS or alike), flexible CSS and web design, and a keen eye on your target audience may all play apart. However, this is a PHP list.. and I think we can better approach this topic by limiting our scope to talk about how PHP could be useful. My first question, being that my first language is not PHP, is; is their any core PHP mobile detection functions/tools that exist? I have a running list of mobile UA's that I picked up somewhere that I often use and edit to distribute content accordingly. I also have a PHP mobile detection script that I picked up somewhere. I'm sure these things can be found via google as well. The problem, as Mari's link suggests, is that UA "list's" and browser sniffing scripts need maintaining quite regularly, since mobile UA's are being added on a weekly basis perhaps. Many of my projects do some PC UA (browser) sniffing.. especially for IE., as IE has it's own system that it uses for how to render content. Anyway, I'm happy to share what I have.. but like I said, PHP is not my first language, so I am interested to see what the more established PHP'ers may have to say. Donovan -- D Brooke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
> 1) Do smart phones use the same browsers as the desktop, or do they have > their own stripped down versions of browsers? Different browsers, some of which are worse than IE (see Blackberry). > 2) When a browser broadcasts its header telling the server what kind of > browser is involved, do they broadcast anything in the header to > indicate that they're being run on a smart phone? Nothing so specific or easy to identify as "i am a smartphone". Depending on your target audience, simple regex checks for the strings "iphone", "android", etc. can do the trick, but if you want specific details about the device... > 3) Bonus question: Is there a preferred method amongst coders to > determine what type of environment is being browsed from, so as to serve > up the proper type of page (desktop or smart phone version of a > webpage)? ... the WURFL database and things akin to it or based on / stolen from it can help parse the header string and return a plethora of information about it (screen size, AJAX ability, markup capacity, etc). Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
Nice article!! You should read up on responsive web design. http://www.alistapart.com/articles/responsive-web-design/ should get you started. HTH!= -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
On Feb 5, 2012, at 9:58 PM, Paul M Foster wrote: [snip] > 3) Bonus question: Is there a preferred method amongst coders to > determine what type of environment is being browsed from, so as to serve > up the proper type of page (desktop or smart phone version of a > webpage)? [snip] You should read up on responsive web design. http://www.alistapart.com/articles/responsive-web-design/ should get you started. HTH! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers already sent
> Thanks. That was the problem. I spent a day trying to debug this. Smash head against wall first, ask questions later. That's my methodology as well. :) Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers already sent
Hi, > Perhaps your server is configured to have output buffering enabled by default Thanks. That was the problem. I spent a day trying to debug this. Kranthi. http://goo.gl/e6t3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers already sent
Perhaps your server is configured to have output buffering enabled by default? Check php.ini / phpinfo(). --Larry Garfield On 11/11/2011 12:12 AM, Kranthi Krishna wrote: Hi all, I am missing something pretty obvious here. The PHP Manual says "Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP.". A simple test case shows otherwise I have the following code test http://goo.gl/e6t3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] headers: setting right for browser to force reload at a certain point in time
German Geek wrote: > This didn't work. ctrl+i brought up my bookmarks. ?? Do i need a > special plugin/extension? Have web developer etc. Nope, this is standard FF. Ctrl+i should give you the "Page Info" window. Try looking for that in your menubar and pulldowns. -- Per Jessen, Zürich (3.1°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] headers: setting right for browser to force reload at a certain point in time
2009/2/23 Per Jessen > German Geek wrote: > > > Yes, that's what i thought, but with my FF 3.0 the resources > > (swf,png,jpg) don't get reloaded. I have to reload the page (after > > deleting cache). > > > > Something to do with the Apache configuration? > > Hi Tim, > > Try loading up just a single file in FF - one of your graphics for > instance - then hit Ctrl-i to get the info page. That will tell you > exactly how FF sees the file - expiry time etc. > Hi Per, Thanks. But: This didn't work. ctrl+i brought up my bookmarks. ?? Do i need a special plugin/extension? Have web developer etc. I have Firebug but in the net tab the cached resources don't show up when reloading the page, i guess because they are not reloaded... So, i can't think of a way how to see that information when it is in cache. I had followed some examples on the web talking about the e-tag header which changes the checksum when the file changes, also i remember setting the expiry to yesterday and things like that... However it all didn't work. Anyway, i might just force a reload by changing the links every time dynamically, although it seems a bit overkill :-S. Tim-Hinnerk Heuer http://www.ihostnz.com P. J. O'Rourke - "Everybody knows how to raise children, except the people who have them." > > /Per > > > -- > Per Jessen, Zürich (2.6°C) > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] headers: setting right for browser to force reload at a certain point in time
German Geek wrote: > Yes, that's what i thought, but with my FF 3.0 the resources > (swf,png,jpg) don't get reloaded. I have to reload the page (after > deleting cache). > > Something to do with the Apache configuration? Hi Tim, Try loading up just a single file in FF - one of your graphics for instance - then hit Ctrl-i to get the info page. That will tell you exactly how FF sees the file - expiry time etc. /Per -- Per Jessen, Zürich (2.6°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] headers: setting right for browser to force reload at a certain point in time
Yes, that's what i thought, but with my FF 3.0 the resources (swf,png,jpg) don't get reloaded. I have to reload the page (after deleting cache). Something to do with the Apache configuration? ?? Thanks for the reply. Tim-Hinnerk Heuer http://www.ihostnz.com Laurence J. Peter - "If two wrongs don't make a right, try three." 2009/2/23 Per Jessen > German Geek wrote: > > > Hi All, > > > > We have an application that generates dynamic ebooks. One of the > > (minor) problems (but yet annoying) is that when a user comes back to > > an ebook, they have to actually delete the cache and reload the page > > to not get the cached version which might be wrong because the content > > or even the flash application is updated. > > Deleting the cache should not be necessary, a reload should be enough. > (it certainly is with Firefox). > > > It would be neat if we could force a reload of the page, but only with > > a special condition like the ebook being updated or the swf. The swf > > and also the other resources are not reloaded though, because it is a > > get request. > > The request type has nothing to do with it - the browser will do a > conditional GET if the local copy is expired. Just set the right > expiry time on your files when you serve them, then they will > automatically be checked by the browser. > > > /Per > > > -- > Per Jessen, Zürich (2.8°C) > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] headers: setting right for browser to force reload at a certain point in time
German Geek wrote: > Hi All, > > We have an application that generates dynamic ebooks. One of the > (minor) problems (but yet annoying) is that when a user comes back to > an ebook, they have to actually delete the cache and reload the page > to not get the cached version which might be wrong because the content > or even the flash application is updated. Deleting the cache should not be necessary, a reload should be enough. (it certainly is with Firefox). > It would be neat if we could force a reload of the page, but only with > a special condition like the ebook being updated or the swf. The swf > and also the other resources are not reloaded though, because it is a > get request. The request type has nothing to do with it - the browser will do a conditional GET if the local copy is expired. Just set the right expiry time on your files when you serve them, then they will automatically be checked by the browser. /Per -- Per Jessen, Zürich (2.8°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] headers-excel file-bad data
On Tue, July 31, 2007 12:32 pm, blackwater dev wrote: > I have an excel file that I am generating. If I copy over the > generated > file and then open it in excel, it works fine, if I try to let the > user > download it using the headers below, when I then open it excel > complains > that it is an unrecognizable format and the info is garbled...any > ideas??? > > Thanks! > > header('Pragma: public'); > header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); > // > Date in the past > header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT'); > header('Cache-Control: no-store, no-cache, must-revalidate'); > // > HTTP/1.1 > header('Cache-Control: pre-check=0, post-check=0, max-age=0'); > // > HTTP/1.1 > header ("Pragma: no-cache"); > header("Expires: 0"); > header('Content-Transfer-Encoding: none'); > header('Content-Type: application/vnd.ms-excel;'); > // > This should work for IE & Opera > header("Content-type: application/x-msexcel"); > // > This should work for the rest > header('Content-Disposition: attachment; filename="myfile.xls"'); > readfile("/tmp/myfile.xls"); Copy it over how?... Plus, I gotta tell ya, all those goofy extra headers are simply NOT doing what you think they are... First of all, unless you add a ", TRUE" as a second arg, each header() call with the same "XXX: " start is REPLACING the previous ones. So you are ALWAYS using Content-type: application/x-msexcel and you might as well rip the rest of them out. Some headers can have multiple instances (Cache-control) but you only get ONE Content-type. Period. You should also compare the actual bytes of the file you get from the download with the file you copied over. Did PHP add something or strip something out? Usually this problem has a self-evident solution once you identify the problem, so I'll say no more in this vein. And, finally, if you want to support legacy browsers and all kinds of "gotchas" with downloads, read this rant: http://richardlynch.blogspot.com/2006/06/php-downloads-content-disposition.html ymmv -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie 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] headers-excel file-bad data
At 1:32 PM -0400 7/31/07, blackwater dev wrote: Hello, I have an excel file that I am generating. If I copy over the generated file and then open it in excel, it works fine, if I try to let the user download it using the headers below, when I then open it excel complains that it is an unrecognizable format and the info is garbled...any ideas??? Yes, an idea -- this might be due to a bug that's found in excel files if a value exist (or doesn't) in the first cell or column of the spreadsheet. I vaguely remember running into that several years ago. You can Google "excel bug first cell" HTH, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] headers and newline at end of script
Martin Marques wrote: > On Thu, 20 Jul 2006 11:30:14 -0400, John Nichel <[EMAIL PROTECTED]> wrote: >> Jochem Maas wrote: >>> I never add the final closing '?>' in any script for this very reason. >>> >> 'Cause you're a SLACKER!!! > > What the hell is a SLACKER??? I'm a slacker. > > -- > - > Lic. Martín Marqués | SELECT 'mmarques' || > Centro de Telemática| '@' || 'unl.edu.ar'; > Universidad Nacional| DBA, Programador, > del Litoral | Administrador > - > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] headers and newline at end of script
Jochem Maas wrote: Martin Marques wrote: On Thu, 20 Jul 2006 11:30:14 -0400, John Nichel <[EMAIL PROTECTED]> wrote: Jochem Maas wrote: I never add the final closing '?>' in any script for this very reason. 'Cause you're a SLACKER!!! What the hell is a SLACKER??? I'm a slacker. Which is why you aren't up for the job here. The slacker position belongs to me. -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] headers and newline at end of script
On Thu, 2006-07-20 at 14:39, Kilbride, James P. wrote: > He never said he didn't want you to do his coding, simply that you were > a slacker. Considering he's self proclaimed 'lazy' just means the two of > you should get on great and you'll probably understand his code better. Won't work because John needs to hire someone to do his work for him so he can better excel at slacking himself. Cheers, Rob. > > James Kilbride > > SNIPPAGE(Jochem Maas wrote:) > > no chance of me getting that code-bitch job you've been > > forced to write a 'test' for then? ;-) > > -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] headers and newline at end of script
He never said he didn't want you to do his coding, simply that you were a slacker. Considering he's self proclaimed 'lazy' just means the two of you should get on great and you'll probably understand his code better. James Kilbride SNIPPAGE(Jochem Maas wrote:) > no chance of me getting that code-bitch job you've been > forced to write a 'test' for then? ;-) > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] headers and newline at end of script
I'd explain but it'd be too much work. James Kilbride > -Original Message- > From: Martin Marques [mailto:[EMAIL PROTECTED] > Sent: Thursday, July 20, 2006 2:32 PM > To: John Nichel > Cc: php-general@lists.php.net > Subject: Re: [PHP] headers and newline at end of script > > > On Thu, 20 Jul 2006 11:30:14 -0400, John Nichel > <[EMAIL PROTECTED]> wrote: > > Jochem Maas wrote: > >> > >> I never add the final closing '?>' in any script for this > very reason. > >> > > > > 'Cause you're a SLACKER!!! > > What the hell is a SLACKER??? > > -- > - > Lic. Martín Marqués | SELECT 'mmarques' || > Centro de Telemática| '@' || 'unl.edu.ar'; > Universidad Nacional| DBA, Programador, > del Litoral | Administrador > - > > -- > 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] headers and newline at end of script
On Thu, 20 Jul 2006 11:30:14 -0400, John Nichel <[EMAIL PROTECTED]> wrote: > Jochem Maas wrote: >> >> I never add the final closing '?>' in any script for this very reason. >> > > 'Cause you're a SLACKER!!! What the hell is a SLACKER??? -- - Lic. Martín Marqués | SELECT 'mmarques' || Centro de Telemática| '@' || 'unl.edu.ar'; Universidad Nacional| DBA, Programador, del Litoral | Administrador - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] headers and newline at end of script
John Nichel wrote: > Jochem Maas wrote: >> Martin Marques wrote: >>> I'm looking for an opinion on programming style. >>> >>> Basicaly, I make systems using PEAR::DB and PEAR::HTML_Template_IT. This >>> last one puts all the HTML away from the PHP code, which has made life >>> much easier. >>> >>> Now, sometimes I warning messages like this one: >>> >>> PHP Warning: Cannot modify header information - headers already sent in >>> >>> I know what it means, so I just look for newlines at the end of my PHP >>> scripts, especially after the closing ?> and delete them. >>> >>> Now, my question is: Is it a bad practice to "NOT" close the script with >>> the PHP closing "?>"? I mean, just leave the script without a closing >>> PHP simbols, as this scripts are included? >> >> I never add the final closing '?>' in any script for this very reason. >> > > 'Cause you're a SLACKER!!! no chance of me getting that code-bitch job you've been forced to write a 'test' for then? ;-) > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] headers and newline at end of script
On Thu, 2006-07-20 at 11:30, John Nichel wrote: > Jochem Maas wrote: > > Martin Marques wrote: > >> I'm looking for an opinion on programming style. > >> > >> Basicaly, I make systems using PEAR::DB and PEAR::HTML_Template_IT. This > >> last one puts all the HTML away from the PHP code, which has made life > >> much easier. > >> > >> Now, sometimes I warning messages like this one: > >> > >> PHP Warning: Cannot modify header information - headers already sent in > >> > >> I know what it means, so I just look for newlines at the end of my PHP > >> scripts, especially after the closing ?> and delete them. > >> > >> Now, my question is: Is it a bad practice to "NOT" close the script with > >> the PHP closing "?>"? I mean, just leave the script without a closing > >> PHP simbols, as this scripts are included? > > > > I never add the final closing '?>' in any script for this very reason. > > > > 'Cause you're a SLACKER!!! Some of the best coders are slackers... because they find better ways to code to prevent having to write so much code :) But to answer the question... http://marc.theaimsgroup.com/?l=php-dev&m=106896286829744&w=2 http://marc.theaimsgroup.com/?l=php-dev&m=106896382030183&w=2 Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] headers and newline at end of script
Jochem Maas wrote: Martin Marques wrote: I'm looking for an opinion on programming style. Basicaly, I make systems using PEAR::DB and PEAR::HTML_Template_IT. This last one puts all the HTML away from the PHP code, which has made life much easier. Now, sometimes I warning messages like this one: PHP Warning: Cannot modify header information - headers already sent in I know what it means, so I just look for newlines at the end of my PHP scripts, especially after the closing ?> and delete them. Now, my question is: Is it a bad practice to "NOT" close the script with the PHP closing "?>"? I mean, just leave the script without a closing PHP simbols, as this scripts are included? I never add the final closing '?>' in any script for this very reason. 'Cause you're a SLACKER!!! -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] headers and newline at end of script
Martin Marques wrote: > I'm looking for an opinion on programming style. > > Basicaly, I make systems using PEAR::DB and PEAR::HTML_Template_IT. This > last one puts all the HTML away from the PHP code, which has made life > much easier. > > Now, sometimes I warning messages like this one: > > PHP Warning: Cannot modify header information - headers already sent in > > I know what it means, so I just look for newlines at the end of my PHP > scripts, especially after the closing ?> and delete them. > > Now, my question is: Is it a bad practice to "NOT" close the script with > the PHP closing "?>"? I mean, just leave the script without a closing > PHP simbols, as this scripts are included? I never add the final closing '?>' in any script for this very reason. whether it's bad practice or I don't know (can't be any worse than the flamewar on internals@lists.php.net though ;-) > > -- > 21:50:04 up 2 days, 9:07, 0 users, load average: 0.92, 0.37, 0.18 > - > Lic. Martín Marqués | SELECT 'mmarques' || > Centro de Telemática| '@' || 'unl.edu.ar'; > Universidad Nacional| DBA, Programador, > del Litoral | Administrador > - > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] headers already sent.
There is no real way of knowing if output is going to be sent before a header or not, unless its a very simple page. Your best bet is to investigate the output buffering functions here: http://www.php.net/manual/en/ref.outcontrol.php HTH Steve ""P. Guethlein"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > At 10:30 PM 04/07/2006, you wrote: >>Comment inline: > > Thanks, I just found that out after, well I don't want to say how long it > took . > > Is that just the way things are in PHP or is there a command / > configuration to make something like this more obvious? Hmmm. maybe > the IDE I'm using? Using EnginSite. Is there a better one for a Windows > Environment ? > > ( head banging against wall ) > > -Pete > > > > >>P. Guethlein wrote: >>>(Know enough to be dangerous beginner...) >>> >>>Routine for a web login asked user name and password. >>> >>>User Name is entered correctly. >>> >>>Password is Incorrect. >>> >>>Next Try. >>> >>>User Name is enter correctly. >>> >>>Password is Entered Correctly. >>> >>>PHP notifies me on the html output that I am logged in. However, an >>>error is appearing in text above the html output. It states >>> >>>Warning: Cannot modify header information - headers already sent by >>>(output started at D:\webpages\\users.inc:11) in >>>D:\webpages\\web\loginfunctions.php on line 26 >>> >>>Users.inc is >>> >>>== >$domain = 'localhost'; >>>$admin = 'x'; >>>$user = 'x'; >>>$web = 'x'; >>>$password = 'xx'; >>>$site = 'x'; >>>$leads = 'x'; >>>?> >>This gap right here, it's outputting a carriage return and/or linefeed. >>headers get sent on the first character of output being sent. >// Configuration settings for My Site >>> >>>// Email Settings >>>$mailsite['from_name'] = 'x Website'; // from email name >>>$mailsite['from_email'] = '[EMAIL PROTECTED]'; // from email address >>> >>>// Just in case we need to relay to a different server, >>>// provide an option to use external mail server. >>>$mailsite['smtp_mode'] = 'enabled'; // enabled or disabled >>>$mailsite['smtp_host'] = 'mail..xxx;mail.x2.xxx'; >>>$mailsite['smtp_port'] = '25'; >>>$mailsite['smtp_username'] = null; >>>?> >>>=== >>> >>>Line 26 from the loginfunctions.php file is >>> >>>//now redirect the user to whatever page they wanted. >>>header('Location: index.php?href='.$link); >>> >>>== >>> >>>I can anticipate what the problem is with the notification that PHP gives >>>me with the headers already output. However, it says 'headers already >>>sent by users.inc', huh? >>> >>>Suggestions of where to look on this bug is appreciated! >>> >>>-Pete >> >>-- >>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] headers already sent.
At 10:30 PM 04/07/2006, you wrote: Comment inline: Thanks, I just found that out after, well I don't want to say how long it took . Is that just the way things are in PHP or is there a command / configuration to make something like this more obvious? Hmmm. maybe the IDE I'm using? Using EnginSite. Is there a better one for a Windows Environment ? ( head banging against wall ) -Pete P. Guethlein wrote: (Know enough to be dangerous beginner...) Routine for a web login asked user name and password. User Name is entered correctly. Password is Incorrect. Next Try. User Name is enter correctly. Password is Entered Correctly. PHP notifies me on the html output that I am logged in. However, an error is appearing in text above the html output. It states Warning: Cannot modify header information - headers already sent by (output started at D:\webpages\\users.inc:11) in D:\webpages\\web\loginfunctions.php on line 26 Users.inc is == This gap right here, it's outputting a carriage return and/or linefeed. headers get sent on the first character of output being sent. === Line 26 from the loginfunctions.php file is //now redirect the user to whatever page they wanted. header('Location: index.php?href='.$link); == I can anticipate what the problem is with the notification that PHP gives me with the headers already output. However, it says 'headers already sent by users.inc', huh? Suggestions of where to look on this bug is appreciated! -Pete -- 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] headers already sent.
Comment inline: P. Guethlein wrote: (Know enough to be dangerous beginner...) Routine for a web login asked user name and password. User Name is entered correctly. Password is Incorrect. Next Try. User Name is enter correctly. Password is Entered Correctly. PHP notifies me on the html output that I am logged in. However, an error is appearing in text above the html output. It states Warning: Cannot modify header information - headers already sent by (output started at D:\webpages\\users.inc:11) in D:\webpages\\web\loginfunctions.php on line 26 Users.inc is == This gap right here, it's outputting a carriage return and/or linefeed. headers get sent on the first character of output being sent. === Line 26 from the loginfunctions.php file is //now redirect the user to whatever page they wanted. header('Location: index.php?href='.$link); == I can anticipate what the problem is with the notification that PHP gives me with the headers already output. However, it says 'headers already sent by users.inc', huh? Suggestions of where to look on this bug is appreciated! -Pete -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] headers .vs javascript location.href
On Sep 19, 2005, at 5:08 PM, Chris Shiflett wrote: bruce wrote: i'd already asked/explained the error. to reiterate, the error i'm getting is the error that's generated when you try to use the php 'header' function, and it throws a warning/error regarding 'headers already being sent...' If you're absolutely certain that your script produces no output prior to the point where you call header(), then you might want to check to see whether an error is being generated - with display_errors enabled, these are included in the output stream. Also, just copy/paste your exact error here, and also include the lines indicated in the message (and a few lines before/after). I bet someone on this list can spot the problem. Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This is just a guess here bruce, but do you have any whitespace/line breaks before the PHP code starts? If so then you are generating output before you even get to the code. If you are using a config file of any kind you'll also need to make sure it has no whitespace/ line breaks before or after the code blocks. Again: just a guess. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] headers .vs javascript location.href
bruce wrote: i'd already asked/explained the error. to reiterate, the error i'm getting is the error that's generated when you try to use the php 'header' function, and it throws a warning/error regarding 'headers already being sent...' If you're absolutely certain that your script produces no output prior to the point where you call header(), then you might want to check to see whether an error is being generated - with display_errors enabled, these are included in the output stream. Also, just copy/paste your exact error here, and also include the lines indicated in the message (and a few lines before/after). I bet someone on this list can spot the problem. Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] headers .vs javascript location.href
chris, i'd already asked/explained the error. to reiterate, the error i'm getting is the error that's generated when you try to use the php 'header' function, and it throws a warning/error regarding 'headers already being sent...' the soln appears to be to use the php buffering functions, as this is supposed to stop output from being generated/posted, allowing the app to 'buffer' the output until the page is displayed. i've tried to use an 'ob_start()' as the very 1st line in the index.php page that's being displayed. i've also tried to insert the 'ob_start()' in a number of various places within the app with no change... my question was how/what could i possibly do, short of using the javascript soln, which seems to work... i also stated that i could readily provide the code that i'm creating if anyone wanted to take an actual look. and as i also stated, yeah, it could/should be cleaned up, but for now, it's a test app... -bruce -Original Message- From: Chris Shiflett [mailto:[EMAIL PROTECTED] Sent: Sunday, September 18, 2005 8:20 PM To: [EMAIL PROTECTED] Cc: 'php' Subject: Re: [PHP] headers .vs javascript location.href bruce wrote: > need to talk to someone to figure out how/what i need to do to use > the php 'headers' function, as opposed to the javascript 'location.href'. > > i've tried to implement the buffering functions, but still get the same > error... > > is there someone that i can talk to about this, who ha > experience/understanding of what's going on. i've thought about rewriting > what i have to this point, but i've got code interspersed with html... > > yeah.. i know... cleaning it up would probably make things easier/better, > but this is a quick/dirty test.. and i don't claim to be a web developer! You need to ask a question if you want to receive an answer. If your question really is whether there is anyone you can talk to, then the answer is yes. There are quite a few people on this list who know a great deal about the topics you mention. (You might want to start by clarifying the reference to "the same error.") Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- 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] headers .vs javascript location.href
bruce wrote: need to talk to someone to figure out how/what i need to do to use the php 'headers' function, as opposed to the javascript 'location.href'. i've tried to implement the buffering functions, but still get the same error... is there someone that i can talk to about this, who ha experience/understanding of what's going on. i've thought about rewriting what i have to this point, but i've got code interspersed with html... yeah.. i know... cleaning it up would probably make things easier/better, but this is a quick/dirty test.. and i don't claim to be a web developer! You need to ask a question if you want to receive an answer. If your question really is whether there is anyone you can talk to, then the answer is yes. There are quite a few people on this list who know a great deal about the topics you mention. (You might want to start by clarifying the reference to "the same error.") Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] headers and session
Hi Alessandro try this as well (Put these lines before and after your redirect/header statement); session_write_close(); header( "Location: ".$PHPcmd ); exit(); hope this helps Angelo Zanetti Z Logic www.zlogic.co.za Alessandro Rosa wrote: >Hi to all, > >I got a problem while storing session variables. > >session_start(); >header( "Cache-control: private" ); > >require_once("config.inc.php"); > > >$_SESSION['session_psw'] = $_POST['txtPassword']; >$_SESSION['session_user'] = $_POST['txtIdUtente']; > > > >$PHPcmd = $GLOBALS['gestionale_path_name']."test/2.php" ; > >header( "Location: ".$PHPcmd ); > >?> > >After the call to header(...), the values of session variables are lost. > >I think I should fix this up with some settings in my php.ini > >Could you help me, please? > >Alessandro Rosa > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Headers already sent error
Pls Make sure that outside your tags, these is no any blankspace or sth else. Best regards, Yang Shiqi -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: Thursday, February 03, 2005 3:44 PM To: [php] PHP General List Subject: Re: [PHP] Headers already sent error Tim Burgan wrote: > Hello, > > > I'm receiving an error "Cannot modify header information - headers > already sent by XXX". > > In my php, I have a heap of code, then use header("Location: > blah.php"); to redirect the user. I get this error on the webhost, but > not on my local host. > > I've searched and found that this can be caused by spaces after the > closing php tag, but I don't have any. > > What could this be? > > > Tim > Rest assured, *something* is getting output before you try that header() call. Anything outside of PHP tags (carriage rturns/line feeds/spaces) any echo or print. To help you figure it out, try doing something like exit('STARTOFBODY'); instead of the header call. Then view the source of the ouput and see what precedes that Chris -- 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] Headers already sent error
Tim Burgan wrote: Hello, I'm receiving an error "Cannot modify header information - headers already sent by XXX". In my php, I have a heap of code, then use header("Location: blah.php"); to redirect the user. I get this error on the webhost, but not on my local host. I've searched and found that this can be caused by spaces after the closing php tag, but I don't have any. What could this be? Tim Rest assured, *something* is getting output before you try that header() call. Anything outside of PHP tags (carriage rturns/line feeds/spaces) any echo or print. To help you figure it out, try doing something like exit('STARTOFBODY'); instead of the header call. Then view the source of the ouput and see what precedes that Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers already sent error
On Thu, 2005-02-03 at 12:59 +1030, Tim Burgan wrote: > Hello, > > > I'm receiving an error "Cannot modify header information - headers > already sent by XXX". > > In my php, I have a heap of code, then use header("Location: blah.php"); > to redirect the user. I get this error on the webhost, but not on my > local host. > > I've searched and found that this can be caused by spaces after the > closing php tag, but I don't have any. > > What could this be? > > > Tim > try adding: ob_start(); to the top of your file -Robby -- /*** * Robby Russell | Owner.Developer.Geek * PLANET ARGON | www.planetargon.com * Portland, OR | [EMAIL PROTECTED] * 503.351.4730 | blog.planetargon.com * PHP/PostgreSQL Hosting & Development * --- Now hosting PostgreSQL 8.0! --- / -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers Again
--- PETCOL <[EMAIL PROTECTED]> wrote: > Unfortunately history tells me that php like ColdFusion will one day > be bought out by the big corporates, or at least they'll have a > considerable financial vested interest in it. There's nothing to buy. Welcome to open source. Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly Coming mid-2004 HTTP Developer's Handbook - Sams http://httphandbook.org/ PHP Community Site http://phpcommunity.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers Again
PETCOL wrote: Unfortunately history tells me that php like ColdFusion will one day be bought out by the big corporates, or at least they'll have a considerable financial vested interest in it. Not likely. Since PHP is open source if Zend decided to change the license I'm certain it would be forked and continued as an open source project. This is the basis of why open source software is so popular and also why there is negligible gain to be had by Zend in changing the license. At which time we hope way off in the future, we'll all have to start paying for support and maintenance contracts. EVen if it did happen you'd be in no different a position than you are now. This mailing list is primarily user-supported and would likely continue even if PHP became a commercial product (which it won't - see above). If you want commercial support for PHP you can get it. And you'll pay for it. Allaire owned ColdFusion, the developer network was extremely co-operative, then joint venture between Macromedia and Allaire, now if you want good old assistance you need a "Devnet" contract. ColdFusion was never open source (afaik). That's the difference. For more info on what 'open source' actually means, see http://www.opensource.org/docs/definition.php -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers Again
Stuart, Unfortunately history tells me that php like ColdFusion will one day be bought out by the big corporates, or at least they'll have a considerable financial vested interest in it. At which time we hope way off in the future, we'll all have to start paying for support and maintenance contracts. Allaire owned ColdFusion, the developer network was extremely co-operative, then joint venture between Macromedia and Allaire, now if you want good old assistance you need a "Devnet" contract. Cheers, I'm going to bed. Col "Stuart" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > PETCOL wrote: > > Stuart > > > > Thank you. > > Don't thank me[1], thank them. Preferably with cash[2]. > > [1] I will accept cash if offered. > [2] http://marc.theaimsgroup.com/?q=about#Begware > > -- > Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers Again
[EMAIL PROTECTED]> Petcol: > Jason, > > What I shock, 307,000 entries returned. > > Maybe someone with ability greater or other than I, should give some > serious consideration to a solution or work around. > > I've been using ColdFuion for 7 years and I can do a url="anotherlocation.htm"> anywhere in the page, no matter if I've > run CFML, Javascript it still works. > > Sorry I'm just frustrated. > > Regards > Col Put ob_start(); in the beginning of the script. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers Again
On Tuesday 17 February 2004 17:21, PETCOL wrote: > Alliare and Macromedias forums for ColdFusion and other software, allow a > search through the entire post, archive everything. Which always avoid > this problem of a newsgroup. Maybe I'm wrong, but I don't thing there's a > search like this for a newsgroup? Umm, did you take a look at my signature? > If you do happen to know, as it would appear you may, the url of the answer > to the original question, then could you simply supply it. I do not know the url of the answer to the original question off hand. But I can assure you that a quick search of the archives will uncover plenty of answers. > I'm new to this code, I appreciate any assistance, and I will troll through > archives etc to get it. However, if some kind sole can save me 3 hours > work, I'll also appreciate it, which is probably why this list get > repetative posts. The trouble with this list is that it is too friendly and useful! People use it as the first resort instead of using the manual, the archives and of course google. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* If there is any realistic deterrent to marriage, it's the fact that you can't afford divorce. -- Jack Nicholson */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers Again
PETCOL wrote: Stuart Thank you. Don't thank me[1], thank them. Preferably with cash[2]. [1] I will accept cash if offered. [2] http://marc.theaimsgroup.com/?q=about#Begware -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers Again
Michael, So are you answering my problem not, really just antaganising it. I've tried ob_end_flush(); it didn't work, maybe it's a server configuration issue. Maybe it's just php can not do it? So pleased to hear the php community is here to help each other. For those of you who are making the effort I thank you. Col "Michael Egan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Got to agree with Jason's comments - as I'm sure all other regulars on the list will do. I've just had a quick look at the php.net site, done a search for "header" and halfway down the first page returned found this: "Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file." Not hard is it? Regards, Michael Egan > -Original Message- > From: PETCOL [mailto:[EMAIL PROTECTED] > Sent: 17 February 2004 09:22 > To: [EMAIL PROTECTED] > Subject: Re: [PHP] Headers Again > > > Jason, > > I appreciate people get just as frustrate by reading repetative posts. > > Alliare and Macromedias forums for ColdFusion and other > software, allow a > search through the entire post, archive everything. Which > always avoid this > problem of a newsgroup. Maybe I'm wrong, but I don't thing > there's a search > like this for a newsgroup? > > If you do happen to know, as it would appear you may, the url > of the answer > to the original question, then could you simply supply it. > > I'm new to this code, I appreciate any assistance, and I will > troll through > archives etc to get it. However, if some kind sole can save > me 3 hours > work, I'll also appreciate it, which is probably why this list get > repetative posts. > > Cheers, relax, and have a nice day. > > Col > > "Jason Wong" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > On Tuesday 17 February 2004 16:37, PETCOL wrote: > > > > What you're asking is a VERY FAQ. Something that's asked > almost every > other > > day. The list archives will have plenty of answers. > > > > > What I shock, 307,000 entries returned. > > > > If you don't want to trawl through those search results > then read the > error > > message again (carefully, all of it). If you still haven't > figured it then > > read the manual entry for header(), every single line, then > correlate what > is > > said with the error message. > > > > > Maybe someone with ability greater or other than I, > should give some > > > serious consideration to a solution or work around. > > > > All the info you need is in the archives. > > > > > I've been using ColdFuion for 7 years and I can do a > > url="anotherlocation.htm"> anywhere in the page, no > matter if I've run > > > CFML, Javascript it still works. > > > > You can do that as well, again, all the info you need is in > the archives. > > > > > Sorry I'm just frustrated. > > > > I'm sure regulars on the list are just as frustrated at how > often this > > question crops up and at how little research people do before asking > another > > FAQ. > > > > -- > > Jason Wong -> Gremlins Associates -> www.gremlins.biz > > Open Source Software Systems Integrators > > * Web Design & Hosting * Internet & Intranet Applications > Development * > > -- > > Search the list archives before you post > > http://marc.theaimsgroup.com/?l=php-general > > -- > > /* > > Losing your drivers' license is just God's way of saying > "BOOGA, BOOGA!" > > */ > > -- > 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] Headers Again
Stuart Thank you. "Stuart" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > PETCOL wrote: > > Alliare and Macromedias forums for ColdFusion and other software, allow a > > search through the entire post, archive everything. Which always avoid this > > problem of a newsgroup. Maybe I'm wrong, but I don't thing there's a search > > like this for a newsgroup? > > http://marc.theaimsgroup.com/?l=php-general > > -- > Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers Again
PETCOL wrote: Alliare and Macromedias forums for ColdFusion and other software, allow a search through the entire post, archive everything. Which always avoid this problem of a newsgroup. Maybe I'm wrong, but I don't thing there's a search like this for a newsgroup? http://marc.theaimsgroup.com/?l=php-general -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Headers Again
Got to agree with Jason's comments - as I'm sure all other regulars on the list will do. I've just had a quick look at the php.net site, done a search for "header" and halfway down the first page returned found this: "Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file." Not hard is it? Regards, Michael Egan > -Original Message- > From: PETCOL [mailto:[EMAIL PROTECTED] > Sent: 17 February 2004 09:22 > To: [EMAIL PROTECTED] > Subject: Re: [PHP] Headers Again > > > Jason, > > I appreciate people get just as frustrate by reading repetative posts. > > Alliare and Macromedias forums for ColdFusion and other > software, allow a > search through the entire post, archive everything. Which > always avoid this > problem of a newsgroup. Maybe I'm wrong, but I don't thing > there's a search > like this for a newsgroup? > > If you do happen to know, as it would appear you may, the url > of the answer > to the original question, then could you simply supply it. > > I'm new to this code, I appreciate any assistance, and I will > troll through > archives etc to get it. However, if some kind sole can save > me 3 hours > work, I'll also appreciate it, which is probably why this list get > repetative posts. > > Cheers, relax, and have a nice day. > > Col > > "Jason Wong" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > On Tuesday 17 February 2004 16:37, PETCOL wrote: > > > > What you're asking is a VERY FAQ. Something that's asked > almost every > other > > day. The list archives will have plenty of answers. > > > > > What I shock, 307,000 entries returned. > > > > If you don't want to trawl through those search results > then read the > error > > message again (carefully, all of it). If you still haven't > figured it then > > read the manual entry for header(), every single line, then > correlate what > is > > said with the error message. > > > > > Maybe someone with ability greater or other than I, > should give some > > > serious consideration to a solution or work around. > > > > All the info you need is in the archives. > > > > > I've been using ColdFuion for 7 years and I can do a > > url="anotherlocation.htm"> anywhere in the page, no > matter if I've run > > > CFML, Javascript it still works. > > > > You can do that as well, again, all the info you need is in > the archives. > > > > > Sorry I'm just frustrated. > > > > I'm sure regulars on the list are just as frustrated at how > often this > > question crops up and at how little research people do before asking > another > > FAQ. > > > > -- > > Jason Wong -> Gremlins Associates -> www.gremlins.biz > > Open Source Software Systems Integrators > > * Web Design & Hosting * Internet & Intranet Applications > Development * > > -- > > Search the list archives before you post > > http://marc.theaimsgroup.com/?l=php-general > > -- > > /* > > Losing your drivers' license is just God's way of saying > "BOOGA, BOOGA!" > > */ > > -- > 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] Headers Again
Jason, I appreciate people get just as frustrate by reading repetative posts. Alliare and Macromedias forums for ColdFusion and other software, allow a search through the entire post, archive everything. Which always avoid this problem of a newsgroup. Maybe I'm wrong, but I don't thing there's a search like this for a newsgroup? If you do happen to know, as it would appear you may, the url of the answer to the original question, then could you simply supply it. I'm new to this code, I appreciate any assistance, and I will troll through archives etc to get it. However, if some kind sole can save me 3 hours work, I'll also appreciate it, which is probably why this list get repetative posts. Cheers, relax, and have a nice day. Col "Jason Wong" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Tuesday 17 February 2004 16:37, PETCOL wrote: > > What you're asking is a VERY FAQ. Something that's asked almost every other > day. The list archives will have plenty of answers. > > > What I shock, 307,000 entries returned. > > If you don't want to trawl through those search results then read the error > message again (carefully, all of it). If you still haven't figured it then > read the manual entry for header(), every single line, then correlate what is > said with the error message. > > > Maybe someone with ability greater or other than I, should give some > > serious consideration to a solution or work around. > > All the info you need is in the archives. > > > I've been using ColdFuion for 7 years and I can do a > url="anotherlocation.htm"> anywhere in the page, no matter if I've run > > CFML, Javascript it still works. > > You can do that as well, again, all the info you need is in the archives. > > > Sorry I'm just frustrated. > > I'm sure regulars on the list are just as frustrated at how often this > question crops up and at how little research people do before asking another > FAQ. > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.biz > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > -- > Search the list archives before you post > http://marc.theaimsgroup.com/?l=php-general > -- > /* > Losing your drivers' license is just God's way of saying "BOOGA, BOOGA!" > */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers Again
On Tuesday 17 February 2004 16:37, PETCOL wrote: What you're asking is a VERY FAQ. Something that's asked almost every other day. The list archives will have plenty of answers. > What I shock, 307,000 entries returned. If you don't want to trawl through those search results then read the error message again (carefully, all of it). If you still haven't figured it then read the manual entry for header(), every single line, then correlate what is said with the error message. > Maybe someone with ability greater or other than I, should give some > serious consideration to a solution or work around. All the info you need is in the archives. > I've been using ColdFuion for 7 years and I can do a url="anotherlocation.htm"> anywhere in the page, no matter if I've run > CFML, Javascript it still works. You can do that as well, again, all the info you need is in the archives. > Sorry I'm just frustrated. I'm sure regulars on the list are just as frustrated at how often this question crops up and at how little research people do before asking another FAQ. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Losing your drivers' license is just God's way of saying "BOOGA, BOOGA!" */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers Again
Jason, What I shock, 307,000 entries returned. Maybe someone with ability greater or other than I, should give some serious consideration to a solution or work around. I've been using ColdFuion for 7 years and I can do a anywhere in the page, no matter if I've run CFML, Javascript it still works. Sorry I'm just frustrated. Regards Col "Jason Wong" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Tuesday 17 February 2004 09:57, PETCOL wrote: > > > I have authenticated a user, after that I want to take them to another > > page: > > > > Header("Location: welcome.php"); > > > > But I get the following error? > > > > error > > Cannot modify header information - headers already sent > > error > > > > Suggestions? > > google? > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.biz > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > -- > Search the list archives before you post > http://marc.theaimsgroup.com/?l=php-general > -- > /* > I don't want to achieve immortality through my work. I want to achieve > immortality through not dying. > -- Woody Allen > */
Re: [PHP] Headers Again
On Tuesday 17 February 2004 09:57, PETCOL wrote: > I have authenticated a user, after that I want to take them to another > page: > > Header("Location: welcome.php"); > > But I get the following error? > > error > Cannot modify header information - headers already sent > error > > Suggestions? google? -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* I don't want to achieve immortality through my work. I want to achieve immortality through not dying. -- Woody Allen */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers Again
PETCOL wrote: Hi, I have authenticated a user, after that I want to take them to another page: Header("Location: welcome.php"); But I get the following error? error Cannot modify header information - headers already sent error Suggestions? Don't send output to the browser before you try to send headers(). -- By-Tor.com It's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers and sessions in php .cgi
> > I have a problem setting my headers right with php running as > > .cgi. I have to specify a Content-type for the cgi file to work. > > But how should I do both that and start a session? > > Try using header() instead of print to set Content-Type. > > Hope that helps. Thanks Chris. I tried that (see original post). Then I get a 500 error in my browser and bad header in error_log. Guess I'll have to take session_start() apart and see what it does. This all worked in 4.2, though, where I used .cgi files without a die-hard need for Content-type. As I said in a previous post, everything works when I run my program as a .php file without Content-type. So I guess there's a conflict between the Content-type header and those inserted by session_start() in 4.3.4. Thanks for any help, I'm on a bad deadline and my ISP changed PHP version without telling! -- Børge -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers and sessions in php .cgi
> >I have a problem setting my headers right with php running as .cgi. I > >have to specify a Content-type for the cgi file to work. But how > >should I do both that and start a session? > > > >I have a few options: > > > >#! /usr/local/bin/php > > >session_start(); > >print 'Content-type: text/html' . "\n\n"; > > > >This way $_SESSION['count'] stays unset even though I say > >$_SESSION['count'] = 1; in my program. > > > >To swap the two lines won't work because I heard \n\n terminates the > >header portion. Anyway, here goes: > > Stupid question: Have you tried Well, there's one thing I have found out here and that is that there's no such thing as a stupid question. I've tried searching for Content-type and session_start without getting any wiser :-( > header ('Content-type: text/html'); > > I'm pretty sure it will work. Tried it, didn't word I'm afraid. The text inside doesn't contain anything that's treated differently by " and '. -- Børge -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers and sessions in php .cgi
--- Børge Strand <[EMAIL PROTECTED]> wrote: > I have a problem setting my headers right with php running as > .cgi. I have to specify a Content-type for the cgi file to work. > But how should I do both that and start a session? Try using header() instead of print to set Content-Type. Hope that helps. Chris = Chris Shiflett - http://shiflett.org/ PHP Security Handbook Coming mid-2004 HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers and sessions in php .cgi
On Sat, 10 Jan 2004 17:44:18 +0100 (MET), you wrote: >I have a problem setting my headers right with php running as .cgi. I >have to specify a Content-type for the cgi file to work. But how >should I do both that and start a session? > >I have a few options: > >#! /usr/local/bin/php >session_start(); >print 'Content-type: text/html' . "\n\n"; > >This way $_SESSION['count'] stays unset even though I say >$_SESSION['count'] = 1; in my program. > >To swap the two lines won't work because I heard \n\n terminates the >header portion. Anyway, here goes: Stupid question: Have you tried header ('Content-type: text/html'); I'm pretty sure it will work. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Headers Problem
Yes, there was a blank line. Now I just have to test it to see if that was it. One other question though. It appears that Windows does not have this problem - the site in question is on a Linux box. Why would this be? The two sites are identical, I just use the Windows one for developing and testing. I have looked at both php.ini files, and other than the OS specific stuff, they are the same as well. Thanks again... -Original Message- From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] Sent: December 24, 2003 8:52 AM To: Beauford Cc: 'PHP' Subject: Re: [PHP] Headers Problem From: "Beauford" <[EMAIL PROTECTED]> > Just a clarification, session_start() is on the first line of restricted.inc > and restricted.inc is included on the first line of > update-corrections-input.php. All update-corrections-write.php does is write > info to a database and includes update-corrections-input.php on the > last line. So I'm still not understanding where the output from > update-corrections-write.php is coming from. Sounds like you have a blank line as the first line in update-corrections-write.php. If "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] Headers Problem
From: "Beauford" <[EMAIL PROTECTED]> > Just a clarification, session_start() is on the first line of restricted.inc > and restricted.inc is included on the first line of > update-corrections-input.php. All update-corrections-write.php does is write > info to a database and includes update-corrections-input.php on the last > line. So I'm still not understanding where the output from > update-corrections-write.php is coming from. Sounds like you have a blank line as the first line in update-corrections-write.php. If "http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Headers Problem
Beauford wrote: > I'm getting the following error. My question is, where would I use the > ob_start() and ob_end_flush() function so I can get rid of this. I > have read the PHP manual, but not quite getting it.Or if there is a better way? > Don't work around the problem with output buffering; try fixing it. > Warning: session_start() [function.session-start]: Cannot send session > cache limiter - headers already sent (output started at > /usr/local/apache/htdocs/supreme/updates/update-corrections-write.php: > 2) in /usr/local/apache/php/includes/restricted.inc on line 1 You must have session_start() before any output. You've placed it on line 1 of restricted.inc, but output was started on line 2 of update-corrections-write.php. If you're going to include restricted.inc and start a session, include it before there is output. Just a clarification, session_start() is on the first line of restricted.inc and restricted.inc is included on the first line of update-corrections-input.php. All update-corrections-write.php does is write info to a database and includes update-corrections-input.php on the last line. So I'm still not understanding where the output from update-corrections-write.php is coming from. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers Problem
Beauford wrote: I'm getting the following error. My question is, where would I use the ob_start() and ob_end_flush() function so I can get rid of this. I have read the PHP manual, but not quite getting it.Or if there is a better way? Don't work around the problem with output buffering; try fixing it. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /usr/local/apache/htdocs/supreme/updates/update-corrections-write.php:2) in /usr/local/apache/php/includes/restricted.inc on line 1 You must have session_start() before any output. You've placed it on line 1 of restricted.inc, but output was started on line 2 of update-corrections-write.php. If you're going to include restricted.inc and start a session, include it before there is output. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers Sent Message
Mark Roberts wrote: Could someone help me out with this. I had this problem about a year ago with another site and I can't for the life of me remember what I had to do to fix it. I am in a oscommerce application, however I think it is really a php problem. I get this message when ever I try to update the admin portion of the site: Warning: Cannot modify header information - headers already sent by (output started at /home/virtual/site1/fst/var/www/html/admin3/includes/application_top.php:267 ) in /home/virtual/site1/fst/var/www/html/admin3/includes/functions/general.php on line 18 You are lucky I have the files opened right now. The errors you report are only the last one, the first and main problem is that this line failed: include(DIR_WS_CLASSES . 'language.php'); // application_top.php:267 It generated a warning and the headers and then the html body was send. Basicly your main language file is missing. Marek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers Sent Message
--- Mark Roberts <[EMAIL PROTECTED]> wrote: > Warning: Cannot modify header information - headers already sent by > (output started at /home/virtual/site1/fst/var/www/html/admin3/includes/application_top.php:267 > ) in > /home/virtual/site1/fst/var/www/html/admin3/includes/functions/general.php > on line 18 Go to this script: application_top.php Look at line 267. Something is being output there, or perhaps there is something on that line that generates an error. In this script: general.php You are doing something that outputs a header on line 18, and the output from application_top.php happens prior to this, which cannot happen. Hope that helps. Chris = Chris Shiflett - http://shiflett.org/ PHP Security Handbook Coming mid-2004 HTTP Developer's Handbook http://httphandbook.org/ RAMP Training Courses http://www.nyphp.org/ramp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers Sent Message
From: "Mark Roberts" <[EMAIL PROTECTED]> > Could someone help me out with this. I had this problem about a year ago > with another site and I can't for the life of me remember what I had to do > to fix it. I am in a oscommerce application, however I think it is really a > php problem. I get this message when ever I try to update the admin portion > of the site: > > Warning: Cannot modify header information - headers already sent by (output > started at > /home/virtual/site1/fst/var/www/html/admin3/includes/application_top.php:267 > ) in > /home/virtual/site1/fst/var/www/html/admin3/includes/functions/general.php > on line 18 I always get yelled at for answering these questions and doing the whole "take my hand and follow along as we read this together"... but oh well... "output started at .../application_top.php:267" means that application_top.php has output on line 267. You cannot send any header information (header(), setcookie(), session_start(), etc) after there is output. "general.php" is trying to send header information on line 18, after application_top.php has been included and already caused output. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers, outputting a file ..
* Thus wrote Adam i Agnieszka Gasiorowski FNORD ([EMAIL PROTECTED]): > Wouter van Vliet wrote: > > > 110 $File = $this->Get($User); > > 111 > > 112 foreach($File['Headers'] as $H) header($H);; > > 113 readfile($File['Path']); > > Do I see TWO ; here or it's just a typo? That doesn't matter, he could have 30 there if he wanted. Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers, outputting a file ..
Wouter van Vliet wrote: > 110 $File = $this->Get($User); > 111 > 112 foreach($File['Headers'] as $H) header($H);; > 113 readfile($File['Path']); Do I see TWO ; here or it's just a typo? -- Seks, seksić, seksolatki... news:pl.soc.seks.moderowana http://hyperreal.info { iWanToDie } WiNoNa) ( http://szatanowskie-ladacznice.0-700.pl foReVeR( * ) Poznaj jej zwiewne kształty... http://www.opera.com 007 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] headers already sent and cookie problem
Hi Mike, hi all, I solved this nasty one! Happy. Your analysis is totally correct, Mike. Every visitor who puts an item in cart for the first time will get a cookie and... receives the error on his screen. And I, ... I didn't have this error message! What did it for me was: so , i just called the function and assigned it to a variable and... gone with the wind! Thanks again Mike! Regards Fred -Original Message- From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED] Sent: vrijdag 18 juli 2003 18:20 To: 'frederik feys '; '[EMAIL PROTECTED] ' Subject: RE: [PHP] headers already sent and cookie problem -Original Message- From: frederik feys To: 'Ford, Mike [LSS]'; [EMAIL PROTECTED] Here's the URL: http://www.aurelis.org/store/cart.txt and the get_cartID: http://www.aurelis.org/store/includes/functions/get_cartID.txt -- I've only had time for a quick look, but I think I have an inkling of where your problem might be. It all seems to lie with the way you've implemented GetCartId() -- and the problem will only show up any time the cartId cookie is not already set. Basically, if the cookie is not set, GetCartId() generates a new ID and sets the cookie -- but this requires sending a header, and you can't do this once you've started output of the real page. So you must make you first call to GetCartId() *before* you send any output. Now, if we look at this fragment of code from /store/cart.txt: function ShowCart($lang) { global $connection,$lang_dir,$DOCUMENT_ROOT,$page_theme,$country_iso_code,$srch _ter m; /* ob_start(); //start buffering output */ $page_title=get_label(194,$lang,$connection); $page_tab=3; include_once($DOCUMENT_ROOT . "/header_aurelis.php"); $country_iso_code = $_GET[country_iso_code]; if($lang=="EN"){ $currency_symbol = "$ "; } else{ $currency_symbol = "€ "; } $totalCost = 0; $show_cart = @mysql_query(("select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '" . GetCartId() . "' order by items.itemName asc"),$connection); ... we can see that you include header_aurelis.php, which presumably outputs the initial part of your HTML, before you do $show_cart = @mysql_query ... ; which includes a call to GetCartId() -- which will attempt to set the cartId cookie if it's not already set, and will fail with the "headers already sent" error. So, overall, I'd say you've got to get/set your cartId earlier in the game -- and certainly before you call or include anything that outputs actual page content. This analysis also explains why the error is intermittent -- someone who has set the cartId cookie once will probably not see the error again until after the cookie expires 30 days later! Hope this helps (and you followed my somewhat rambling explanation!) Cheers! Mike -- 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] headers already sent and cookie problem
-Original Message- From: frederik feys To: 'Ford, Mike [LSS]'; [EMAIL PROTECTED] Here's the URL: http://www.aurelis.org/store/cart.txt and the get_cartID: http://www.aurelis.org/store/includes/functions/get_cartID.txt -- I've only had time for a quick look, but I think I have an inkling of where your problem might be. It all seems to lie with the way you've implemented GetCartId() -- and the problem will only show up any time the cartId cookie is not already set. Basically, if the cookie is not set, GetCartId() generates a new ID and sets the cookie -- but this requires sending a header, and you can't do this once you've started output of the real page. So you must make you first call to GetCartId() *before* you send any output. Now, if we look at this fragment of code from /store/cart.txt: function ShowCart($lang) { global $connection,$lang_dir,$DOCUMENT_ROOT,$page_theme,$country_iso_code,$srch_ter m; /* ob_start(); //start buffering output */ $page_title=get_label(194,$lang,$connection); $page_tab=3; include_once($DOCUMENT_ROOT . "/header_aurelis.php"); $country_iso_code = $_GET[country_iso_code]; if($lang=="EN"){ $currency_symbol = "$ "; } else{ $currency_symbol = "€ "; } $totalCost = 0; $show_cart = @mysql_query(("select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '" . GetCartId() . "' order by items.itemName asc"),$connection); ... we can see that you include header_aurelis.php, which presumably outputs the initial part of your HTML, before you do $show_cart = @mysql_query ... ; which includes a call to GetCartId() -- which will attempt to set the cartId cookie if it's not already set, and will fail with the "headers already sent" error. So, overall, I'd say you've got to get/set your cartId earlier in the game -- and certainly before you call or include anything that outputs actual page content. This analysis also explains why the error is intermittent -- someone who has set the cartId cookie once will probably not see the error again until after the cookie expires 30 days later! Hope this helps (and you followed my somewhat rambling explanation!) Cheers! Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] headers already sent and cookie problem
Hi all, hi Mike, Here's the URL: http://www.aurelis.org/store/cart.txt and the get_cartID: http://www.aurelis.org/store/includes/functions/get_cartID.txt Thanks in advance! Fred -Original Message- From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED] Sent: woensdag 16 juli 2003 12:20 To: 'frederik feys'; [EMAIL PROTECTED] Subject: RE: [PHP] headers already sent and cookie problem > -Original Message- > From: frederik feys [mailto:[EMAIL PROTECTED] > Sent: 16 July 2003 10:21 > > One nasty thing to debug is that the error only shows up from time to > time. > So now everything seems OK. > > What do i have now? > I start my code with session_start > Then include some files. The last one is get_cartID.php (remember?) > Then i use several functions to have cart functionallity. > In show_cart i include my page heading and then output > further body and > footer content. > When I put the get_cartID include file AFTER include > "heading.php" into > my show cart function, the other functions start complaining > they can't > access the function get_cartID. > Lots of text, sorry for that. But I still don't have the clue. > Maybe you like to see my code? Yes, I think so -- I can't visualize enough of what's going on from your description to make further suggestions about what you might need to look at. >From the sound of it, your files are quite big, so the best thing would be if you can put them up (as .phps or .txt) on your Web server and post their URLs to the list. If you can't do that, attach them to an email as .txt files. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] headers already sent and cookie problem
> -Original Message- > From: frederik feys [mailto:[EMAIL PROTECTED] > Sent: 16 July 2003 10:21 > > One nasty thing to debug is that the error only shows up from time to > time. > So now everything seems OK. > > What do i have now? > I start my code with session_start > Then include some files. The last one is get_cartID.php (remember?) > Then i use several functions to have cart functionallity. > In show_cart i include my page heading and then output > further body and > footer content. > When I put the get_cartID include file AFTER include > "heading.php" into > my show cart function, the other functions start complaining > they can't > access the function get_cartID. > Lots of text, sorry for that. But I still don't have the clue. > Maybe you like to see my code? Yes, I think so -- I can't visualize enough of what's going on from your description to make further suggestions about what you might need to look at. >From the sound of it, your files are quite big, so the best thing would be if you can put them up (as .phps or .txt) on your Web server and post their URLs to the list. If you can't do that, attach them to an email as .txt files. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] headers already sent and cookie problem
Thanks for your tips Mike! One nasty thing to debug is that the error only shows up from time to time. So now everything seems OK. What do i have now? I start my code with session_start Then include some files. The last one is get_cartID.php (remember?) Then i use several functions to have cart functionallity. In show_cart i include my page heading and then output further body and footer content. When I put the get_cartID include file AFTER include "heading.php" into my show cart function, the other functions start complaining they can't access the function get_cartID. Lots of text, sorry for that. But I still don't have the clue. Maybe you like to see my code? Any help welcome! Fred -Original Message- From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED] Sent: dinsdag 15 juli 2003 11:36 To: 'frederik feys'; [EMAIL PROTECTED] Subject: RE: [PHP] headers already sent and cookie problem > -Original Message- > From: frederik feys [mailto:[EMAIL PROTECTED] > Sent: 15 July 2003 09:45 > > This is what i get: > "Warning: Cannot add header information - headers already > sent by (output started at /home/u/r/html/store/cart.php:188) > in /home/u/r/html/store/includes/functions/get_cartID.php on line 14" This says that on line 188 of store/cart.php you started outputting your HTML page, but you can't do that before the attempt to send headers on line 14 of store/includes/functions/get_cartID.php. Take a good look at line 188 of store/cart.php to see what you can do so that it is not starting HTML output, or move the header calls above the point where it is included/required. > I know that the problem is the reading of the cookie and then > after some sripting outputting page HTML. No, other way around. > I started my code > ob_start() > and do an ob_flush() within a function(show_cart) (?might > that be a problem?) Actually, that should be a preventer for the problem, so long as the ob_start() is executed before output is started -- perhaps your ob_start() should occur earlier in your script? Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] headers already sent and cookie problem
> -Original Message- > From: frederik feys [mailto:[EMAIL PROTECTED] > Sent: 15 July 2003 09:45 > > This is what i get: > "Warning: Cannot add header information - headers already > sent by (output started at /home/u/r/html/store/cart.php:188) > in /home/u/r/html/store/includes/functions/get_cartID.php on line 14" This says that on line 188 of store/cart.php you started outputting your HTML page, but you can't do that before the attempt to send headers on line 14 of store/includes/functions/get_cartID.php. Take a good look at line 188 of store/cart.php to see what you can do so that it is not starting HTML output, or move the header calls above the point where it is included/required. > I know that the problem is the reading of the cookie and then > after some sripting outputting page HTML. No, other way around. > I started my code > ob_start() > and do an ob_flush() within a function(show_cart) (?might > that be a problem?) Actually, that should be a preventer for the problem, so long as the ob_start() is executed before output is started -- perhaps your ob_start() should occur earlier in your script? Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] headers already sent and cookie problem
You cannot send any page information before you send headers (ie setting a cookie), that means there should be no html before the php that sets the cookie, also any function that are called before you set the cookie cannot output to the browser. Ry On 15/7/03 9:45 am, "frederik feys" <[EMAIL PROTECTED]> wrote: > Hi all, > > > > This is what i get: > > ³Warning: Cannot add header information - headers already sent by (output > started at /home/u/r/html/store/cart.php:188) in > /home/u/r/html/store/includes/functions/get_cartID.php on line 14² > > > > I know that the problem is the reading of the cookie and then after some > sripting outputting page HTML. > > > > I started my code > > ob_start() > > and do an ob_flush() within a function(show_cart) (?might that be a problem?) > > > > Can anyone shed some light on this? > > > > Thanks! > > Fred > > > > Ryan Gibson --- [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Headers in body - what am I doing wrong???
On Jun 12, 2003, "-{ Rene Brehmer }-" claimed that: |>You have an extra \r\n. There is one contained in the variable $from so the |>line $headers .= "From: ".$from."\r\n"; is putting \r\n\r\n which signifies |>the end of the headers and the begining of the message body. | |Stupid me ... so simple, of course ... thanks ... first thing to go is the |eyes... | |Rene Eyes are the THIRD thing to go. Second is memory. I can't remember the first thing to go, though. Jeff -- Registered Linux user #304026. "lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import" Key fingerprint = 52FC 20BD 025A 8C13 5FC6 68C6 9CF9 46C2 B089 0FED Responses to this message should conform to RFC 1855. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers in body - what am I doing wrong???
It's not future when I send them ... my clock's within the 15 second limit my NTP sync allows... but maybe the time difference causes ezmlm to do some dancing when sending it out ?? I know listserv based lists can get confused about the time differences... but thanks anyway ;-) Rene At 22:50 11-06-2003, Chris Hayes wrote: (darn, this one was already answered, i hate it that some people ask questions with a future time.) -- Rene Brehmer aka Metalbunny http://metalbunny.net/ References, tools, and other useful stuff... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Headers in body - what am I doing wrong???
At 22:31 11-06-2003, Jennifer Goodie wrote: >// pull fields from form query >$to = "[EMAIL PROTECTED]"; >$name = $HTTP_POST_VARS['name']; >$address = $HTTP_POST_VARS['address']; >$listname = $HTTP_POST_VARS['listname']; >$action = strtoupper($HTTP_POST_VARS['action']); > >// build headers >$from = "\"$name\" <$address>\r\n"; >$message = $action." ".$listname." ".$name."\r\n"; >$message .= "EXIT\r\n"; > >$headers = "MIME-Version: 1.0\r\n"; >$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; >$headers .= "From: ".$from."\r\n"; >$headers .= "Reply-to: ".$from."\r\n"; You have an extra \r\n. There is one contained in the variable $from so the line $headers .= "From: ".$from."\r\n"; is putting \r\n\r\n which signifies the end of the headers and the begining of the message body. Stupid me ... so simple, of course ... thanks ... first thing to go is the eyes... Rene -- Rene Brehmer aka Metalbunny http://metalbunny.net/ References, tools, and other useful stuff... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Headers in body - what am I doing wrong???
> > PS some mailservers do not like \r\n, check the manual on mail() and see > what they suggest, i think it was just \n. RFC for SMTP states that CRLF (\r\n) should be used. A lot of mail servers will accept just \n, but it is best to try and be standards compliant, you have less potential for problems when changing server set-ups. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers in body - what am I doing wrong???
(darn, this one was already answered, i hate it that some people ask questions with a future time.) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers in body - what am I doing wrong???
When using my yahoo account as test-target for this script, I get this in return from my Mercury server: == quote from error message == The mail server has encountered errors processing your request: * Unrecognized command "Reply-to:". From: "DeltaPower" <[EMAIL PROTECTED]> Reply-to: "DeltaPower" <[EMAIL PROTECTED]> Obviously, there's an extra line between the From and the Reply-to field, which is why Mercury thinks the reply-to is in the body. Mercury is made (or setup, not sure which) so that it will stop processing when it finds something it doesn't understand. I use the reply to field just as a safety measure ... Any ideas y'all ??? You are already pretty far in determining the problem. Indeed the border between the header and content of a mail is an empty line. What if i just give a hint? Look closely: $from = "\"$name\" <$address>\r\n"; $headers .= "From: ".$from."\r\n"; See ? Chris PS some mailservers do not like \r\n, check the manual on mail() and see what they suggest, i think it was just \n. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Headers in body - what am I doing wrong???
> >// pull fields from form query >$to = "[EMAIL PROTECTED]"; >$name = $HTTP_POST_VARS['name']; >$address = $HTTP_POST_VARS['address']; >$listname = $HTTP_POST_VARS['listname']; >$action = strtoupper($HTTP_POST_VARS['action']); > >// build headers >$from = "\"$name\" <$address>\r\n"; >$message = $action." ".$listname." ".$name."\r\n"; >$message .= "EXIT\r\n"; > >$headers = "MIME-Version: 1.0\r\n"; >$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; >$headers .= "From: ".$from."\r\n"; >$headers .= "Reply-to: ".$from."\r\n"; You have an extra \r\n. There is one contained in the variable $from so the line $headers .= "From: ".$from."\r\n"; is putting \r\n\r\n which signifies the end of the headers and the begining of the message body. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers bust ?
Malcom, Do your logic test before your input form. When you think of how a script is processed, on the server, then you'll see that the logic portion must precede any display portion. Juli Meloni has a good example of this structure in her custom error message example. You'll find it at www.thickbook.com Scripting often requires us to invert what we would see as the "normal" flow of eventsl Cheers - Miles Thompson At 09:01 AM 2/15/2003 -0500, Malcolm wrote: Hello, I've been fooling with this for a few days now. I'm getting a hearders already sent error. I know it means I've got output before the header but I can't figure how else to do this. The error messages; (output started at c:\foxy\www\project_db\switchtest.php:2) in c:\foxy\www\project_db\switchtest.php on line 11 The script; echo " This script uses a predefined list of names to switch"; echo" Input mal, jim or joe Your Name: "; switch ($dog) { case mal: header("location =../aamaillist/ml_menu.php"); break; case jim: echo ""; print " If you were jim you could have a private page here."; echo ""; break; case joe: echo ""; print "Hello Joe"; echo ""; break; default: print "You must be a stranger."; } ?> How can I redirect without output before the header ? -- 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] Headers bust ?
On Sat, 2003-02-15 at 09:01, Malcolm wrote: > Hello, > > I've been fooling with this for a few days now. > I'm getting a hearders already sent error. > I know it means I've got output before the header but > I can't figure how else to do this. Hi Malcom-- Looks like you are outputting data right after your script starts (on line to, you have an echo right away). You should either (a) turn on output buffering, which should take care of the problem, or (b) (the best solution because it makes your script behave the way it should) move things around so that the decision on the redirect is made before outputting anything. Try adding this at the beginning, before the echo: if ($dog == 'mal') header ('Location: ../aamaillist/ml_menu.php'); Hope this helps! Marco -- php|architect - The Monthly Magazine for PHP Professionals Come check us out on the web at http://www.phparch.com! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php headers already sent error.
http://www.php.net/manual/en/faq.using.php#faq.using.headers-sent Justin Garrett "Chris Winters" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Im SO CLOSE! > > Welll to start I had everything running FINE (MySQL, Apache, and PHP) until > I installed STUPID Zend Studio for PHP. After their 30 day trial expired, I > uninstalled it and everything just went downhill. > > After re installing everything, I have these errors left over. Now the code > is already on production server running (but with Linux). Im on a win2K box > (dont laugh)- BUT before it worked. > > I have no idea what this means since Im new to apache and PHP installs. > > Thanks for any help in for what to check > > Notice: Constant false already defined in c:\www\html\defines.php on line 4 > > Notice: Constant true already defined in c:\www\html\defines.php on line 5 > > Warning: Cannot add header information - headers already sent by (output > started at c:\www\html\defines.php:4) in c:\www\html\index.php on line 9 > > Warning: Cannot send session cookie - headers already sent by (output > started at c:\www\html\defines.php:4) in c:\www\html\index.php on line 89 > > Warning: Cannot send session cache limiter - headers already sent (output > started at c:\www\html\defines.php:4) in c:\www\html\index.php on line 89 > > Chris > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] headers and redirect
> I have a question about clearing or resetting headers. My script executes > a > function based on the variables passed to it, such as: > > events.php?action=add > > However, when the function is finished, I need to redirect to "events.php" > with no variables, because refreshing the page causes another event to be > added. I tried: > > header("Location: ./php/events.php"); > > But that did not reset the headers. Any tips? www.php.net/header the correct syntax is header("Location: http://www.yourdomain.com/php/events.php";); ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] headers and cookies
This is not correct. Both the setcookie() and header() functions manipulate the HTTP headers in the response. You cannot have output prior to any function that manipulates headers - that's the limitation. These two functions work fine together in any order; it's prior output that will cause an error. Chris Jay Blanchard wrote: Well, if you send headers first you cannot send cookies, if you send cookies first you cannot send headers. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php