php-general Digest 12 Jan 2009 14:00:39 -0000 Issue 5897
php-general Digest 12 Jan 2009 14:00:39 - Issue 5897 Topics (messages 286062 through 286084): Re: Couple of beginner questions 286062 by: John Corry 286063 by: Paul M Foster 286065 by: Peter Ford 286066 by: Peter Ford 286067 by: Nathan Rixham 286068 by: Nathan Rixham 286069 by: Nathan Rixham 286070 by: Nathan Rixham php_value error_log realtive path in 5.2.8 286064 by: Andre Hübner 286071 by: Nathan Rixham 286072 by: Nathan Rixham 286083 by: Nathan Rixham Re: RSS feeder in PHP5? 286073 by: Richard Heyes 286074 by: Richard Heyes 286075 by: clive 286076 by: Craig Whitmore 286077 by: Nathan Rixham 286078 by: Nathan Rixham 286079 by: Nathan Rixham 286080 by: Richard Heyes 286081 by: Nathan Rixham 286082 by: Richard Heyes 286084 by: Michelle Konzack Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- One of the best things that ever happened to me (with regards to writing PHP) was deciding not to embed it in HTML anymore. I either: a) generate the HTML from classes I've built (HTML, Forms, Tables, Images, etc) or use an equivalent PEAR class - or - b) Use Smarty templates...in which I still generate the HTML that will go to the template (where required) with the HTML generation classes. The advantages are abundant. I can't imagine having to maintain some of the code I saw in the examples above. My favorite WTF was with this snippet: $imgHTML = 'img src=' . $url . ' alt=' . $alt . ' title=' . $alt . ' class=' . $imgclass . ' /'; Holy crap...REALLY!? All that string concatenation and there's not even width/height attributes in there! That would look like: $i = new Image('path/to/image/file'); $i-__set(array('class'=$imgClass, 'alt' = $altText)); $i-toHtml(); Being able to change every image tag in a site by editing the class/method that created is just too big an advantage not to use. Not to mention the auto-generated width/height attributes, the ability to auto-produce thumbnails and fullsize images from a single file... After struggling through the beginnings, I wrote classes to generate basic HTML elements, then tables, then forms, then images. It saved me a bunch of time and taught me to see the website as an application...not as a web-page with pieces of data in it. Somehow, coming to that bit of knowledge was very helpful to my life as a programmer. Good luck, John Corry ---End Message--- ---BeginMessage--- On Mon, Jan 12, 2009 at 12:04:15AM -0500, John Corry wrote: One of the best things that ever happened to me (with regards to writing PHP) was deciding not to embed it in HTML anymore. I either: a) generate the HTML from classes I've built (HTML, Forms, Tables, Images, etc) or use an equivalent PEAR class - or - b) Use Smarty templates...in which I still generate the HTML that will go to the template (where required) with the HTML generation classes. The advantages are abundant. I can't imagine having to maintain some of the code I saw in the examples above. My favorite WTF was with this snippet: $imgHTML = 'img src=' . $url . ' alt=' . $alt . ' title=' . $alt . ' class=' . $imgclass . ' /'; Holy crap...REALLY!? All that string concatenation and there's not even width/height attributes in there! That would look like: $i = new Image('path/to/image/file'); $i-__set(array('class'=$imgClass, 'alt' = $altText)); $i-toHtml(); Being able to change every image tag in a site by editing the class/method that created is just too big an advantage not to use. Not to mention the auto-generated width/height attributes, the ability to auto-produce thumbnails and fullsize images from a single file... After struggling through the beginnings, I wrote classes to generate basic HTML elements, then tables, then forms, then images. It saved me a bunch of time and taught me to see the website as an application...not as a web-page with pieces of data in it. Somehow, coming to that bit of knowledge was very helpful to my life as a programmer. I've written a lot of code like the original example above, and still do, but I see your point, since I've written code like yours too. I write all my PHP code (and I write a *lot* of it) solo, with no help and no collaborators. But as I understand it from a lot of framework types, the ideal is to set up the HTML so that a HTML coder can understand what's going on, without having a lot of PHP weirdness in it. Meaning, if you're going to infuse your HTML with PHP, you should do it in a minimalistic way. It'd be a helluva lot easier
[PHP] php_value error_log realtive path in 5.2.8
Hi, please can someone try to add a logging with .htaccess and use a relative path to logfile? I always get an open_basedir error... open_basedir and document_root of domain points to: /path/path/ In /path/path/ is located the .htaccess with: php_flag log_errors on php_value error_log subpath/logfile.txt (logfile.txt is writeable) It just only works if path to logfile.txt is given absolut as /path/path/subpath/logfile.txt The relative path works reproducable in php 5.2.6 Please can somebody confirm this behavior? May be a kind of bug? This behavior seems to be new to me... Thanks, Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
Paul M Foster wrote: (snip) But here's a question for those of you who work in a collaborative environment-- are you really ever in a situation where some HTML weenie is coding HTML pages and you're somewhere else doing the PHP work? Or is that some academic's view of the way things *should* be done? Paul Yup, been there in a mid-sized web agency a few years ago, although with Java/JSP rather than PHP. The sensitive types drew the pretty pictures on their Macs, passed the design to the HTML hackers who broke the pretty pictures into sprawling arrays of table cells and image fragments, then passed the HTML to the Java teams (me and others) who had to slot in the logic without spoiling the pretty pictures. Then the sensitive types would see a pixel out of place and the HTML hackers would have to carefully navigate the logic sections and tweak the tables to make it look right again. It certainly focuses the mind about separating logic and presentation. In the end most of the JSP was done with JSP tag libraries, so that the HTML hackers were not too distracted by scary Java code. It actually all worked quite well, and produced some really beautiful web sites AND really elegant code libraries. But then the dot-com thing all fell over and it was too expensive for most people to pay for three teams and a couple of managers just to build a web shop... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
Paul M Foster wrote: But here's a question for those of you who work in a collaborative environment-- are you really ever in a situation where some HTML weenie is coding HTML pages and you're somewhere else doing the PHP work? Or is that some academic's view of the way things *should* be done? Paul yep very frequently, infact I'd say I only work in the display layer about 20% of the time now; if that. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
Peter Ford wrote: Paul M Foster wrote: (snip) But here's a question for those of you who work in a collaborative environment-- are you really ever in a situation where some HTML weenie is coding HTML pages and you're somewhere else doing the PHP work? Or is that some academic's view of the way things *should* be done? Paul Yup, been there in a mid-sized web agency a few years ago, although with Java/JSP rather than PHP. The sensitive types drew the pretty pictures on their Macs, passed the design to the HTML hackers who broke the pretty pictures into sprawling arrays of table cells and image fragments, then passed the HTML to the Java teams (me and others) who had to slot in the logic without spoiling the pretty pictures. Then the sensitive types would see a pixel out of place and the HTML hackers would have to carefully navigate the logic sections and tweak the tables to make it look right again. It certainly focuses the mind about separating logic and presentation. In the end most of the JSP was done with JSP tag libraries, so that the HTML hackers were not too distracted by scary Java code. It actually all worked quite well, and produced some really beautiful web sites AND really elegant code libraries. But then the dot-com thing all fell over and it was too expensive for most people to pay for three teams and a couple of managers just to build a web shop... think you've hit on something there; when I'm not coding in php I'm coding in java; which has a very strong focus on code seperation and using certain architectures / design patterns; it's hard not to cary this over to php and other languages once you've started doing it - as you say it leads to really beautiful web sites AND really elegant code libraries at the same time though there's the time/effort/cost factors and often it's not efficient or cost effective in any way to knock up a perfectly coded application for a small-mid sized site. Not that stops me trying / picking choosing the work which allows me the freedom to code properly ooh, worth noting that using flex as a front end almost by nature forces you to use an mvc/3-tier/n-tier architecture :) makes coding much more enjoyable. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php_value error_log realtive path in 5.2.8
Andre Hübner wrote: Hi, please can someone try to add a logging with .htaccess and use a relative path to logfile? I always get an open_basedir error... open_basedir and document_root of domain points to: /path/path/ In /path/path/ is located the .htaccess with: php_flag log_errors on php_value error_log subpath/logfile.txt (logfile.txt is writeable) It just only works if path to logfile.txt is given absolut as /path/path/subpath/logfile.txt The relative path works reproducable in php 5.2.6 Please can somebody confirm this behavior? May be a kind of bug? This behavior seems to be new to me... Thanks, Andre have you checked that you're php 5.2.8 is definately using the correct php.ini? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php_value error_log realtive path in 5.2.8
Andre Hübner wrote: - Original Message - From: Nathan Rixham nrix...@gmail.com To: Andre Hübner andre.hueb...@gmx.de Cc: php-general@lists.php.net Sent: Monday, January 12, 2009 11:19 AM Subject: Re: php_value error_log realtive path in 5.2.8 Andre Hübner wrote: Hi, please can someone try to add a logging with .htaccess and use a relative path to logfile? I always get an open_basedir error... open_basedir and document_root of domain points to: /path/path/ In /path/path/ is located the .htaccess with: php_flag log_errors on php_value error_log subpath/logfile.txt (logfile.txt is writeable) It just only works if path to logfile.txt is given absolut as /path/path/subpath/logfile.txt The relative path works reproducable in php 5.2.6 Please can somebody confirm this behavior? May be a kind of bug? This behavior seems to be new to me... Thanks, Andre have you checked that you're php 5.2.8 is definately using the correct php.ini? yes, my php.ini should not be the problem with php 5.2.6 i use the same version cause im my own packager. Thanks, Andre sorry going through the obvious ones - a: is the log file path ../subpath/logfile.txt b: what happens if you set it to ./subpath/logfile.txt c: check the values when you get_cfg_var() / ini_get() the values in question -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RSS feeder in PHP5?
Is there something in PHP5 which can generate the RSS feed? You don't need an extension to help you generate an XML feed. You dimply output XML data instead of HTML and send an appropriate content type header, eg: header('Content-Type: text/xml'); And the actual data: ?xml version=1.0 encoding=iso-8859-1? rss version=0.91 channel title!-- The title of your feed --/title link!-- The URL to your website --/link description !-- A summary of your feed -- /description item title!-- The title of your feed --/title link!-- The link to the article --/link pubDate!-- The data of the article --/pubDate description !-- The text of the article or a preview -- /description /item /channel /rss -- Richard Heyes HTML5 Graphing for Firefox, Chrome, Opera and Safari: http://www.rgraph.org (Updated January 4th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RSS feeder in PHP5?
item title!-- The title of your feed --/title Oops, that should be the title of the individual article. -- Richard Heyes HTML5 Graphing for Firefox, Chrome, Opera and Safari: http://www.rgraph.org (Updated January 4th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RSS feeder in PHP5?
Richard Heyes wrote: Is there something in PHP5 which can generate the RSS feed? You don't need an extension to help you generate an XML feed. You dimply output XML data instead of HTML and send an appropriate content type header, eg: header('Content-Type: text/xml'); I was just about to send something similar :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RSS feeder in PHP5?
On Mon, 2009-01-12 at 11:02 +, Richard Heyes wrote: Is there something in PHP5 which can generate the RSS feed? You don't need an extension to help you generate an XML feed. You dimply output XML data instead of HTML and send an appropriate content type header, eg: header('Content-Type: text/xml'); You actually mean application/xml not text/xml And its alot better to use DOMDocument in PHP5 for XML Creation rather than hardcode everything. Thanks And the actual data: ?xml version=1.0 encoding=iso-8859-1? rss version=0.91 channel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RSS feeder in PHP5?
Craig Whitmore wrote: On Mon, 2009-01-12 at 11:02 +, Richard Heyes wrote: Is there something in PHP5 which can generate the RSS feed? You don't need an extension to help you generate an XML feed. You dimply output XML data instead of HTML and send an appropriate content type header, eg: header('Content-Type: text/xml'); You actually mean application/xml not text/xml actually.. header(Content-type: application/rss+xml; charset=iso-8859-1) or header(Content-type: application/rss+xml; charset=utf-8) And its alot better to use DOMDocument in PHP5 for XML Creation rather than hardcode everything. agreed in principle; and I can't belive i'm saying this.. but with the case of a single rss feed in a single format then a tiny inline script which echo's out is far far lighter on the server and will do the trick; it's one of those set-up and leave scripts so DOMDocument may be overkill in this situation. here's an example / test code: ?php $rss_item_template = ' item titleRSS_TITLE/title linkRSS_LINK/link pubDateRSS_DATE/pubDate dc:creatormediatakeout/dc:creator category![CDATA[news]]/category guid isPermaLink=falseRSS_LINK/guid description![CDATA[RSS_DESCRIPTION]]/description content:encoded![CDATA[RSS_DESCRIPTION]]/content:encoded /item '; $rss_items = ''; $align = 'right'; if( $raw_items = $db-select(SELECT * FROM `news` LIMIT 0,20) ) { foreach($raw_items as $index = $item ) { $title = stripJunkSimple(stripslashes(htmlentities($item['title']))); $link = http://domain.com/;. $item['id']; //edit $date = date( 'r', $item['posting_date'] ); //edit $plain = str_replace(\n,'br /',stripslashes($item['body'])); $in = array('RSS_TITLE','RSS_LINK','RSS_DATE','RSS_DESCRIPTION'); $out = array( $title, $link, $date, $plain ); $rss_simple_item = str_replace( $in , $out , $rss_item_template ); $rss_items .= $rss_simple_item; } } $rss_template = '?xml version=1.0 encoding=iso-8859-1? rss version=2.0 xmlns:content=http://purl.org/rss/1.0/modules/content/; xmlns:wfw=http://wellformedweb.org/CommentAPI/; xmlns:dc=http://purl.org/dc/elements/1.1/; xmlns:atom=http://www.w3.org/2005/Atom; channel titleDomain.com RSS Feed/title atom:link href=http://' .'domain.com'. '/rss/ rel=self type=application/rss+xml / linkhttp://' .'domain.com'. '//link descriptionTop Stories on Domain.com/description pubDate' . date('r') . '/pubDate generatorhttp://' . 'domain.com' . '//generator languageen/language ' . $rss_items . ' /channel /rss'; header(Content-type: application/rss+xml; charset=iso-8859-1); echo $rss_template; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RSS feeder in PHP5?
Nathan Rixham wrote: here's an example / test code: $title = stripJunkSimple(stripslashes(htmlentities($item['title']))); there are a couple of custom functions in this script i forgot to pull out so stripJunkSimple can be removed and the db lookup replaced with you're own - just sample code but you should be aware incase of copy and pasting -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RSS feeder in PHP5?
header('Content-Type: text/xml'); You actually mean application/xml not text/xml Well, no. I use text/xml and have done for nearly 5 years, and it works fine. And its alot better to use DOMDocument in PHP5 for XML Creation rather than hardcode everything. DOMDocument would be overkill. -- Richard Heyes HTML5 Graphing for Firefox, Chrome, Opera and Safari: http://www.rgraph.org (Updated January 4th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RSS feeder in PHP5?
Richard Heyes wrote: header('Content-Type: text/xml'); You actually mean application/xml not text/xml Well, no. I use text/xml and have done for nearly 5 years, and it works fine. it does, but in 2006 it was upgraded to application/rss+xml for all rss versions; all the major readers and browsers recognise this and it's the first choice for rss autodiscovery; second up is application/xml, and finally for backwards compatibility text/xml. the new type was introduced as application/xml had some nuances with charector encoding definition and this is an integral part of an rss feed for it to be valid it's charset must match the content. http://www.rssboard.org/rss-mime-type-application.txt http://www.ietf.org/rfc/rfc3023.txt it's the same for xhtml pages: This document summarizes the best current practice for using various Internet media types for serving various XHTML Family documents. In summary http://www.w3.org/TR/xhtml-media-types/#summary, 'application/xhtml+xml' *SHOULD* be used for XHTML Family documents, and the use of 'text/html' *SHOULD* be limited to HTML-compatible XHTML 1.0 documents. 'application/xml' and 'text/xml' *MAY* also be used, but whenever appropriate, 'application/xhtml+xml' *SHOULD* be used rather than those generic XML media types. http://www.w3.org/TR/xhtml-media-types/ And its alot better to use DOMDocument in PHP5 for XML Creation rather than hardcode everything. DOMDocument would be overkill. yup -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RSS feeder in PHP5?
... Suppose I should change my feed then. At some point... :-) -- Richard Heyes HTML5 Graphing for Firefox, Chrome, Opera and Safari: http://www.rgraph.org (Updated January 4th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php_value error_log realtive path in 5.2.8
Andre Hübner wrote: - Original Message - From: Nathan Rixham nrix...@gmail.com To: Andre Hübner andre.hueb...@gmx.de Sent: Monday, January 12, 2009 12:18 PM Subject: Re: php_value error_log realtive path in 5.2.8 Andre Hübner wrote: - Original Message - From: Nathan Rixham nrix...@gmail.com To: Andre Hübner andre.hueb...@gmx.de; PHP-General php-general@lists.php.net Sent: Monday, January 12, 2009 11:43 AM Subject: Re: php_value error_log realtive path in 5.2.8 Andre Hübner wrote: - Original Message - From: Nathan Rixham nrix...@gmail.com To: Andre Hübner andre.hueb...@gmx.de Cc: php-general@lists.php.net Sent: Monday, January 12, 2009 11:19 AM Subject: Re: php_value error_log realtive path in 5.2.8 Andre Hübner wrote: Hi, please can someone try to add a logging with .htaccess and use a relative path to logfile? I always get an open_basedir error... open_basedir and document_root of domain points to: /path/path/ In /path/path/ is located the .htaccess with: php_flag log_errors on php_value error_log subpath/logfile.txt (logfile.txt is writeable) It just only works if path to logfile.txt is given absolut as /path/path/subpath/logfile.txt The relative path works reproducable in php 5.2.6 Please can somebody confirm this behavior? May be a kind of bug? This behavior seems to be new to me... Thanks, Andre have you checked that you're php 5.2.8 is definately using the correct php.ini? yes, my php.ini should not be the problem with php 5.2.6 i use the same version cause im my own packager. Thanks, Andre sorry going through the obvious ones - a: is the log file path ../subpath/logfile.txt b: what happens if you set it to ./subpath/logfile.txt c: check the values when you get_cfg_var() / ini_get() the values in question interesting... a/b. with ../subpath/logfile.txt ./subpath/logfile.txt and subpath/logfile.txt i get open_basedir restriction. c: the interesting part. if i use relative path in .htaccess the ini_get(error_log) is completly empty a value is only shown when used a absolut path, but in error_log i can see the path whcih is used in .htaccess strange case... what do you think? what about when you do a phpinfo().. whats the val under error_log local and master? +upgrading to 5.2.8 locally to see if i can replicate sorry, forget about CVE-2007-3378, is not changed in current version. my mistake, im sorry... you'll be perhaps glad to know that I've replicated it identically over here; PHP 5.2.8 on windows vista with apache 2.2.10 may be worth noting that if you add the lines to your vhosts.conf file instead under each vhost it works fine; however definately only absolute paths allowed in .htaccess when using open_basedir I'll post on internals for confirmation and get back to you regards, nath -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: RSS feeder in PHP5?
Hello Richard, Am 2009-01-12 11:02:39, schrieb Richard Heyes: Is there something in PHP5 which can generate the RSS feed? You don't need an extension to help you generate an XML feed. You dimply output XML data instead of HTML and send an appropriate content type header, eg: snip Thanks for the tip... If it is easy like this, I will go with it.. Thanks, Greetings and nice Day/Evening Michelle Konzack Systemadministrator 24V Electronic Engineer Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ # Debian GNU/Linux Consultant # http://www.tamay-dogan.net/ http://www.can4linux.org/ Michelle Konzack Apt. 917 ICQ #328449886 +49/177/935194750, rue de Soultz MSN LinuxMichi +33/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com) signature.pgp Description: Digital signature
Re: [PHP] Couple of beginner questions
At 3:36 PM + 1/11/09, Ashley Sheridan wrote: I was thinking more along the lines of this: [1] echo img src=\$url\ alt=\$alt\ title=\$alt\ class=\$imgclass \/; which looks like this otherwise: [2] img src=?php echo($url);? alt=?php echo($alt);? title=?php echo($alt);? class=?php echo($imgclass);?/ Ash: I see and understand what you are saying. To me, [2] is more understandable/preferable than [1]. To each their own. Cheers, 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
[PHP] Re: RSS feeder in PHP5?
Hello Nathan, Am 2009-01-12 11:25:57, schrieb Nathan Rixham: header(Content-type: application/rss+xml; charset=utf-8) OK And its alot better to use DOMDocument in PHP5 for XML Creation rather than hardcode everything. agreed in principle; and I can't belive i'm saying this.. but with the case of a single rss feed in a single format then a tiny inline script which echo's out is far far lighter on the server and will do the trick; it's one of those set-up and leave scripts so DOMDocument may be overkill in this situation. snip Right, it is only a singel RSS feed per VHost and always the same format where a simple echo is enough. Thanks, Greetings and nice Day/Evening Michelle Konzack Systemadministrator 24V Electronic Engineer Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ # Debian GNU/Linux Consultant # http://www.tamay-dogan.net/ http://www.can4linux.org/ Michelle Konzack Apt. 917 ICQ #328449886 +49/177/935194750, rue de Soultz MSN LinuxMichi +33/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com) signature.pgp Description: Digital signature
Re: [PHP] Re: redoing website after 7 years
On Sun, Jan 11, 2009 at 5:09 PM, Robert Cummings rob...@interjinn.com wrote: On Mon, 2009-01-12 at 09:00 +1100, Chris wrote: Robert Cummings wrote: On Fri, 2009-01-09 at 08:56 -0500, Andrew Ballard wrote: On Fri, Jan 9, 2009 at 2:09 AM, Robert Cummings rob...@interjinn.com wrote: On Fri, 2009-01-09 at 15:17 +1100, Chris wrote: I know many people will grin at me for this solution but may be faster way to overcome this problem to do a find for $ and replace with $_REQUEST. even this will help you if you dealt with $_POST, $_GET, $_COOKIE. Please don't. $connection = mysql_connect(...) becomes $_REQUEST[$connection] (or something) How did you get those braces when you did search and replace? ;) Cheers, Rob. Doesn't your search and replace tool support regular expression matching and replacement? Well yes, but the instrutions didn't indicate using a regex ;) I'd like to see you try it without a regex.. ;) I guess you could do it but php isn't going to parse it (or everything is going to be set to $_REQUEST).. The point of my original comment was that you didn't follow the instructions ;) Cheers, Rob. Ah, yes... instructions. But I find that project instructions are often like the DNA sequences in the movie Jurassic Park - nearly complete but lacking critical segments that require someone to fill in the gaps with whatever is lying around the shop that looks like it will fit. :-) Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RSS feeder in PHP5?
hope you're well today Well, I have a bit of runny nose, and as usual it's frickin' freezing (the joys of rat poison). But other than that fine thanks. You? -- Richard Heyes HTML5 Graphing for Firefox, Chrome, Opera and Safari: http://www.rgraph.org (Updated January 4th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
At 5:01 PM + 1/11/09, Nathan Rixham wrote: i love these discussions on pedantics and semantics! [and] keep the layers as seperate as possible That's the main topic of this thread. But you missed the point of the debate. I was claiming that one should not have any html within an echo, whereas Ash was showing difficulties in doing so. For example your: $imgHTML = 'img src=' . $url . ' alt=' . $alt . ' title=' . $alt . ' class=' . $imgclass . ' /'; If given the choice I would not practice. Instead, I would echo each variable out such as: img src=?php echo($url);? ... however; I only really do this when developing or in a quick bit of script; whenever possible I'll always use a templating engine, or xml/xsl which is the perfect abstraction between data and presentation IMHO. I've never used a template engine. Attempts at doing so resulted in frustration as to how the designers mixed php, css, and html. another little note is that I'd never echo out a class or presentation data; infact I'd never use a class on a tag such as img either, preference going to a bit of css using selectors div#article_content p img { /* whatever */ } I see absolutely nothing wrong with using: ?php $paragraph_class = 'paragraph_class'; ... ? p class=?php echo($paragraph_class) with the following in an attached css file. .paragraph_class { font-size: 1.1em; color: #ff; margin: .5em; } now I've limitted all presentation to css only, css contained in a stylesheet - Same here. However, I have changed the application of css style rules via php and javascript (DOM scripting). DOM scripting is an exciting and wonderful way to change html unobtrusively, but that's beyond this discussion. I try to use minimal css classes, and stick to using an id wherever I can't simply redefine the html tag. Id's are fine provided that you are not going to use more than one per page -- otherwise, class is a better choice. the above means that moving back to the original h1 example(s) I'd simply h1whatever/h1 css: h1 { color: rgb(255,0,0); font-size: 1.2em; } seeing as you can only have one h1 tag on a single document. No, that's not true. You can have as many h1 tags as you want in a single document -- they will all just look the same. However, if you use classes, then you can have as many h1 tags as you want looking the way you want them to look -- much more freedom. Additionally, there's more to consider here than just the way the document looks. To be holistic, one should consider not only how the document looks to people, but to bots. If h1 tags are considered important to SE bots, and you don't want h1 tags in your document, then you are sunk -- unless you style the h1 the way you want them to look. As an example, I have used bold tags for SEO concerns while showing the user no bold text. As I said, there's more here than just how a documents looks to a human visitor, but that is also beyond this discussion. Cheers, 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] Couple of beginner questions
$ mv hello-world.php hello-world.html Isn't this backwards?... :-) 39% seems awfully high overhead for what is essentially an extra readfile. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
At 12:25 PM -0500 1/11/09, Robert Cummings wrote: Although, to be honest I tend to vertically spread my tags/attributes: $imgHTML = 'img' .' src='.$url.'' .' alt='.$alt.'' .' title='.$alt.'' .' class='.$imgclass.'' .' /'; This makes it easy to see at a glance what is there and to also comment out lines easily. I vertically stack variables as well, such as in developing a long MySQl $query, but I don't include any html in my echo statements. That's just a private rule of mine that is sometimes broken by client needs. Cheers, 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] Couple of beginner questions
On Mon, Jan 12, 2009 at 10:16 AM, c...@l-i-e.com wrote: $ mv hello-world.php hello-world.html Isn't this backwards?... :-) 39% seems awfully high overhead for what is essentially an extra readfile. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Yea, but it's still the same file. I just copied the wrong line. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
On Sun, Jan 11, 2009 at 11:28:49PM -0800, Lars Torben Wilson wrote: 2009/1/11 Paul M Foster pa...@quillandmouse.com: snip But here's a question for those of you who work in a collaborative environment-- are you really ever in a situation where some HTML weenie is coding HTML pages and you're somewhere else doing the PHP work? Or is that some academic's view of the way things *should* be done? I'm in such a position now, and it's great. Mind you, as I said in another post in this thread, I have separated code and presentation for years and so I'm probably biased. ;) I can just think about code and let someone else handle the presentation. That doesn't mean that the weenies* don't have input into the code, or that I don't have input into the presentation, just that we don't have to focus on jobs that aren't ours. * - For the record, while I might have thought of the people doing the presentation as HTML weenies a few years ago, since then I've had to run a solo shop for a few years, have done layout for some CD releases, and so on--and I have gained respect for people with a truly good eye and the ability to translate that onto the screen. While I enjoy layout and presentation, it's not where my training is and I recognize superior talent when I see it. They have their strengths and I have mine and we do what we do best. As for HTML weenies, my experience has been the opposite. My company does websites, among other things. Most of my work involves our internal website, which runs the company. I do PHP and the HTML for the internal website. My wife does the design/HTML for customer websites. If a customer website needs PHP, I do it. I don't know how many times we've had to deal with outside web design types, and found their work to be atrocious. I also have a fair amount of contempt for people who refuse to learn anything outside their narrow field, which is what I see in a lot of HTML folks. I would have more respect for them if they took the time to understand at least something about PHP, and thus better understand what I have to deal with in their HTML. My wife doesn't know as much about HTML as I do, since she uses Dreamweaver to code HTML. But I code HTML by hand, and I don't have the patience to do fancy HTML the way she does. Consequently, the internal website is visually pleasing but not fancy. Customer websites are prettier than our internal one, but have almost no PHP in them. However, I've had many situations where my wife has designed a pretty page I have to now add PHP to. It's tricky. But as a consequence, I tend to code HTML without resorting to rendering classes. Even though it would be much easier to do it with classes. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] is_readable() returns 1 if file is still uploading
You should be able to fairly quickly fopen/fread/fseek/fread and compare the opening/ending XML tags. If it's well-formed XML, it should be trivial to detect an incomplete file versus a complete one. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Editing in a text area field
Google for BBCode. It's just str_replace(array('[b]','[/b]'),array('b','/b'),$text) in the end. And it's not really going to be any better than just letting them type b and /b if that is needed. Your sanitization process will be the same no matter what, and will have the same flaws/risks either way. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Editing in a text area field
On Mon, Jan 12, 2009 at 10:42 AM, c...@l-i-e.com wrote: Google for BBCode. It's just str_replace(array('[b]','[/b]'),array('b','/b'),$text) in the end. And it's not really going to be any better than just letting them type b and /b if that is needed. Your sanitization process will be the same no matter what, and will have the same flaws/risks either way. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Just to add to the discussion: http://kore-nordmann.de/blog/why_are_you_using_bbcodes.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RSS feeder in PHP5?
You actually mean application/xml not text/xml That depends on if you want the Userland RSS standard or the Other [blanking on name] RSS standard. Unfortunately, the RSS camps are still at war over syntax and required elements, and there are 9 mutually-incompatible often-used versions of the RSS standard over the years, with TWO current 2.0 standards You have to try to hit the lowest common denominator and test in many RSS clients/readers. PITA. Like early browser days, really... Sigh. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
are you really ever in a situation where some HTML weenie is coding HTML pages and you're somewhere else doing the PHP work? Yes. I have been there several times, and am there now. In a well-run organization with good communication and a decent framework, it works out well. Otherwise, it's quite bad, but probably not as bad as the total chaos of not trying to do it right at all. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
On Jan 12, 2009, at 1:43 AM, Paul M Foster wrote: On Mon, Jan 12, 2009 at 12:04:15AM -0500, John Corry wrote: But here's a question for those of you who work in a collaborative environment-- are you really ever in a situation where some HTML weenie is coding HTML pages and you're somewhere else doing the PHP work? Or is that some academic's view of the way things *should* be done? I haven't been involved strictly in the way that you mention. BUT... I have done work where someone else designs the page, and I code the HTML/PHP/MySQL/Rocks(tm)(Learning dead languages is tough though :P) Usually works quite well for me. -- Jason Pruim japr...@raoset.com 616.399.2355
[PHP] Php and CSS where to put it
I have this code and the css seems to not work in IE at all, do I need to put it somewhere different on the page maybe? link rel=stylesheet type=text/css href=inc/styles.css ?php include 'inc/dbconnOpen.php' ; ini_set('error_reporting', E_ALL); ini_set('display_errors', true); $sql = SELECT * FROM `textads` WHERE `expos` xCount ORDER BY RAND() LIMIT 3; $result = mysql_query($sql); echo table class=jobfont width=728 height=90 border=0 align=center cellpadding=10 bordercolor=#66 background= 'inc/bg.gif' bgcolor=#CC tr td table width=690 height=50 border=0 align=center cellpadding=5 tr; while ($row = mysql_fetch_array($result)) { echo td class=col align=center width=33%{$row['title']}br{$row['blurb']}br A HREF='{$row['href']}'{$row['href']}/a/td; //Add to exposure count $views = $row['xCount'] + 1; mysql_query(UPDATE `textads` SET `xCount` = '{$views}' WHERE `ID` = '{$row['ID']}'); } echo /tr /table/td/tr/table; ?
RE: [PHP] Re: Adding extension to an existing PHP install
I seem to recall reading something about Apache modules that you can do a configure, then make, but not the make install and just move the newly compiled module by hand. Is that possible with PHP? If so, where would the newly complied extension be, and where would it need to be moved? Thanks I always just do a phpinfo on the box I'm upgrading, grab the .configure line and re-use it adding in or changing what I need; that way it's sure to be the same? Hello list, I have a PHP (5.2.1) installation on an openSUSE 10.1 server. PHP was initially compiled from source and I have the original config.nice file, so I know what options were used. l need to add an extension to this running installation, specifically I need to add LDAP support. How is the best way to do this? I know I can recompile and reinstall, but I am worried that some extensions may have been added after the initial install and my new installation would overwrite those. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RSS feeder in PHP5?
On Mon, Jan 12, 2009 at 11:02 AM, c...@l-i-e.com wrote: You actually mean application/xml not text/xml That depends on if you want the Userland RSS standard or the Other [blanking on name] RSS standard. Unfortunately, the RSS camps are still at war over syntax and required elements, and there are 9 mutually-incompatible often-used versions of the RSS standard over the years, with TWO current 2.0 standards You have to try to hit the lowest common denominator and test in many RSS clients/readers. PITA. Like early browser days, really... Sigh. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php But I thought it was really simple? ;D -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] Couple of beginner questions
On Jan 12, 2009 11:20am, Jason Pruim japr...@raoset.com wrote: It's actually pretty normal and can work really well. Especially if the HTML person also did the graphic design and KNOWS how to make it work as a web page. We let them build HTML files, which are then turned into Smarty templates with the necessary blocks of Smarty code to work through whatever PHP hands to the template. The PHP app developer can then focus on the application logic...with the app's output going to the appropriate Smarty template. It's a pretty good system compared to the one person doing everything model that I worked under for a long time. Even a one person team can use that approach by separating the tasks and then maintaining discipline to work on the separate tasks, separately. John Corry On Jan 12, 2009, at 1:43 AM, Paul M Foster wrote: On Mon, Jan 12, 2009 at 12:04:15AM -0500, John Corry wrote: But here's a question for those of you who work in a collaborative environment-- are you really ever in a situation where some HTML weenie is coding HTML pages and you're somewhere else doing the PHP work? Or is that some academic's view of the way things *should* be done?
Re: [PHP] Couple of beginner questions
Ashley Sheridan wrote in message news:1231681793.3527.2.ca...@localhost.localdomain... On Sun, 2009-01-11 at 08:08 -0500, tedd wrote: At 4:16 PM -0500 1/10/09, Paul M Foster wrote: And let me present an alternative perspective. Never do something like: ?php echo 'Hellow world'; ? Let Apache (or whatever) interpret HTML as HTML, and don't make it interpret PHP code as HTML. Instead, do: h1Hello world/h1 If you're going to use PHP in the middle of a bunch of HTML, then only use it where it's needed: h1Hello ?php echo $name; ?/h1 The contents of the PHP $name variable can't be seen by the HTML, which is why you need to enclose it in a little PHP island. Naturally, if you're going to put PHP code in the middle of a HTML page, make the extension PHP. Otherwise, Apache will not interpret the PHP code as PHP (unless you do some messing with .htaccess or whatever). It's just simplest to call a file something.php if it has PHP in it. Paul -- Paul M. Foster Paul: I agree with you. My example was not well thought out. My point was not to mix style elements with data. I should have said: I would consider the followingbad practice: ?php echo(h1$whatever/h1); ? Whereas, the following I would consider good practice. h1?php echo($whatever); ?/h1 Thanks for keeping me honest. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com Unless it's something like this: ?php echo h1 class=\$headerClass\$whatever/h1; ? Which is unlikely for a header tag, but I know this sort of format gets used a lot by me and others, especially for setting alternate row styles on tables (damn browsers and not supporting alternate rows!) Ash www.ashleysheridan.co.uk Hey Ash...Why don't you just use CSS subclassing? style type=text/css h1.odd {class stuff here} h1.even {class stuff here} /style then h1 class=odd?php echo $whatever; ?/h1 no escaping, and no need to php your css styles. :) Frank -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Data trasfer between PHP pages
Hi, I have one form where user fills data using radio buttons. Only one answer goes from here to another page. FORM 1 form action=form2.php method=post input type=radio name=myname value=Answer 5 id=1 / label for=15/label br / input type=radio name=myname value=Answer 1 id=2 / label for=21/label br / input type=radio name=myname value=Answer 3 id=3 / label for=33/label br / input type=submit value=Enter / /form --- FORM 2 There is another page has a form with 14 fields PLUS I need the data of the previous form to be hidden somewhere in this form. Once this form is submitted I need to put the combined data into the database. I know this is so simple. But not sure why this is not working. I tried to use ?$_GET[myname] ? from the first form but its not working. My module page has to go live tomorrow morning, I am stuck, please help. Thanks, Chris -- View this message in context: http://www.nabble.com/Data-trasfer-between-PHP-pages-tp21418587p21418587.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Data trasfer between PHP pages
-Original Message- From: Chris Carter [mailto:chandan9sha...@yahoo.com] Sent: Monday, January 12, 2009 11:00 AM To: php-general@lists.php.net Subject: [PHP] Data trasfer between PHP pages Hi, I have one form where user fills data using radio buttons. Only one answer goes from here to another page. FORM 1 form action=form2.php method=post input type=radio name=myname value=Answer 5 id=1 / label for=15/label br / input type=radio name=myname value=Answer 1 id=2 / label for=21/label br / input type=radio name=myname value=Answer 3 id=3 / label for=33/label br / input type=submit value=Enter / /form --- FORM 2 There is another page has a form with 14 fields PLUS I need the data of the previous form to be hidden somewhere in this form. Once this form is submitted I need to put the combined data into the database. I know this is so simple. But not sure why this is not working. I tried to use ?$_GET[myname] ? from the first form but its not working. My module page has to go live tomorrow morning, I am stuck, please help. $_GET['var'] is used for GET-method data retrieval. You have specified POST-method data in your form. Try $_POST['myname'] and see if that doesn't grab the value you're looking for. HTH, // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php and CSS where to put it
Terion Miller wrote: I have this code and the css seems to not work in IE at all, do I need to put it somewhere different on the page maybe? link rel=stylesheet type=text/css href=inc/styles.css ?php include 'inc/dbconnOpen.php' ; I don't see the html headers. Nor a body. Get that fixed and see what happens. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php and CSS where to put it
-- link rel=stylesheet type=text/css href=inc/styles.css link rel=stylesheet type=text/css href=inc/styles.css should be placed in between head/head Thanks, V
Re: [PHP] Re: Adding extension to an existing PHP install
Tim Donnelly wrote: I seem to recall reading something about Apache modules that you can do a configure, then make, but not the make install and just move the newly compiled module by hand. Is that possible with PHP? If so, where would the newly complied extension be, and where would it need to be moved? Thanks I always just do a phpinfo on the box I'm upgrading, grab the .configure line and re-use it adding in or changing what I need; that way it's sure to be the same? Hello list, I have a PHP (5.2.1) installation on an openSUSE 10.1 server. PHP was initially compiled from source and I have the original config.nice file, so I know what options were used. l need to add an extension to this running installation, specifically I need to add LDAP support. How is the best way to do this? I know I can recompile and reinstall, but I am worried that some extensions may have been added after the initial install and my new installation would overwrite those. The binary should be in the dir where you ran make (I think) and you should put it in the dir specified in your php.ini for extensions. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Data trasfer between PHP pages
Hi, I have one form where user fills data using radio buttons. Only one answer goes from here to another page. FORM 1 form action=form2.php method=post input type=radio name=myname value=Answer 5 id=1 / label for=15/label br / input type=radio name=myname value=Answer 1 id=2 / label for=21/label br / input type=radio name=myname value=Answer 3 id=3 / label for=33/label br / input type=submit value=Enter / /form --- FORM 2 There is another page has a form with 14 fields PLUS I need the data of the previous form to be hidden somewhere in this form. Once this form is submitted I need to put the combined data into the database. I know this is so simple. But not sure why this is not working. I tried to use ?$_GET[myname] ? from the first form but its not working. My module page has to go live tomorrow morning, I am stuck, please help. Thanks, Chris The submission method you are using on the first page says, form action=form2.php method=post Since your methodis post you need to use $variable = $_POST[' '] instead of $_GET[' '] That will give you the value from your previous page and then you can just do: input type=hidden name=myname value=?php echo $variable; ? And that will assign your posted value to a hidden field like you wanted.
[PHP] RewriteRules
Hi Everyone, I know it's not a php question... But I know alot of you use rewrite rules and regular expressions and so I thought maybe you would be able to help me. The site: HTTP://purl.raoset.com/test112 test112 doesn't exist.. It's driven by the database using this rewrite rule: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /p.php [L] Now, on that site I have a few links... right now the likes are in the format of: HTTP://purl.raoset.com/design.php?purl=test112 What I would like is to have it read: HTTP://purl.raoset.com/test112/design completing the total look of the site :) I tried to modify this rewrite rule I found on the web: RewriteRule ^(.+)\.pdf$ /cgi-bin/pdf-script.php?file=$1.pdf [L,NC,QSA] But no joy... What I had was: RewriteRule ^design /design.php?purl=$1 [L] Any pointers? I'm still trying to grasp the regex ideas and get used to that and I think that may be what my main issue is right now. Any one who can figure it out has a beverage of their choice waiting for them as long as they come to where I am! :) -- Jason Pruim japr...@raoset.com 616.399.2355
Re: [PHP] Data trasfer between PHP pages
If the 2 forms exist on the same server. Use Sessions. thats would solve lot of problems managing hidden fields and everything. Thanks, V
Re: [PHP] Data trasfer between PHP pages
At 8:59 AM -0800 1/12/09, Chris Carter wrote: Hi, I have one form where user fills data using radio buttons. Only one answer goes from here to another page. FORM 1 form action=form2.php method=post input type=radio name=myname value=Answer 5 id=1 / label for=15/label br / input type=radio name=myname value=Answer 1 id=2 / label for=21/label br / input type=radio name=myname value=Answer 3 id=3 / label for=33/label br / input type=submit value=Enter / /form --- FORM 2 There is another page has a form with 14 fields PLUS I need the data of the previous form to be hidden somewhere in this form. Once this form is submitted I need to put the combined data into the database. I know this is so simple. But not sure why this is not working. I tried to use ?$_GET[myname] ? from the first form but its not working. My module page has to go live tomorrow morning, I am stuck, please help. Thanks, Chris Arr. Sometimes I wonder. You use a POST form and a GET to read the form -- do you see anything wrong with that? Cheers, 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] RewriteRules
On Mon, 2009-01-12 at 13:20 -0500, Jason Pruim wrote: Hi Everyone, I know it's not a php question... But I know alot of you use rewrite rules and regular expressions and so I thought maybe you would be able to help me. The site: HTTP://purl.raoset.com/test112 test112 doesn't exist.. It's driven by the database using this rewrite rule: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /p.php [L] Now, on that site I have a few links... right now the likes are in the format of: HTTP://purl.raoset.com/design.php?purl=test112 What I would like is to have it read: HTTP://purl.raoset.com/test112/design completing the total look of the site :) I tried to modify this rewrite rule I found on the web: RewriteRule ^(.+)\.pdf$ /cgi-bin/pdf-script.php?file=$1.pdf [L,NC,QSA] But no joy... What I had was: RewriteRule ^design /design.php?purl=$1 [L] $1 refers to a captured part of the matched string. To capture you need to place parenthesis around the the portion of the regular expression that you want to capture. So you need something like: RewriteRule ^([^/]+)/([^/]+)$ /$2.php?purl=$1 [L] You need two captures because you have the first path fragment as the parameter value and the second apth fragment as the page name. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Data trasfer between PHP pages
On Mon, 2009-01-12 at 13:37 -0500, tedd wrote: At 8:59 AM -0800 1/12/09, Chris Carter wrote: Hi, I have one form where user fills data using radio buttons. Only one answer goes from here to another page. FORM 1 form action=form2.php method=post input type=radio name=myname value=Answer 5 id=1 / label for=15/label br / input type=radio name=myname value=Answer 1 id=2 / label for=21/label br / input type=radio name=myname value=Answer 3 id=3 / label for=33/label br / input type=submit value=Enter / /form --- FORM 2 There is another page has a form with 14 fields PLUS I need the data of the previous form to be hidden somewhere in this form. Once this form is submitted I need to put the combined data into the database. I know this is so simple. But not sure why this is not working. I tried to use ?$_GET[myname] ? from the first form but its not working. My module page has to go live tomorrow morning, I am stuck, please help. Thanks, Chris Arr. Sometimes I wonder. Sometimes it's the little things and a fresh pair of eyes make all the difference. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RewriteRules
Jason Pruim schrieb: Now, on that site I have a few links... right now the likes are in the format of: HTTP://purl.raoset.com/design.php?purl=test112 What I would like is to have it read: HTTP://purl.raoset.com/test112/design Try the following rule (dunno, if it works for you, but you should get the idea): RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$ /$2.php?purl=$1 /Marc -- http://bithub.net/ Synchronize and share your files over the web for free -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Php and CSS where to put it
Hello Terion, Am 2009-01-12 10:42:10, schrieb Terion Miller: I have this code and the css seems to not work in IE at all, do I need to put it somewhere different on the page maybe? The CSS must be in the HTML Header like html head titleCSS Example/title link rel=stylesheet type=text/css href=inc/styles.css style type=text/css #body { background-color: magenta; } /style /head body ...rest of the page link rel=stylesheet type=text/css href=inc/styles.css ?php include 'inc/dbconnOpen.php' ; ini_set('error_reporting', E_ALL); ini_set('display_errors', true); $sql = SELECT * FROM `textads` WHERE `expos` xCount ORDER BY RAND() LIMIT 3; $result = mysql_query($sql); echo table class=jobfont width=728 height=90 border=0 align=center cellpadding=10 bordercolor=#66 background= 'inc/bg.gif' bgcolor=#CC according to W3C any values must be quoted like: echo table class=\jobfont\ width=\728\ height=\90\ border=\0\ align=\center\ cellpadding=\10\ bordercolor=\#66\ background= \inc/bg.gif\ bgcolor=\#CC\ Do not forget to ESCAPE! And of course, I would put the stuff into the CSS definition and not into the TABLE tag. tr td table width=690 height=50 border=0 align=center cellpadding=5 QUOT the values! tr; while ($row = mysql_fetch_array($result)) { echo td class=col align=center width=33%{$row['title']}br{$row['blurb']}br A HREF='{$row['href']}'{$row['href']}/a/td; //Add to exposure count $views = $row['xCount'] + 1; mysql_query(UPDATE `textads` SET `xCount` = '{$views}' WHERE `ID` = '{$row['ID']}'); } echo /tr /table/td/tr/table; ? Your HTML page has to be closed with: /body /html Thanks, Greetings and nice Day/Evening Michelle Konzack Systemadministrator 24V Electronic Engineer Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ # Debian GNU/Linux Consultant # http://www.tamay-dogan.net/ http://www.can4linux.org/ Michelle Konzack Apt. 917 ICQ #328449886 +49/177/935194750, rue de Soultz MSN LinuxMichi +33/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com) signature.pgp Description: Digital signature
Re: [PHP] Re: Php and CSS where to put it
Resolved! Thanks! On Mon, Jan 12, 2009 at 12:38 PM, Michelle Konzack linux4miche...@tamay-dogan.net wrote: Hello Terion, Am 2009-01-12 10:42:10, schrieb Terion Miller: I have this code and the css seems to not work in IE at all, do I need to put it somewhere different on the page maybe? The CSS must be in the HTML Header like html head titleCSS Example/title link rel=stylesheet type=text/css href=inc/styles.css style type=text/css #body { background-color: magenta; } /style /head body ...rest of the page link rel=stylesheet type=text/css href=inc/styles.css ?php include 'inc/dbconnOpen.php' ; ini_set('error_reporting', E_ALL); ini_set('display_errors', true); $sql = SELECT * FROM `textads` WHERE `expos` xCount ORDER BY RAND() LIMIT 3; $result = mysql_query($sql); echo table class=jobfont width=728 height=90 border=0 align=center cellpadding=10 bordercolor=#66 background= 'inc/bg.gif' bgcolor=#CC according to W3C any values must be quoted like: echo table class=\jobfont\ width=\728\ height=\90\ border=\0\ align=\center\ cellpadding=\10\ bordercolor=\#66\ background= \inc/bg.gif\ bgcolor=\#CC\ Do not forget to ESCAPE! And of course, I would put the stuff into the CSS definition and not into the TABLE tag. tr td table width=690 height=50 border=0 align=center cellpadding=5 QUOT the values! tr; while ($row = mysql_fetch_array($result)) { echo td class=col align=center width=33%{$row['title']}br{$row['blurb']}br A HREF='{$row['href']}'{$row['href']}/a/td; //Add to exposure count $views = $row['xCount'] + 1; mysql_query(UPDATE `textads` SET `xCount` = '{$views}' WHERE `ID` = '{$row['ID']}'); } echo /tr /table/td/tr/table; ? Your HTML page has to be closed with: /body /html Thanks, Greetings and nice Day/Evening Michelle Konzack Systemadministrator 24V Electronic Engineer Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ # Debian GNU/Linux Consultant # http://www.tamay-dogan.net/ http://www.can4linux.org/ Michelle Konzack Apt. 917 ICQ #328449886 +49/177/935194750, rue de Soultz MSN LinuxMichi +33/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)
Re: [PHP] RSS feeder in PHP5?
Unfortunately, the RSS camps are still at war over syntax and required elements, and there are 9 mutually-incompatible often-used versions of the RSS standard over the years, with TWO current 2.0 standards You have to try to hit the lowest common denominator and test in many RSS clients/readers. RSS 0.92? That's what I've always used. -- Richard Heyes HTML5 Graphing for Firefox, Chrome, Opera and Safari: http://www.rgraph.org (Updated January 4th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] downloading xls files corrupts them
I am using php to download xls files on my server. When I download them, excel is saying they are corrupted. They are not corrupted on the server itself. These are simple xls spreadsheets with no formatting in them. Here is the headers that I am using for the download. This is happening in both IE and Firefox. header(Pragma: public); header(Expires: 0); header(Cache-Control: must-revalidate, post-check=0, pre-check=0); header(Content-Type: application/force-download); header(Content-Type: application/octet-stream); header(Content-Type: application/download); header(Content-Disposition: attachment; filename=.basename(./bidDocs/.$myFile).;); header(Content-Transfer-Encoding: binary); header(Content-Length: .filesize(./bidDocs/.$myFile)); readfile(./bidDocs/.$myFile); Anyone have any suggestions? MLGW now offers ONLINE BILLING! To view your bills, receive paperless bills, check payment status and pay online, go to www.mlgw.com and click on the My Account link. Enroll today! This e-mail and any attachments represent the views and opinions of only the sender and are not necessarily those of Memphis Light, Gas Water Division, and no such inference should be made. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: RewriteRules
Jason Pruim wrote: Hi Everyone, I know it's not a php question... But I know alot of you use rewrite rules and regular expressions and so I thought maybe you would be able to help me. The site: HTTP://purl.raoset.com/test112 test112 doesn't exist.. It's driven by the database using this rewrite rule: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /p.php [L] Now, on that site I have a few links... right now the likes are in the format of: HTTP://purl.raoset.com/design.php?purl=test112 What I would like is to have it read: HTTP://purl.raoset.com/test112/design completing the total look of the site :) technically the same code as above should work even if you change you're links.. you see it's just redirecting everything not found to p.php so in p.php simply add in a print_r($_SERVER); exit(); at the top, upload to server then visit /test112/design in you're browser.. check the print_r output and you'll see the request in there, (variables sometimes differ, hence why I'm suggesting you check; you can skip this bit and jump right on to the next paragraph though) you can then simply: $request_page_parts = explode('/', $_SERVER['REQUEST_URI'); print_r($request_page_parts); then use whatever code you want to display the correct page based on the uri requested (as you want) I know this isn't the approach you expected but it basically hands off all page selection and processing to php, rather than a load of rewrite rules and lots of updating of .htaccess if you really want the rewrite rules then I'm sure you've had many other accurate replies with examples :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: downloading xls files corrupts them
Chris Ditty wrote: I am using php to download xls files on my server. When I download them, excel is saying they are corrupted. They are not corrupted on the server itself. These are simple xls spreadsheets with no formatting in them. Here is the headers that I am using for the download. This is happening in both IE and Firefox. header(Pragma: public); header(Expires: 0); header(Cache-Control: must-revalidate, post-check=0, pre-check=0); header(Content-Type: application/force-download); header(Content-Type: application/octet-stream); header(Content-Type: application/download); header(Content-Disposition: attachment; filename=.basename(./bidDocs/.$myFile).;); header(Content-Transfer-Encoding: binary); header(Content-Length: .filesize(./bidDocs/.$myFile)); readfile(./bidDocs/.$myFile); Anyone have any suggestions? MLGW now offers ONLINE BILLING! To view your bills, receive paperless bills, check payment status and pay online, go to www.mlgw.com and click on the My Account link. Enroll today! This e-mail and any attachments represent the views and opinions of only the sender and are not necessarily those of Memphis Light, Gas Water Division, and no such inference should be made. try removing: header(Content-Transfer-Encoding: binary); and see if it works -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Holy crap
Chrome 2.0? http://www.trustedreviews.com/software/news/2009/01/12/Google-Chrome-Hitting-Macs--Linux-By-July/p1 So much for long beta periods! -- Richard Heyes HTML5 Graphing for Firefox, Chrome, Opera and Safari: http://www.rgraph.org (Updated January 4th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] downloading xls files corrupts them
For starters, three calls to header(Content-type: ); is just plain silly :-) Read this for sure: http://php.net/header You may find this interesting, or not, to pick the right Content-type http://richardlynch.blogspot.com/2006/06/php-downloads-content-disposition.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Holy crap
On Mon, 2009-01-12 at 19:27 +, Richard Heyes wrote: Chrome 2.0? http://www.trustedreviews.com/software/news/2009/01/12/Google-Chrome-Hitting-Macs--Linux-By-July/p1 So much for long beta periods! 2.0 is the new beta... what did you think Web 2.0 was all about? Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: downloading xls files corrupts them
Chris Ditty wrote: I am using php to download xls files on my server. When I download them, excel is saying they are corrupted. They are not corrupted on the server itself. These are simple xls spreadsheets with no formatting in them. Here is the headers that I am using for the download. This is happening in both IE and Firefox. header(Pragma: public); header(Expires: 0); header(Cache-Control: must-revalidate, post-check=0, pre-check=0); header(Content-Type: application/force-download); header(Content-Type: application/octet-stream); header(Content-Type: application/download); header(Content-Disposition: attachment; filename=.basename(./bidDocs/.$myFile).;); header(Content-Transfer-Encoding: binary); header(Content-Length: .filesize(./bidDocs/.$myFile)); readfile(./bidDocs/.$myFile); Anyone have any suggestions? actually.. why not simply redirect them to the file? also here's an alternative $file = ./bidDocs/.$myFile; if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; } if it works don't thank me thank http://php.net/readfile :p -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
On Mon, 2009-01-12 at 11:20 -0500, Jason Pruim wrote: On Jan 12, 2009, at 1:43 AM, Paul M Foster wrote: On Mon, Jan 12, 2009 at 12:04:15AM -0500, John Corry wrote: But here's a question for those of you who work in a collaborative environment-- are you really ever in a situation where some HTML weenie is coding HTML pages and you're somewhere else doing the PHP work? Or is that some academic's view of the way things *should* be done? I haven't been involved strictly in the way that you mention. BUT... I have done work where someone else designs the page, and I code the HTML/PHP/MySQL/Rocks(tm)(Learning dead languages is tough though :P) Usually works quite well for me. -- Jason Pruim japr...@raoset.com 616.399.2355 I tend to work on projects on my own. I built the CMS that runs the current website, and now building it's sibling to run all the company sites under one roof. I just get given the design, then I go from there doing all the HTML, Javascript, CSS, PHP and MySQL from there. I have the advantage in that when I need to update the code, I know exactly how I've done it, but I have the disadvantage in that I don't know if what I'm doing is meeting a decent standard by other peoples opinion. I do try more and more to logically separate function from form, and the only time I deviate from that in the main is with heredocs, which I don't count as a sin I'll be sent to hell for ;) Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
On Mon, 2009-01-12 at 11:51 -0500, Frank Stanovcak wrote: Ashley Sheridan wrote in message news:1231681793.3527.2.ca...@localhost.localdomain... On Sun, 2009-01-11 at 08:08 -0500, tedd wrote: At 4:16 PM -0500 1/10/09, Paul M Foster wrote: And let me present an alternative perspective. Never do something like: ?php echo 'Hellow world'; ? Let Apache (or whatever) interpret HTML as HTML, and don't make it interpret PHP code as HTML. Instead, do: h1Hello world/h1 If you're going to use PHP in the middle of a bunch of HTML, then only use it where it's needed: h1Hello ?php echo $name; ?/h1 The contents of the PHP $name variable can't be seen by the HTML, which is why you need to enclose it in a little PHP island. Naturally, if you're going to put PHP code in the middle of a HTML page, make the extension PHP. Otherwise, Apache will not interpret the PHP code as PHP (unless you do some messing with .htaccess or whatever). It's just simplest to call a file something.php if it has PHP in it. Paul -- Paul M. Foster Paul: I agree with you. My example was not well thought out. My point was not to mix style elements with data. I should have said: I would consider the followingbad practice: ?php echo(h1$whatever/h1); ? Whereas, the following I would consider good practice. h1?php echo($whatever); ?/h1 Thanks for keeping me honest. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com Unless it's something like this: ?php echo h1 class=\$headerClass\$whatever/h1; ? Which is unlikely for a header tag, but I know this sort of format gets used a lot by me and others, especially for setting alternate row styles on tables (damn browsers and not supporting alternate rows!) Ash www.ashleysheridan.co.uk Hey Ash...Why don't you just use CSS subclassing? style type=text/css h1.odd {class stuff here} h1.even {class stuff here} /style then h1 class=odd?php echo $whatever; ?/h1 no escaping, and no need to php your css styles. :) Frank That's what I do do, but the 'odd' has to come from PHP, as unfortunately, numerical selectors in CSS aren't supported by (AFAIK) any browsers at the moment. So for example, if I was coding for alternate rows in a table, I might do: for($i=0; $i$some_limit; $i++) { $rowClass = ($i % 2 == 0)?'':'class=alternate'; print EOP tr $rowClass td.../td td.../td td.../td /tr EOP; } As far as such loops go, is this a particular faux pas in regards to the way it's coded? Go on Tedd ;) Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
Ashley Sheridan wrote: On Mon, 2009-01-12 at 11:51 -0500, Frank Stanovcak wrote: Ashley Sheridan wrote in message news:1231681793.3527.2.ca...@localhost.localdomain... On Sun, 2009-01-11 at 08:08 -0500, tedd wrote: At 4:16 PM -0500 1/10/09, Paul M Foster wrote: And let me present an alternative perspective. Never do something like: ?php echo 'Hellow world'; ? Let Apache (or whatever) interpret HTML as HTML, and don't make it interpret PHP code as HTML. Instead, do: h1Hello world/h1 If you're going to use PHP in the middle of a bunch of HTML, then only use it where it's needed: h1Hello ?php echo $name; ?/h1 The contents of the PHP $name variable can't be seen by the HTML, which is why you need to enclose it in a little PHP island. Naturally, if you're going to put PHP code in the middle of a HTML page, make the extension PHP. Otherwise, Apache will not interpret the PHP code as PHP (unless you do some messing with .htaccess or whatever). It's just simplest to call a file something.php if it has PHP in it. Paul -- Paul M. Foster Paul: I agree with you. My example was not well thought out. My point was not to mix style elements with data. I should have said: I would consider the followingbad practice: ?php echo(h1$whatever/h1); ? Whereas, the following I would consider good practice. h1?php echo($whatever); ?/h1 Thanks for keeping me honest. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com Unless it's something like this: ?php echo h1 class=\$headerClass\$whatever/h1; ? Which is unlikely for a header tag, but I know this sort of format gets used a lot by me and others, especially for setting alternate row styles on tables (damn browsers and not supporting alternate rows!) Ash www.ashleysheridan.co.uk Hey Ash...Why don't you just use CSS subclassing? style type=text/css h1.odd {class stuff here} h1.even {class stuff here} /style then h1 class=odd?php echo $whatever; ?/h1 no escaping, and no need to php your css styles. :) Frank That's what I do do, but the 'odd' has to come from PHP, as unfortunately, numerical selectors in CSS aren't supported by (AFAIK) any browsers at the moment. So for example, if I was coding for alternate rows in a table, I might do: for($i=0; $i$some_limit; $i++) { $rowClass = ($i % 2 == 0)?'':'class=alternate'; print EOP tr $rowClass td.../td td.../td td.../td /tr EOP; } As far as such loops go, is this a particular faux pas in regards to the way it's coded? Go on Tedd ;) Ash www.ashleysheridan.co.uk nice pick-up on the fact you only need to css the alternate row not both odd and even :p -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Data trasfer between PHP pages
On Mon, 2009-01-12 at 13:40 -0500, Robert Cummings wrote: On Mon, 2009-01-12 at 13:37 -0500, tedd wrote: At 8:59 AM -0800 1/12/09, Chris Carter wrote: Hi, I have one form where user fills data using radio buttons. Only one answer goes from here to another page. FORM 1 form action=form2.php method=post input type=radio name=myname value=Answer 5 id=1 / label for=15/label br / input type=radio name=myname value=Answer 1 id=2 / label for=21/label br / input type=radio name=myname value=Answer 3 id=3 / label for=33/label br / input type=submit value=Enter / /form --- FORM 2 There is another page has a form with 14 fields PLUS I need the data of the previous form to be hidden somewhere in this form. Once this form is submitted I need to put the combined data into the database. I know this is so simple. But not sure why this is not working. I tried to use ?$_GET[myname] ? from the first form but its not working. My module page has to go live tomorrow morning, I am stuck, please help. Thanks, Chris Arr. Sometimes I wonder. Sometimes it's the little things and a fresh pair of eyes make all the difference. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP I tend to use $_REQUEST to capture a lot of my data, as I end up mixing get and post a lot throughout my code. $_REQUEST is an amalgamate of $_COOKIE, $_GET and $_POST (in that order I believe, with $_GET overwritting $_COOKIE, and $_POST overwriting $_GET). This is especially useful when altering how a form sends data. Only today we had to update a form to use GET instead of POST, as IE managed to break the back button because of the POST values not auto-submitting. It would have meant a lot of code changes had $_REQUEST not been used. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
On Mon, 2009-01-12 at 19:43 +, Nathan Rixham wrote: Ashley Sheridan wrote: On Mon, 2009-01-12 at 11:51 -0500, Frank Stanovcak wrote: Ashley Sheridan wrote in message news:1231681793.3527.2.ca...@localhost.localdomain... On Sun, 2009-01-11 at 08:08 -0500, tedd wrote: At 4:16 PM -0500 1/10/09, Paul M Foster wrote: And let me present an alternative perspective. Never do something like: ?php echo 'Hellow world'; ? Let Apache (or whatever) interpret HTML as HTML, and don't make it interpret PHP code as HTML. Instead, do: h1Hello world/h1 If you're going to use PHP in the middle of a bunch of HTML, then only use it where it's needed: h1Hello ?php echo $name; ?/h1 The contents of the PHP $name variable can't be seen by the HTML, which is why you need to enclose it in a little PHP island. Naturally, if you're going to put PHP code in the middle of a HTML page, make the extension PHP. Otherwise, Apache will not interpret the PHP code as PHP (unless you do some messing with .htaccess or whatever). It's just simplest to call a file something.php if it has PHP in it. Paul -- Paul M. Foster Paul: I agree with you. My example was not well thought out. My point was not to mix style elements with data. I should have said: I would consider the followingbad practice: ?php echo(h1$whatever/h1); ? Whereas, the following I would consider good practice. h1?php echo($whatever); ?/h1 Thanks for keeping me honest. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com Unless it's something like this: ?php echo h1 class=\$headerClass\$whatever/h1; ? Which is unlikely for a header tag, but I know this sort of format gets used a lot by me and others, especially for setting alternate row styles on tables (damn browsers and not supporting alternate rows!) Ash www.ashleysheridan.co.uk Hey Ash...Why don't you just use CSS subclassing? style type=text/css h1.odd {class stuff here} h1.even {class stuff here} /style then h1 class=odd?php echo $whatever; ?/h1 no escaping, and no need to php your css styles. :) Frank That's what I do do, but the 'odd' has to come from PHP, as unfortunately, numerical selectors in CSS aren't supported by (AFAIK) any browsers at the moment. So for example, if I was coding for alternate rows in a table, I might do: for($i=0; $i$some_limit; $i++) { $rowClass = ($i % 2 == 0)?'':'class=alternate'; print EOP tr $rowClass td.../td td.../td td.../td /tr EOP; } As far as such loops go, is this a particular faux pas in regards to the way it's coded? Go on Tedd ;) Ash www.ashleysheridan.co.uk nice pick-up on the fact you only need to css the alternate row not both odd and even :p Yeah, I think my laziness had something to do with that, I didn't want to have to go and define another style ;) Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Data trasfer between PHP pages
On Mon, Jan 12, 2009 at 3:03 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: I tend to use $_REQUEST to capture a lot of my data, as I end up mixing get and post a lot throughout my code. $_REQUEST is an amalgamate of $_COOKIE, $_GET and $_POST (in that order I believe, with $_GET overwritting $_COOKIE, and $_POST overwriting $_GET). This is especially useful when altering how a form sends data. Only today we had to update a form to use GET instead of POST, as IE managed to break the back button because of the POST values not auto-submitting. It would have meant a lot of code changes had $_REQUEST not been used. It's okay if you want to do such things, but I really wouldn't recommend it. It leads to buggy apps (from almost every example I've ever seen). Most code I've seen using $_REQUEST doesn't validate it either which would be the loophole to it. Any app allowing user input should function no matter where it comes from or what it is, but still why not be very clear about it. GET is for the state of the page POST is for data. So you really shouldn't mix the two concepts. If I need to display a form based on an id I might have a url that looks like /form.php?id=x which indicates I'm working with id x and it will make the post action also have id=x in the query string since it is the resource I'm working on, not the data. That save page will still technically have a GET POST mixed, but they're two totally different things. You can fix IE back button problems with the PRG pattern [1]. It's kind of lame but I got over that after not having to see page expired anymore. [1] http://en.wikipedia.org/wiki/Post/Redirect/Get -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Data trasfer between PHP pages
On Mon, 2009-01-12 at 15:15 -0500, Eric Butera wrote: On Mon, Jan 12, 2009 at 3:03 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: I tend to use $_REQUEST to capture a lot of my data, as I end up mixing get and post a lot throughout my code. $_REQUEST is an amalgamate of $_COOKIE, $_GET and $_POST (in that order I believe, with $_GET overwritting $_COOKIE, and $_POST overwriting $_GET). This is especially useful when altering how a form sends data. Only today we had to update a form to use GET instead of POST, as IE managed to break the back button because of the POST values not auto-submitting. It would have meant a lot of code changes had $_REQUEST not been used. It's okay if you want to do such things, but I really wouldn't recommend it. It leads to buggy apps (from almost every example I've ever seen). Most code I've seen using $_REQUEST doesn't validate it either which would be the loophole to it. Any app allowing user input should function no matter where it comes from or what it is, but still why not be very clear about it. GET is for the state of the page POST is for data. So you really shouldn't mix the two concepts. Most systems using a front-end loader to get to a page containing a form wouldn't work if you DIDN'T mix the two concepts. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] switch vs elseif
I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info on switch or elseif seperately. :( Strictly from a performance stand point, not preference or anything else, is there a benefit of one over the other? for($i=0;$i3;$i++){ switch($i){ case 0: header pg1 code break; case 1: header pg2 code break; case 3: header pg3 code break; }; }; or would that be better served using an if...elseif structure? Frank -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] switch vs elseif
I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info on switch or elseif seperately. :( Strictly from a performance stand point, not preference or anything else, is there a benefit of one over the other? for($i=0;$i3;$i++){ switch($i){ case 0: header pg1 code break; case 1: header pg2 code break; case 3: header pg3 code break; }; }; or would that be better served using an if...elseif structure? Frank -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Data trasfer between PHP pages
On Mon, Jan 12, 2009 at 3:21 PM, Robert Cummings rob...@interjinn.com wrote: On Mon, 2009-01-12 at 15:15 -0500, Eric Butera wrote: On Mon, Jan 12, 2009 at 3:03 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: I tend to use $_REQUEST to capture a lot of my data, as I end up mixing get and post a lot throughout my code. $_REQUEST is an amalgamate of $_COOKIE, $_GET and $_POST (in that order I believe, with $_GET overwritting $_COOKIE, and $_POST overwriting $_GET). This is especially useful when altering how a form sends data. Only today we had to update a form to use GET instead of POST, as IE managed to break the back button because of the POST values not auto-submitting. It would have meant a lot of code changes had $_REQUEST not been used. It's okay if you want to do such things, but I really wouldn't recommend it. It leads to buggy apps (from almost every example I've ever seen). Most code I've seen using $_REQUEST doesn't validate it either which would be the loophole to it. Any app allowing user input should function no matter where it comes from or what it is, but still why not be very clear about it. GET is for the state of the page POST is for data. So you really shouldn't mix the two concepts. Most systems using a front-end loader to get to a page containing a form wouldn't work if you DIDN'T mix the two concepts. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP I use MVC w/ front controllers all the time. I dunno what you're talking about though so hopefully you can elaborate more. demo_form would accept GET id=1 demo_save would accept GET id=1 and POST name, description, etc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] switch vs elseif
On Mon, Jan 12, 2009 at 3:15 PM, Frank Stanovcak blindspot...@comcast.net wrote: I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info on switch or elseif seperately. :( Strictly from a performance stand point, not preference or anything else, is there a benefit of one over the other? for($i=0;$i3;$i++){ switch($i){ case 0: header pg1 code break; case 1: header pg2 code break; case 3: header pg3 code break; }; }; or would that be better served using an if...elseif structure? Frank -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This might be of interest in answering your question: http://www.suspekt.org/switchtable/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] switch vs elseif
On Mon, 2009-01-12 at 15:15 -0500, Frank Stanovcak wrote: I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info on switch or elseif seperately. :( Strictly from a performance stand point, not preference or anything else, is there a benefit of one over the other? for($i=0;$i3;$i++){ switch($i){ case 0: header pg1 code break; case 1: header pg2 code break; case 3: header pg3 code break; }; }; or would that be better served using an if...elseif structure? In some caes you can use a switch statement to avoid redundant code by allowing a particular case to contain code for one condition then allowing fall through to the next condition's code. The following is a lame example: ?php switch( $foo ) { case 0: { // something break; } case 2: { // something else } case 3: { // something elser break; } default: { // something defaulty } } ? In the above exmaple case 2 runs the code within it's block AND the code within case 3's block. Using else you would probably do one of the following: ?php else if( $foo == 2 || $foo == 3 ) { // something else if( $foo == 3 ) { // something elser } } ? Or with code redundancy: ?php else if( $foo == 2 ) { // something else // something elser } else if( $foo == 3 ) { // something elser } ? One has to wonder about the readability of the case version though since one may not notice immediately the missing break statement. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Data trasfer between PHP pages
Eric Butera wrote: On Mon, Jan 12, 2009 at 3:21 PM, Robert Cummings rob...@interjinn.com wrote: On Mon, 2009-01-12 at 15:15 -0500, Eric Butera wrote: On Mon, Jan 12, 2009 at 3:03 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: I tend to use $_REQUEST to capture a lot of my data, as I end up mixing get and post a lot throughout my code. $_REQUEST is an amalgamate of $_COOKIE, $_GET and $_POST (in that order I believe, with $_GET overwritting $_COOKIE, and $_POST overwriting $_GET). This is especially useful when altering how a form sends data. Only today we had to update a form to use GET instead of POST, as IE managed to break the back button because of the POST values not auto-submitting. It would have meant a lot of code changes had $_REQUEST not been used. It's okay if you want to do such things, but I really wouldn't recommend it. It leads to buggy apps (from almost every example I've ever seen). Most code I've seen using $_REQUEST doesn't validate it either which would be the loophole to it. Any app allowing user input should function no matter where it comes from or what it is, but still why not be very clear about it. GET is for the state of the page POST is for data. So you really shouldn't mix the two concepts. Most systems using a front-end loader to get to a page containing a form wouldn't work if you DIDN'T mix the two concepts. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP I use MVC w/ front controllers all the time. I dunno what you're talking about though so hopefully you can elaborate more. demo_form would accept GET id=1 demo_save would accept GET id=1 and POST name, description, etc if i understand correctly i think you just proved robs point; you mixed get and post on the demo_save (vs mixing by using $REQUEST which is just wrong imho - no offense) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Data trasfer between PHP pages
On Mon, 2009-01-12 at 15:29 -0500, Eric Butera wrote: On Mon, Jan 12, 2009 at 3:21 PM, Robert Cummings rob...@interjinn.com wrote: On Mon, 2009-01-12 at 15:15 -0500, Eric Butera wrote: On Mon, Jan 12, 2009 at 3:03 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: I tend to use $_REQUEST to capture a lot of my data, as I end up mixing get and post a lot throughout my code. $_REQUEST is an amalgamate of $_COOKIE, $_GET and $_POST (in that order I believe, with $_GET overwritting $_COOKIE, and $_POST overwriting $_GET). This is especially useful when altering how a form sends data. Only today we had to update a form to use GET instead of POST, as IE managed to break the back button because of the POST values not auto-submitting. It would have meant a lot of code changes had $_REQUEST not been used. It's okay if you want to do such things, but I really wouldn't recommend it. It leads to buggy apps (from almost every example I've ever seen). Most code I've seen using $_REQUEST doesn't validate it either which would be the loophole to it. Any app allowing user input should function no matter where it comes from or what it is, but still why not be very clear about it. GET is for the state of the page POST is for data. So you really shouldn't mix the two concepts. Most systems using a front-end loader to get to a page containing a form wouldn't work if you DIDN'T mix the two concepts. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP I use MVC w/ front controllers all the time. I dunno what you're talking about though so hopefully you can elaborate more. demo_form would accept GET id=1 demo_save would accept GET id=1 and POST name, description, etc Front end controller usually receives a GET variable indicating what page or content is being requested... add a form with POSTed data and you need to mix GET and POST. unless you go through the hoops of putting the front end loader information into the form. There's absolutely nothing wrong with mixing GET and POST as long as you know what you're doing. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Data trasfer between PHP pages
On Mon, 2009-01-12 at 15:15 -0500, Eric Butera wrote: On Mon, Jan 12, 2009 at 3:03 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: I tend to use $_REQUEST to capture a lot of my data, as I end up mixing get and post a lot throughout my code. $_REQUEST is an amalgamate of $_COOKIE, $_GET and $_POST (in that order I believe, with $_GET overwritting $_COOKIE, and $_POST overwriting $_GET). This is especially useful when altering how a form sends data. Only today we had to update a form to use GET instead of POST, as IE managed to break the back button because of the POST values not auto-submitting. It would have meant a lot of code changes had $_REQUEST not been used. It's okay if you want to do such things, but I really wouldn't recommend it. It leads to buggy apps (from almost every example I've ever seen). Most code I've seen using $_REQUEST doesn't validate it either which would be the loophole to it. Any app allowing user input should function no matter where it comes from or what it is, but still why not be very clear about it. GET is for the state of the page POST is for data. So you really shouldn't mix the two concepts. If I need to display a form based on an id I might have a url that looks like /form.php?id=x which indicates I'm working with id x and it will make the post action also have id=x in the query string since it is the resource I'm working on, not the data. That save page will still technically have a GET POST mixed, but they're two totally different things. You can fix IE back button problems with the PRG pattern [1]. It's kind of lame but I got over that after not having to see page expired anymore. [1] http://en.wikipedia.org/wiki/Post/Redirect/Get I like that idea actually, I'll try and work it into the next projects, as it would fix the problem rather than work-around it. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] switch vs elseif
On Mon, 2009-01-12 at 15:15 -0500, Frank Stanovcak wrote: I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info on switch or elseif seperately. :( Strictly from a performance stand point, not preference or anything else, is there a benefit of one over the other? for($i=0;$i3;$i++){ switch($i){ case 0: header pg1 code break; case 1: header pg2 code break; case 3: header pg3 code break; }; }; or would that be better served using an if...elseif structure? Frank And a switch is a lot neater for dealing with these sorts of things. I tend never to use if...elseif's at all, and use switches. Like Rob said, you can fall into further cases below, and it's very simple to add more at a later date. There is one place where an if...elseif would work and a switch could not, and that is where you were performing lots of different logic tests on different variables. Aside from that, I think any speed benefit one would have over the other would be marginal. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Data trasfer between PHP pages
On Mon, Jan 12, 2009 at 3:34 PM, Robert Cummings rob...@interjinn.com wrote: On Mon, 2009-01-12 at 15:29 -0500, Eric Butera wrote: On Mon, Jan 12, 2009 at 3:21 PM, Robert Cummings rob...@interjinn.com wrote: On Mon, 2009-01-12 at 15:15 -0500, Eric Butera wrote: On Mon, Jan 12, 2009 at 3:03 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: I tend to use $_REQUEST to capture a lot of my data, as I end up mixing get and post a lot throughout my code. $_REQUEST is an amalgamate of $_COOKIE, $_GET and $_POST (in that order I believe, with $_GET overwritting $_COOKIE, and $_POST overwriting $_GET). This is especially useful when altering how a form sends data. Only today we had to update a form to use GET instead of POST, as IE managed to break the back button because of the POST values not auto-submitting. It would have meant a lot of code changes had $_REQUEST not been used. It's okay if you want to do such things, but I really wouldn't recommend it. It leads to buggy apps (from almost every example I've ever seen). Most code I've seen using $_REQUEST doesn't validate it either which would be the loophole to it. Any app allowing user input should function no matter where it comes from or what it is, but still why not be very clear about it. GET is for the state of the page POST is for data. So you really shouldn't mix the two concepts. Most systems using a front-end loader to get to a page containing a form wouldn't work if you DIDN'T mix the two concepts. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP I use MVC w/ front controllers all the time. I dunno what you're talking about though so hopefully you can elaborate more. demo_form would accept GET id=1 demo_save would accept GET id=1 and POST name, description, etc Front end controller usually receives a GET variable indicating what page or content is being requested... add a form with POSTed data and you need to mix GET and POST. unless you go through the hoops of putting the front end loader information into the form. There's absolutely nothing wrong with mixing GET and POST as long as you know what you're doing. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP Yep. I guess I was just trying to define what knowing what I'm doing meant. My url might have id=1 in it, but that is the only thing. On a post page I still need that id=1 in the url because it has to know what record to update. Some could argue to throw that in the form itself, I used to even, but over time it has just made more sense for it to be in the url since it defines what page/record you're working with. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] switch vs elseif
Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1231793310.3558.55.ca...@localhost.localdomain... On Mon, 2009-01-12 at 15:15 -0500, Frank Stanovcak wrote: I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info on switch or elseif seperately. :( Strictly from a performance stand point, not preference or anything else, is there a benefit of one over the other? for($i=0;$i3;$i++){ switch($i){ case 0: header pg1 code break; case 1: header pg2 code break; case 3: header pg3 code break; }; }; or would that be better served using an if...elseif structure? Frank And a switch is a lot neater for dealing with these sorts of things. I tend never to use if...elseif's at all, and use switches. Like Rob said, you can fall into further cases below, and it's very simple to add more at a later date. There is one place where an if...elseif would work and a switch could not, and that is where you were performing lots of different logic tests on different variables. Aside from that, I think any speed benefit one would have over the other would be marginal. Ash www.ashleysheridan.co.uk Yeah, I knew about the fall through benefit. :) I was just worried about speed since I have to loop through this several times and generate a pdf from it. Thanks folks! Frank -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] switch vs elseif
Eric Butera eric.but...@gmail.com wrote in message news:6a8639eb0901121231r253eed48xe1974d8ef44ab...@mail.gmail.com... On Mon, Jan 12, 2009 at 3:15 PM, Frank Stanovcak blindspot...@comcast.net wrote: I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info on switch or elseif seperately. :( Strictly from a performance stand point, not preference or anything else, is there a benefit of one over the other? for($i=0;$i3;$i++){ switch($i){ case 0: header pg1 code break; case 1: header pg2 code break; case 3: header pg3 code break; }; }; or would that be better served using an if...elseif structure? Frank -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This might be of interest in answering your question: http://www.suspekt.org/switchtable/ Wow...so if I read that right. the only difference in the root code of PHP is that the pre compiled code is easier to read. PHP actually generates the If...elseif...elseif... structure any way when it compiles the script. ewww. Frank. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] switch vs elseif
On Mon, Jan 12, 2009 at 3:58 PM, Frank Stanovcak blindspot...@comcast.net wrote: Eric Butera eric.but...@gmail.com wrote in message news:6a8639eb0901121231r253eed48xe1974d8ef44ab...@mail.gmail.com... On Mon, Jan 12, 2009 at 3:15 PM, Frank Stanovcak blindspot...@comcast.net wrote: I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info on switch or elseif seperately. :( Strictly from a performance stand point, not preference or anything else, is there a benefit of one over the other? for($i=0;$i3;$i++){ switch($i){ case 0: header pg1 code break; case 1: header pg2 code break; case 3: header pg3 code break; }; }; or would that be better served using an if...elseif structure? Frank -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This might be of interest in answering your question: http://www.suspekt.org/switchtable/ Wow...so if I read that right. the only difference in the root code of PHP is that the pre compiled code is easier to read. PHP actually generates the If...elseif...elseif... structure any way when it compiles the script. ewww. Frank. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Yea I was bummed out to hear that too because I had heard switch was faster. Oh well. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] switch vs elseif -- switchtable
On Mon, 2009-01-12 at 15:31 -0500, Eric Butera wrote: On Mon, Jan 12, 2009 at 3:15 PM, Frank Stanovcak blindspot...@comcast.net wrote: I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info on switch or elseif seperately. :( Strictly from a performance stand point, not preference or anything else, is there a benefit of one over the other? for($i=0;$i3;$i++){ switch($i){ case 0: header pg1 code break; case 1: header pg2 code break; case 3: header pg3 code break; }; }; or would that be better served using an if...elseif structure? Frank This might be of interest in answering your question: http://www.suspekt.org/switchtable/ How do I install this? The page and .tgz both give no instructions?! Are there any benchmarks to show speed comparisons? Also, is there any plans to have this patch/extension incorporated into the real PHP trunk? Daevid. http://daevid.com
Re: [PHP] Couple of beginner questions
At 7:47 PM + 1/12/09, Ashley Sheridan wrote: Ehat's what I do do, but the 'odd' has to come from PHP, as unfortunately, numerical selectors in CSS aren't supported by (AFAIK) any browsers at the moment. So for example, if I was coding for alternate rows in a table, I might do: for($i=0; $i$some_limit; $i++) { $rowClass = ($i % 2 == 0)?'':'class=alternate'; print EOP tr $rowClass td.../td td.../td td.../td /tr EOP; } As far as such loops go, is this a particular faux pas in regards to the way it's coded? Go on Tedd ;) Ash True, css does not allow numeric classes (like sessions). But, I never need them anyway. As I provided before: http://webbytedd.com/b/color-rows/ this is my solution for alternating row style. As for the above code being something I approve, or not -- I see your point. Heredoc's do present a mixture of text (HTML, et all.) that begs the question of IF it is keeping html and php separate. On one hand, some can say that a heredoc IS a component as much as echo() and thus should not contain html. But on the other hand, that's what it was designed for. So, it's one of those things that can't be judged in such fashion. However, I can say that a heredoc containing html does not brother me as much as an echo() containing the same. Cheers, 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] switch vs elseif -- switchtable
On Mon, Jan 12, 2009 at 4:00 PM, Daevid Vincent dae...@daevid.com wrote: On Mon, 2009-01-12 at 15:31 -0500, Eric Butera wrote: On Mon, Jan 12, 2009 at 3:15 PM, Frank Stanovcak blindspot...@comcast.net wrote: I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info on switch or elseif seperately. :( Strictly from a performance stand point, not preference or anything else, is there a benefit of one over the other? for($i=0;$i3;$i++){ switch($i){ case 0: header pg1 code break; case 1: header pg2 code break; case 3: header pg3 code break; }; }; or would that be better served using an if...elseif structure? Frank This might be of interest in answering your question: http://www.suspekt.org/switchtable/ How do I install this? The page and .tgz both give no instructions?! Are there any benchmarks to show speed comparisons? Also, is there any plans to have this patch/extension incorporated into the real PHP trunk? Daevid. http://daevid.com Hi Daevid, Someone wrote a quick bench on this url: http://www.suspekt.org/2008/07/31/switch-table-extension/ As for all your other questions, you'll have to contact the author. I just thought it applied to this thread. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] variable probe revision
I posted this once before, and then tried to use it multiple times in a script. As you can guess I got a bunch of func already defined errors. Here is a revision incase anyone decided to use it that will work multiple times in the same script for variable watching. ---Code follows--- ?php if(!function_exists(breakarray)){ function breakarray($passed){ echo 'table border=1trthkey/ththvalue/th/tr'; foreach($passed as $tkey=$tvalue){ echo 'trtd[' , $tkey , ']/tdtd'; if(is_array($tvalue)){ if(sizeof($tvalue) 0){ breakarray($tvalue); echo '/td/tr'; }else{ echo '' , $tvalue , '/td/tr'; }; }else{ echo 'EMPTY /td/tr'; }; }; echo '/table'; }; }; echo 'table border=1tr thvariable/th thvalue/th /tr'; foreach(get_defined_vars() as $key = $value){ echo 'trtd$',$key ,'/tdtd'; if(is_array($value) and $key != 'GLOBALS'){ if(sizeof($value) 0){ breakarray($value); echo '/td/tr'; }else{ echo 'EMPTY /td/tr'; }; }else{ echo '' , $value , '/td/tr'; }; }; echo '/table'; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
On Mon, 2009-01-12 at 16:02 -0500, tedd wrote: True, css does not allow numeric classes (like sessions). But, I never need them anyway. As I provided before: http://webbytedd.com/b/color-rows/ this is my solution for alternating row style. tr class=row?php echo($i++ 1 );? td abc/td td abc/td td abc/td /tr That's just wasteful... Here's better: tr class=row?php echo( $i ^= 1 );? td abc/td td abc/td td abc/td /tr Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Data trasfer between PHP pages
At 8:03 PM + 1/12/09, Ashley Sheridan wrote: I tend to use $_REQUEST to capture a lot of my data, as I end up mixing get and post a lot throughout my code. $_REQUEST is an amalgamate of $_COOKIE, $_GET and $_POST (in that order I believe, with $_GET overwritting $_COOKIE, and $_POST overwriting $_GET). This is especially useful when altering how a form sends data. Only today we had to update a form to use GET instead of POST, as IE managed to break the back button because of the POST values not auto-submitting. It would have meant a lot of code changes had $_REQUEST not been used. Ash www.ashleysheridan.co.uk Arr. I was thinking you were up there with the PHP greats until you said that. :-0 I never use requests -- you simply don't know where the data is coming from and that presents a possible security risk as well as confusion if you have to review/trouble-shoot the code later. Am I wrong? Cheers, 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] Data trasfer between PHP pages
On Mon, 2009-01-12 at 16:18 -0500, tedd wrote: At 8:03 PM + 1/12/09, Ashley Sheridan wrote: I tend to use $_REQUEST to capture a lot of my data, as I end up mixing get and post a lot throughout my code. $_REQUEST is an amalgamate of $_COOKIE, $_GET and $_POST (in that order I believe, with $_GET overwritting $_COOKIE, and $_POST overwriting $_GET). This is especially useful when altering how a form sends data. Only today we had to update a form to use GET instead of POST, as IE managed to break the back button because of the POST values not auto-submitting. It would have meant a lot of code changes had $_REQUEST not been used. Ash www.ashleysheridan.co.uk Arr. I was thinking you were up there with the PHP greats until you said that. :-0 I never use requests -- you simply don't know where the data is coming from and that presents a possible security risk as well as confusion if you have to review/trouble-shoot the code later. Am I wrong? Proper use of $_REQUEST shouldn't be an issue. But I still like to keep them separate so tha internally I know exactly where the data came from. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Data trasfer between PHP pages
On Mon, Jan 12, 2009 at 4:18 PM, tedd tedd.sperl...@gmail.com wrote: At 8:03 PM + 1/12/09, Ashley Sheridan wrote: I tend to use $_REQUEST to capture a lot of my data, as I end up mixing get and post a lot throughout my code. $_REQUEST is an amalgamate of $_COOKIE, $_GET and $_POST (in that order I believe, with $_GET overwritting $_COOKIE, and $_POST overwriting $_GET). This is especially useful when altering how a form sends data. Only today we had to update a form to use GET instead of POST, as IE managed to break the back button because of the POST values not auto-submitting. It would have meant a lot of code changes had $_REQUEST not been used. Ash www.ashleysheridan.co.uk Arr. I was thinking you were up there with the PHP greats until you said that. :-0 I never use requests -- you simply don't know where the data is coming from and that presents a possible security risk as well as confusion if you have to review/trouble-shoot the code later. Am I wrong? Cheers, 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 I can just as easily make firefox/curl send data via cookie or post as a get. It's how you validate it that is the most important (security wise). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Data trasfer between PHP pages
On Mon, 2009-01-12 at 16:18 -0500, tedd wrote: At 8:03 PM + 1/12/09, Ashley Sheridan wrote: I tend to use $_REQUEST to capture a lot of my data, as I end up mixing get and post a lot throughout my code. $_REQUEST is an amalgamate of $_COOKIE, $_GET and $_POST (in that order I believe, with $_GET overwritting $_COOKIE, and $_POST overwriting $_GET). This is especially useful when altering how a form sends data. Only today we had to update a form to use GET instead of POST, as IE managed to break the back button because of the POST values not auto-submitting. It would have meant a lot of code changes had $_REQUEST not been used. Ash www.ashleysheridan.co.uk Arr. I was thinking you were up there with the PHP greats until you said that. :-0 I never use requests -- you simply don't know where the data is coming from and that presents a possible security risk as well as confusion if you have to review/trouble-shoot the code later. Am I wrong? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com Both GET and POST are as susceptible as each other to attack. So as long as data is properly sanitised before it's used, it should be fine. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
On Mon, Jan 12, 2009 at 4:17 PM, Robert Cummings rob...@interjinn.com wrote: On Mon, 2009-01-12 at 16:02 -0500, tedd wrote: True, css does not allow numeric classes (like sessions). But, I never need them anyway. As I provided before: http://webbytedd.com/b/color-rows/ this is my solution for alternating row style. tr class=row?php echo($i++ 1 );? td abc/td td abc/td td abc/td /tr That's just wasteful... Here's better: tr class=row?php echo( $i ^= 1 );? td abc/td td abc/td td abc/td /tr Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You guys with your clever bit-shifting. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Php and CSS where to put it
At 7:38 PM +0100 1/12/09, Michelle Konzack wrote: Hello Terion, Am 2009-01-12 10:42:10, schrieb Terion Miller: I have this code and the css seems to not work in IE at all, do I need to put it somewhere different on the page maybe? The CSS must be in the HTML Header like html head titleCSS Example/title link rel=stylesheet type=text/css href=inc/styles.css style type=text/css #body { background-color: magenta; } /style /head body ...rest of the page Today must be my Arrr day. Don't embed css in document -- just put what you want in your css file. If IE has a problem with it, then deal with IE within the css file. There are css hacks if you can't find a way around the problem. But embedding css style rules is a real no-no in my book -- there's no reason to do it. Cheers, 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] Couple of beginner questions
On Mon, 2009-01-12 at 16:17 -0500, Robert Cummings wrote: On Mon, 2009-01-12 at 16:02 -0500, tedd wrote: True, css does not allow numeric classes (like sessions). But, I never need them anyway. As I provided before: http://webbytedd.com/b/color-rows/ this is my solution for alternating row style. tr class=row?php echo($i++ 1 );? td abc/td td abc/td td abc/td /tr That's just wasteful... Here's better: tr class=row?php echo( $i ^= 1 );? td abc/td td abc/td td abc/td /tr Cheers, Rob. It is a *lot* smaller than my example. I like it! :p Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variable probe revision
On Mon, 2009-01-12 at 16:11 -0500, Frank Stanovcak wrote: I posted this once before, and then tried to use it multiple times in a script. As you can guess I got a bunch of func already defined errors. Here is a revision incase anyone decided to use it that will work multiple times in the same script for variable watching. ---Code follows--- ?php if(!function_exists(breakarray)){ function breakarray($passed){ echo 'table border=1trthkey/ththvalue/th/tr'; foreach($passed as $tkey=$tvalue){ echo 'trtd[' , $tkey , ']/tdtd'; if(is_array($tvalue)){ if(sizeof($tvalue) 0){ breakarray($tvalue); echo '/td/tr'; }else{ echo '' , $tvalue , '/td/tr'; }; }else{ echo 'EMPTY /td/tr'; }; }; echo '/table'; }; }; echo 'table border=1tr thvariable/th thvalue/th /tr'; foreach(get_defined_vars() as $key = $value){ echo 'trtd$',$key ,'/tdtd'; if(is_array($value) and $key != 'GLOBALS'){ if(sizeof($value) 0){ breakarray($value); echo '/td/tr'; }else{ echo 'EMPTY /td/tr'; }; }else{ echo '' , $value , '/td/tr'; }; }; echo '/table'; ? Why not put the function in a functions include and use a require_once() on it? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
Robert Cummings wrote: On Mon, 2009-01-12 at 16:02 -0500, tedd wrote: True, css does not allow numeric classes (like sessions). But, I never need them anyway. As I provided before: http://webbytedd.com/b/color-rows/ this is my solution for alternating row style. tr class=row?php echo($i++ 1 );? td abc/td td abc/td td abc/td /tr That's just wasteful... Here's better: tr class=row?php echo( $i ^= 1 );? td abc/td td abc/td td abc/td /tr Cheers, Rob. wtf? that's some freaky bug right there rob.. ?php for($i=0;$i10;$i++) { ? tr class=row?php echo( $i ^= 1 ); ? td abc/td td abc/td td abc/td /tr ?php } ? output: tr class=row1 td abc/td td abc/td td abc/td /tr tr class=row3 td abc/td td abc/td td abc/td /tr tr class=row5 td abc/td td abc/td td abc/td /tr tr class=row7 td abc/td td abc/td td abc/td /tr tr class=row9 td abc/td td abc/td td abc/td /tr php 5.2.5 - weird -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] switch vs elseif
At 3:15 PM -0500 1/12/09, Frank Stanovcak wrote: I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info on switch or elseif seperately. :( Strictly from a performance stand point, not preference or anything else, is there a benefit of one over the other? for($i=0;$i3;$i++){ switch($i){ case 0: header pg1 code break; case 1: header pg2 code break; case 3: header pg3 code break; }; }; or would that be better served using an if...elseif structure? Frank elseif!!! Arr !!! I guess that today is my day to get myself in all sorts of trouble. I have never used elseif -- and can't stand it, tedd's rules. if ($options 2) { echo('use switch'); { else { echo('use if'); } Reason? It makes sense to me. Cheers, 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] Couple of beginner questions
On Mon, 2009-01-12 at 16:26 -0500, Eric Butera wrote: On Mon, Jan 12, 2009 at 4:17 PM, Robert Cummings tr class=row?php echo( $i ^= 1 );? td abc/td td abc/td td abc/td /tr Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You guys with your clever bit-shifting. :) That was a toggle, not a shift :D Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Php and CSS where to put it
On Mon, 2009-01-12 at 16:27 -0500, tedd wrote: At 7:38 PM +0100 1/12/09, Michelle Konzack wrote: Hello Terion, Am 2009-01-12 10:42:10, schrieb Terion Miller: I have this code and the css seems to not work in IE at all, do I need to put it somewhere different on the page maybe? The CSS must be in the HTML Header like html head titleCSS Example/title link rel=stylesheet type=text/css href=inc/styles.css style type=text/css #body { background-color: magenta; } /style /head body ...rest of the page Today must be my Arrr day. Don't embed css in document -- just put what you want in your css file. If IE has a problem with it, then deal with IE within the css file. There are css hacks if you can't find a way around the problem. But embedding css style rules is a real no-no in my book -- there's no reason to do it. On my dev sites I embed the CSS, on production it gets exported to an external version-named file as part of the build process. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
On Mon, 2009-01-12 at 21:36 +, Nathan Rixham wrote: Robert Cummings wrote: On Mon, 2009-01-12 at 16:02 -0500, tedd wrote: True, css does not allow numeric classes (like sessions). But, I never need them anyway. As I provided before: http://webbytedd.com/b/color-rows/ this is my solution for alternating row style. tr class=row?php echo($i++ 1 );? td abc/td td abc/td td abc/td /tr That's just wasteful... Here's better: tr class=row?php echo( $i ^= 1 );? td abc/td td abc/td td abc/td /tr Cheers, Rob. wtf? that's some freaky bug right there rob.. ?php for($i=0;$i10;$i++) { ? tr class=row?php echo( $i ^= 1 ); ? td abc/td td abc/td td abc/td /tr ?php } ? output: tr class=row1 td abc/td td abc/td td abc/td /tr tr class=row3 td abc/td td abc/td td abc/td /tr tr class=row5 td abc/td td abc/td td abc/td /tr tr class=row7 td abc/td td abc/td td abc/td /tr tr class=row9 td abc/td td abc/td td abc/td /tr php 5.2.5 - weird Nooo... you introduced the bug, my code presumed a foreach loop and $i intialized to 0. You're code doesn't work with tedd's version either since you're incrementing $i in the loop and in the HTML output... thus it will always be even. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
Robert Cummings wrote: On Mon, 2009-01-12 at 21:36 +, Nathan Rixham wrote: Robert Cummings wrote: On Mon, 2009-01-12 at 16:02 -0500, tedd wrote: True, css does not allow numeric classes (like sessions). But, I never need them anyway. As I provided before: http://webbytedd.com/b/color-rows/ this is my solution for alternating row style. tr class=row?php echo($i++ 1 );? td abc/td td abc/td td abc/td /tr That's just wasteful... Here's better: tr class=row?php echo( $i ^= 1 );? td abc/td td abc/td td abc/td /tr Cheers, Rob. wtf? that's some freaky bug right there rob.. ?php for($i=0;$i10;$i++) { ? tr class=row?php echo( $i ^= 1 ); ? td abc/td td abc/td td abc/td /tr ?php } ? output: tr class=row1 td abc/td td abc/td td abc/td /tr tr class=row3 td abc/td td abc/td td abc/td /tr tr class=row5 td abc/td td abc/td td abc/td /tr tr class=row7 td abc/td td abc/td td abc/td /tr tr class=row9 td abc/td td abc/td td abc/td /tr php 5.2.5 - weird Nooo... you introduced the bug, my code presumed a foreach loop and $i intialized to 0. You're code doesn't work with tedd's version either since you're incrementing $i in the loop and in the HTML output... thus it will always be even. Cheers, Rob. but the rest should echo regardless..? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
On Mon, 2009-01-12 at 21:45 +, Nathan Rixham wrote: Robert Cummings wrote: On Mon, 2009-01-12 at 21:36 +, Nathan Rixham wrote: Robert Cummings wrote: On Mon, 2009-01-12 at 16:02 -0500, tedd wrote: True, css does not allow numeric classes (like sessions). But, I never need them anyway. As I provided before: http://webbytedd.com/b/color-rows/ this is my solution for alternating row style. tr class=row?php echo($i++ 1 );? td abc/td td abc/td td abc/td /tr That's just wasteful... Here's better: tr class=row?php echo( $i ^= 1 );? td abc/td td abc/td td abc/td /tr Cheers, Rob. wtf? that's some freaky bug right there rob.. ?php for($i=0;$i10;$i++) { ? tr class=row?php echo( $i ^= 1 ); ? td abc/td td abc/td td abc/td /tr ?php } ? output: tr class=row1 td abc/td td abc/td td abc/td /tr tr class=row3 td abc/td td abc/td td abc/td /tr tr class=row5 td abc/td td abc/td td abc/td /tr tr class=row7 td abc/td td abc/td td abc/td /tr tr class=row9 td abc/td td abc/td td abc/td /tr php 5.2.5 - weird Nooo... you introduced the bug, my code presumed a foreach loop and $i intialized to 0. You're code doesn't work with tedd's version either since you're incrementing $i in the loop and in the HTML output... thus it will always be even. Cheers, Rob. but the rest should echo regardless..? Huh? -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php