Re: [PHP] Re: Problem with EXEC and PASSTHRU
# [EMAIL PROTECTED] / 2006-10-26 08:46:27 +1300: > I'm LOVING php now - its a very simple language limited only by your > imagination as to how you use it! My knowledge seems to be lacking > more in HTML and Browser server relationships - I'm basing things on > my background in Basic programming as a kid - you do Print "Hello > world" and it does that instantly to the screen - little different > with browsers! It's a little different with network communication. Try programming something for the console using the CLI (Command-Line Interface) version of PHP, should be much less confusing. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] heredoc usage [WAS:
At 10/25/2006 11:24 PM, Robert Cummings wrote: Now, the thing that I dislike about heredoc for such small strings is the switching between heredoc mode and the switching back. It's ugly on the scale of switching in and out of PHP tags. It's so interesting that some details bug some people and others bug others. In an expression such as this: echo '' . $day . ''; ...I count eight transitions (instances of switching between PHP syntax and output text) -- one each time you open or close a quote -- compared to just two transitions (the opening & closing labels) for the comparable heredoc statement: print <<< hdDay $day hdDay; it would be less ugly if the closing delimiter didn't have to be at the beginning of it's own line in which case code could still maintain indentation formatting. I agree. Too bad the PHP developers didn't come up with a special symbol for heredoc closing labels to give us more control over script formatting. I do however find this a fairly minor irritation, a small price to pay for heredoc's power. To lighten the mess of heredoc I personally use the following format: $foo = <<<_ ... _; Nice and concise! Thanks, I'll use that. However that's only useful if indenting the content is not an issue. I don't see how you draw that conclusion. Heredoc doesn't become useless if we need to indent the content, it just means we lose complete control over indenting every line of our PHP script. The functionality is still totally there. This script indenting issue with heredoc is for me one of the few irritations of PHP. I love the language and the power that heredoc gives me. I'm also irritated by the class member syntax $this->that but I still use it as well. > I ask because I use heredoc all the time, sometimes for inline code > as above but most often for template assembly, maintaining HTML in > external files that can be edited independently of the PHP logic. I use a tag based template system, there's no PHP in my content so my content files for the most part just look like more HTML. This is a different topic, but also one close to my heart. Yes, I too use my own selector-based templating system. It does allow me to embed PHP variables into the template if I want, but the primary merge between plain HTML template and MySQL content happens through CSS-style selectors. Hello , Cool. My comparable example (but in an HTML context) would look like: Hello FIRSTNAME, where the engine replaces the content of the span with the value from the database based on a match of 'span.firstName' or perhaps just '.firstName'. (In this example the 'FIRSTNAME' content in the template is merely a place-holder to make it easier to preview the markup and isn't necessary to the merge process.) | InterJinn Application Framework - http://www.interjinn.com | Interesting project! Good work. Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] heredoc usage [WAS:
Paul Novitski wrote: It's so interesting that some details bug some people and others bug others. In an expression such as this: echo '' . $day . ''; or you could write it likes this ' echo " $day "; much easier to read, but slightly more taxing on the server. -- Regards, Clive -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] heredoc usage [WAS:
Incidentally, a nice side effect of heredoc is that some editors (like vim) recognise <
[PHP] any one can give an idea on this question ?
Hi, I just wondering this.. For example I had a several php pages. In this page there was an array named $arrHede It has lots of values. in index.php $arrHede['antin']='yada'; in config.php $arrHede['kuntin']='bada'; and so. So I want to write a scrpit check all those files to get all $arrHede keys. And I do not want to include those files because of errors. Regards Sancar -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] any one can give an idea on this question ?
Sancar Saran wrote: I just wondering this.. For example I had a several php pages. In this page there was an array named $arrHede It has lots of values. in index.php $arrHede['antin']='yada'; in config.php $arrHede['kuntin']='bada'; and so. So I want to write a scrpit check all those files to get all $arrHede keys. And I do not want to include those files because of errors. Maybe it's just me, but I didn't see a question anywhere in that lot, just a statement of what you want to do. Seems obvious to me that you need to open each file, find assignments to the $arrHede array and pull out the values. Have you even tried to do that yet? We're not here to write scripts for you. Try it and come back if/when you have problems. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] any one can give an idea on this question ?
Sancar Saran wrote: For example I had a several php pages. In this page there was an array named $arrHede It has lots of values. in index.php $arrHede['antin']='yada'; in config.php $arrHede['kuntin']='bada'; and so. So I want to write a scrpit check all those files to get all $arrHede keys. And I do not want to include those files because of errors. Scanning all the php files with regex is probably easiest, e.g.: if (preg_match_all('/\$arrHede\[([\'"])(.*?)\1/', $contents, $matches)) { $keys = array_merge($keys, $matches[2]); } } ?> Note that if your array keys contain escaped quotes, like ['foo\'bar'], the regex would need to be a bit more complex to allow for them. Arpad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] any one can give an idea on this question ?
On Thursday 26 October 2006 14:32, Arpad Ray wrote: > Sancar Saran wrote: > > For example I had a several php pages. In this page there was an array > > named $arrHede > > > > It has lots of values. > > > > in index.php > > $arrHede['antin']='yada'; > > > > in config.php > > $arrHede['kuntin']='bada'; > > > > and so. > > > > So I want to write a scrpit check all those files to get all $arrHede > > keys. And I do not want to include those files because of errors. > > Scanning all the php files with regex is probably easiest, e.g.: > > $keys = array(); > foreach (glob('*.php') as $filename) { > $contents = file_get_contents($filename); > if (preg_match_all('/\$arrHede\[([\'"])(.*?)\1/', $contents, > $matches)) { > $keys = array_merge($keys, $matches[2]); > } > } > ?> > > Note that if your array keys contain escaped quotes, like ['foo\'bar'], > the regex would need to be a bit more complex to allow for them. > > Arpad Lots of thanks, that regex things my weakest area in that php I owe you my friend :) Regads Sancar... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Template Problems
Hi, I have 3 domains: www.example1.com, www.example2.com www.template.com I have a PHP website on www.template.com with a database. in this database I have many tables one of which is sites, which has a list of the sites using the template with a site_id. Example of this data is: Site_id, URL, Name 1 www.example1.comExample 1 2 www.example2.comExample 2 All of the other tables have the site_id in to relate to what site should be shown what information. However I can't have the user seeing the url as "www.template.com" instead it needs to say what they typed in for example "www.example1.com" I need to somehow redirect the user from "www.example1.com" (but mask the url) to "www.template.com" with the correct site_id passed through for every single page they visit (which says what data the template should load) which I would manually set in example1.com, this would then allow the user to browse the site and goto the next one when they want. Can anyone help Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Template
Hi, I have 3 domains: www.example1.com, www.example2.com www.template.com I have a PHP website on www.template.com with a database. in this database I have many tables one of which is sites, which has a list of the sites using the template with a site_id. Example of this data is: Site_id, URL, Name 1 www.example1.comExample 1 2 www.example2.comExample 2 All of the other tables have the site_id in to relate to what site should be shown what information. However I can't have the user seeing the url as "www.template.com" instead it needs to say what they typed in for example "www.example1.com" I need to somehow redirect the user from "www.example1.com" (but mask the url) to "www.template.com" with the correct site_id passed through for every single page they visit (which says what data the template should load) which I would manually set in example1.com, this would then allow the user to browse the site and goto the next one when they want. Can anyone help Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Template Trouble
Hi, I am trying to have 1 template site and have an unlimited number of websites using this template site to call there own information. The sites are exactly the same except for the database, each of the sites also needs there own URL, for example one of these urls may be www.example1.com and the other www.example2.com. These sites are identical apart from the database they call to, one will call to a database called example1 and the other example2. I want another site (for example www.solution.com) to read what url has been entered and to pull in the database for that site (either example1 or example2) and show that information. I have tried using the CURL library without success (not sure how to use it fully) and have tried using frames but had loads of problems regarding losing session data. can anyone help? Thanks Kev
Re: [PHP] PHP Template Trouble
Kevin, there is no need to post the same question three times to this list. Your chances on getting helpful responses won't increase. The issue you describe is more related to Apache (assuming that you are on an Apache server) and URL rewriting than to PHP. Ask Google for "Apache mod_rewrite" and I am sure you will find some stuff that will help you. /frank 25 okt 2006 kl. 11.49 skrev Kevin: Hi, I am trying to have 1 template site and have an unlimited number of websites using this template site to call there own information. The sites are exactly the same except for the database, each of the sites also needs there own URL, for example one of these urls may be www.example1.com and the other www.example2.com. These sites are identical apart from the database they call to, one will call to a database called example1 and the other example2. I want another site (for example www.solution.com) to read what url has been entered and to pull in the database for that site (either example1 or example2) and show that information. I have tried using the CURL library without success (not sure how to use it fully) and have tried using frames but had loads of problems regarding losing session data. can anyone help? Thanks Kev -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Template Trouble
Hi, Yes there was an error, I never meant to post 3 times it backlogged in the system and my bulk detector picked up the email from php.net asking me to register my email so sorry about that. I am actually using Windows IIS, there is a IISRewrite which does the same as mod_rewrite, however the problem I had using that is you can only change the bit after www.example.com so for example if i had www.example.com?cat_id=5 i could rewrite that to www.example.com/games/ however I didn't find a way of rewriting the entire URL to make it look like a different site, if that is possible however I'll look further into it but at the time being I have found no way. Thanks Frank Arensmeier wrote: Kevin, there is no need to post the same question three times to this list. Your chances on getting helpful responses won't increase. The issue you describe is more related to Apache (assuming that you are on an Apache server) and URL rewriting than to PHP. Ask Google for "Apache mod_rewrite" and I am sure you will find some stuff that will help you. /frank 25 okt 2006 kl. 11.49 skrev Kevin: Hi, I am trying to have 1 template site and have an unlimited number of websites using this template site to call there own information. The sites are exactly the same except for the database, each of the sites also needs there own URL, for example one of these urls may be www.example1.com and the other www.example2.com. These sites are identical apart from the database they call to, one will call to a database called example1 and the other example2. I want another site (for example www.solution.com) to read what url has been entered and to pull in the database for that site (either example1 or example2) and show that information. I have tried using the CURL library without success (not sure how to use it fully) and have tried using frames but had loads of problems regarding losing session data. can anyone help? Thanks Kev -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Template Trouble
>> Hi, >> >> I am trying to have 1 template site and have an unlimited number of >> websites using this template site to call there own information. >> >> The sites are exactly the same except for the database, each of the >> sites also needs there own URL, for example one of these urls may be >> www.example1.com and the other www.example2.com. These sites are >> identical apart from the database they call to, one will call to a >> database called example1 and the other example2. I want another site >> (for example www.solution.com) to read what url has been entered and >> to pull in the database for that site (either example1 or example2) >> and show that information. I have tried using the CURL library >> without success (not sure how to use it fully) and have tried using >> frames but had loads of problems regarding losing session data. can >> anyone help? >> >> Thanks >> Kev >> Here's just an idea to give you maybe a starting point to go from... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP]
Robert Cummings wrote: > On Wed, 2006-10-25 at 17:35 -0700, Paul Novitski wrote: >> At 10/25/2006 04:09 PM, Stut wrote: >>> Dang that's painful!! Try this... >>> >>> >> foreach (range(1, 31) as $day) >>> { >>> print '>> if ($selected_day_of_month == $day) >>> print ' selected'; >>> print '>'.$day.''; >>> } >>> >>> ?> >> >> Ouch! Gnarly mix of logic and markup. I suggest something more like: >> >> foreach (range(1, 31) as $day) >> { >> $sSelected = ($selected_day_of_month == $day) ? ' >> selected="selected"' : ''; >> >> print <<< hdDay >> $day >> >> hdDay; >> } > > Ewww, I'll take Stut's style anyday. Heredoc has its uses, but I > wouldn't consider your above usage one of them :/ Now to add my own > flavour... > > > for( $day = 1; $day <= 31; $day++ ) > { > $selected > = $selected_day_of_month == $day > ? ' selected="selected"' > : ''; > > echo '' > .$day > .''; > } > > ?> bunch of space wasters ;-) ',$d,''; ?> > > Cheers, > Rob. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Template Trouble
Hi Brad, That sounds like a good idea however: Where would config.php go? If it goes on the www.solution.com side of things, then $_SERVER[HTTP_HOST] will always be www.solution.com and if it goes on another then it would be www.example1.com. What you have put would be the kind of solution I am looking for but its the $_SERVER[HTTP_HOST] variable that would need to be posted through correctly, even if using frames on www.example1.com (using them to load www.solution.com) $_SERVER[HTTP_HOST] would still equal www.example1.com Thanks Kevin Brad Fuller wrote: Hi, I am trying to have 1 template site and have an unlimited number of websites using this template site to call there own information. The sites are exactly the same except for the database, each of the sites also needs there own URL, for example one of these urls may be www.example1.com and the other www.example2.com. These sites are identical apart from the database they call to, one will call to a database called example1 and the other example2. I want another site (for example www.solution.com) to read what url has been entered and to pull in the database for that site (either example1 or example2) and show that information. I have tried using the CURL library without success (not sure how to use it fully) and have tried using frames but had loads of problems regarding losing session data. can anyone help? Thanks Kev Here's just an idea to give you maybe a starting point to go from... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Template Trouble
Sorry, made a mistake in that last post: "even if using frames on www.example1.com (using them to load www.solution.com) $_SERVER[HTTP_HOST] would still equal www.example1.com " It would actually equal www.solution.com once its in the frame as well not www.example1.com which is what i've put above. Thanks Brad Fuller wrote: Hi, I am trying to have 1 template site and have an unlimited number of websites using this template site to call there own information. The sites are exactly the same except for the database, each of the sites also needs there own URL, for example one of these urls may be www.example1.com and the other www.example2.com. These sites are identical apart from the database they call to, one will call to a database called example1 and the other example2. I want another site (for example www.solution.com) to read what url has been entered and to pull in the database for that site (either example1 or example2) and show that information. I have tried using the CURL library without success (not sure how to use it fully) and have tried using frames but had loads of problems regarding losing session data. can anyone help? Thanks Kev Here's just an idea to give you maybe a starting point to go from... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Template Trouble
Kevin, Are all these sites hosted on the same box? -Brad -Original Message- From: Kevin [mailto:[EMAIL PROTECTED] Sent: Thursday, October 26, 2006 9:37 AM To: php-general@lists.php.net Subject: Re: [PHP] PHP Template Trouble Hi Brad, That sounds like a good idea however: Where would config.php go? If it goes on the www.solution.com side of things, then $_SERVER[HTTP_HOST] will always be www.solution.com and if it goes on another then it would be www.example1.com. What you have put would be the kind of solution I am looking for but its the $_SERVER[HTTP_HOST] variable that would need to be posted through correctly, even if using frames on www.example1.com (using them to load www.solution.com) $_SERVER[HTTP_HOST] would still equal www.example1.com Thanks Kevin Brad Fuller wrote: >>> Hi, >>> >>> I am trying to have 1 template site and have an unlimited number of >>> websites using this template site to call there own information. >>> >>> The sites are exactly the same except for the database, each of the >>> sites also needs there own URL, for example one of these urls may be >>> www.example1.com and the other www.example2.com. These sites are >>> identical apart from the database they call to, one will call to a >>> database called example1 and the other example2. I want another site >>> (for example www.solution.com) to read what url has been entered and >>> to pull in the database for that site (either example1 or example2) >>> and show that information. I have tried using the CURL library >>> without success (not sure how to use it fully) and have tried using >>> frames but had loads of problems regarding losing session data. can >>> anyone help? >>> >>> Thanks >>> Kev >>> >>> > > > Here's just an idea to give you maybe a starting point to go from... > > // config.php > > $db_host = "localhost"; > $db_user = "foo"; > $db_pass = "bar"; > > switch($_SERVER["HTTP_HOST"]){ > case "www.example1.com": > $db_name = "example1"; > break; > Case "www.example2.com": > $db_name = "example2"; > break; > case "www.template.com": > $db_name = "template"; > break; > } > ?> > > // index.php > > include("config.php"); > > $link = mysql_connect($db_host, $db_user, $db_pass); > mysql_select_db($db_name); > > ... > > ?> > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Template Trouble
Yes all the sites are located on a Windows 2003 Dedicated Server. Kevin wrote: Sorry, made a mistake in that last post: "even if using frames on www.example1.com (using them to load www.solution.com) $_SERVER[HTTP_HOST] would still equal www.example1.com " It would actually equal www.solution.com once its in the frame as well not www.example1.com which is what i've put above. Thanks Brad Fuller wrote: Hi, I am trying to have 1 template site and have an unlimited number of websites using this template site to call there own information. The sites are exactly the same except for the database, each of the sites also needs there own URL, for example one of these urls may be www.example1.com and the other www.example2.com. These sites are identical apart from the database they call to, one will call to a database called example1 and the other example2. I want another site (for example www.solution.com) to read what url has been entered and to pull in the database for that site (either example1 or example2) and show that information. I have tried using the CURL library without success (not sure how to use it fully) and have tried using frames but had loads of problems regarding losing session data. can anyone help? Thanks Kev Here's just an idea to give you maybe a starting point to go from... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Template Trouble
Yes all the sites are located on a Windows 2003 Dedicated Server. Kevin Brad Fuller wrote: Kevin, Are all these sites hosted on the same box? -Brad -Original Message- From: Kevin [mailto:[EMAIL PROTECTED] Sent: Thursday, October 26, 2006 9:37 AM To: php-general@lists.php.net Subject: Re: [PHP] PHP Template Trouble Hi Brad, That sounds like a good idea however: Where would config.php go? If it goes on the www.solution.com side of things, then $_SERVER[HTTP_HOST] will always be www.solution.com and if it goes on another then it would be www.example1.com. What you have put would be the kind of solution I am looking for but its the $_SERVER[HTTP_HOST] variable that would need to be posted through correctly, even if using frames on www.example1.com (using them to load www.solution.com) $_SERVER[HTTP_HOST] would still equal www.example1.com Thanks Kevin Brad Fuller wrote: Hi, I am trying to have 1 template site and have an unlimited number of websites using this template site to call there own information. The sites are exactly the same except for the database, each of the sites also needs there own URL, for example one of these urls may be www.example1.com and the other www.example2.com. These sites are identical apart from the database they call to, one will call to a database called example1 and the other example2. I want another site (for example www.solution.com) to read what url has been entered and to pull in the database for that site (either example1 or example2) and show that information. I have tried using the CURL library without success (not sure how to use it fully) and have tried using frames but had loads of problems regarding losing session data. can anyone help? Thanks Kev Here's just an idea to give you maybe a starting point to go from... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How does the Zend engine behave?
Jon Anderson wrote: Take this with a grain of salt. I develop with PHP, but I am not an internals guy... [EMAIL PROTECTED] wrote: Are the include files only compiled when execution hits them, or are all include files compiled when the script is first compiled, which would mean a cascade through all statically linked include files. By statically linked files I mean ones like "include ('bob.php')" - i.e the filename isn't in a variable. Compiled when execution hits them. You can prove this by trying to conditionally include a file with a syntax error: if (false) include('script_with_syntax_error.php'); won't cause an error. Good idea. Secondly, are include files that are referenced, but not used, loaded into memory? I.e Are statically included files automatically loaded into memory at the start of a request? (Of course those where the name is variable can only be loaded once the name has been determined.) And when are they loaded into memory? When the instruction pointer hits the include? Or when the script is initially loaded? If your include file is actually included, it will use memory. If it is not included because of some condition, then it won't use memory. I wonder if that's the same when a cache/optimiser is used. Probably. Maybe I'll check. Are included files ever unloaded? For instance if I had 3 include files and no loops, once execution had passed from the first include file to the second, the engine might be able to unload the first file. Or at least the code, if not the data. If you define a global variable in an included file and don't unset it anywhere, then it isn't automatically "unloaded", nor are function/class definitions unloaded when execution is finished. Once you include a file, it isn't unloaded later though - even included files that have just executed statements (no definitions saved for later) seem to eat a little memory once, but it's so minimal that you wouldn't run into problems unless you were including many thousand files. Including the same file again doesn't eat further memory. I assume the eaten memory is for something to do with compilation or caching in the ZE. Thirdly, I understand that when a request arrives, the script it requests is compiled before execution. Now suppose a second request arrives for the same script, from a different requester, am I right in assuming that the uncompiled form is loaded? I.e the script is tokenized for each request, and the compiled version is not loaded unless you have engine level caching installed - e.g. MMCache or Zend Optimiser. I think that's correct. If you don't have an opcode cache, the script is compiled again for every request, regardless of who requests it. IMO, you're probably better off with PECL/APC or eAccelerator rather than MMCache or Zend Optimizer. I use APC personally, and find it exceptional -> rock solid + fast. (eAccelerator had a slight performance edge for my app up until APC's most recent release, where APC now has a significant edge.) Thanks - that's useful to know. Fourthly, am I right in understanding that scripts do NOT share memory, even for the portions that are simply instructions? That is, when the second request arrives, the script is loaded again in full. (As opposed to each request sharing the executed/compiled code, but holding data separately.) Yep, I think that's also correct. Fifthly, if a script takes 4MB, given point 4, does the webserver demand 8MB if it is simultaneously servicing 2 requests? Yep. More usually with webserver/PHP overhead. Lastly, are there differences in these behaviors for PHP4 and PHP5? Significant differences between 4 and 5, but with regards to the above, I think they're more or less the same. Thanks Jon. So in summary: use a cache if possible. Late load files to save memory. Buy more memory to handle more sessions. And it's conceivable that when caches are used, different rules may apply. Jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Template Trouble
Cool, then what you want to do is make all the domains point to the same directory, have your files index.php and config.php in that directory and it should work like magic. Then you end up with one copy of the files and how ever many sites you need. No frames, no duplicated code. It's been a long time (5+ years) since I worked with Windows/IIS, sorry I don't have more specific instructions on how to do the above. Hope that's enough to get you started in the right direction. -Brad -Original Message- From: Kevin [mailto:[EMAIL PROTECTED] Sent: Thursday, October 26, 2006 10:15 AM To: php-general@lists.php.net Subject: Re: [PHP] PHP Template Trouble Yes all the sites are located on a Windows 2003 Dedicated Server. Kevin Brad Fuller wrote: > Kevin, > > Are all these sites hosted on the same box? > > -Brad > > > > -Original Message- > From: Kevin [mailto:[EMAIL PROTECTED] > Sent: Thursday, October 26, 2006 9:37 AM > To: php-general@lists.php.net > Subject: Re: [PHP] PHP Template Trouble > > Hi Brad, > > That sounds like a good idea however: > > Where would config.php go? If it goes on the www.solution.com side of > things, then $_SERVER[HTTP_HOST] will always be www.solution.com and if > it goes on another then it would be www.example1.com. > > What you have put would be the kind of solution I am looking for but its > the $_SERVER[HTTP_HOST] variable that would need to be posted through > correctly, even if using frames on www.example1.com (using them to load > www.solution.com) $_SERVER[HTTP_HOST] would still equal www.example1.com > > Thanks > > Kevin > > Brad Fuller wrote: > Hi, I am trying to have 1 template site and have an unlimited number of websites using this template site to call there own information. The sites are exactly the same except for the database, each of the sites also needs there own URL, for example one of these urls may be www.example1.com and the other www.example2.com. These sites are identical apart from the database they call to, one will call to a database called example1 and the other example2. I want another site (for example www.solution.com) to read what url has been entered and to pull in the database for that site (either example1 or example2) and show that information. I have tried using the CURL library without success (not sure how to use it fully) and have tried using frames but had loads of problems regarding losing session data. can anyone help? Thanks Kev >> Here's just an idea to give you maybe a starting point to go from... >> >> > // config.php >> >> $db_host = "localhost"; >> $db_user = "foo"; >> $db_pass = "bar"; >> >> switch($_SERVER["HTTP_HOST"]){ >> case "www.example1.com": >> $db_name = "example1"; >> break; >> Case "www.example2.com": >> $db_name = "example2"; >> break; >> case "www.template.com": >> $db_name = "template"; >> break; >> } >> ?> >> >> > // index.php >> >> include("config.php"); >> >> $link = mysql_connect($db_host, $db_user, $db_pass); >> mysql_select_db($db_name); >> >> ... >> >> ?> >> >> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Template Trouble
But the dedicated server has security. In order to use it you must create accounts (these are your ftp accounts) so basically I have example mapped to www.example.com and example2 mapped to www.example2.com example's root dir would be along the lines of: c:\inetpub\www\example\htdocs example2's root dir would be c:\inetput\www\example2\htdocs Example2 cannot access the root dir of example because of the security, it gives a permission denied error and the same the other way around. Kevin Brad Fuller wrote: Cool, then what you want to do is make all the domains point to the same directory, have your files index.php and config.php in that directory and it should work like magic. Then you end up with one copy of the files and how ever many sites you need. No frames, no duplicated code. It's been a long time (5+ years) since I worked with Windows/IIS, sorry I don't have more specific instructions on how to do the above. Hope that's enough to get you started in the right direction. -Brad -Original Message- From: Kevin [mailto:[EMAIL PROTECTED] Sent: Thursday, October 26, 2006 10:15 AM To: php-general@lists.php.net Subject: Re: [PHP] PHP Template Trouble Yes all the sites are located on a Windows 2003 Dedicated Server. Kevin Brad Fuller wrote: Kevin, Are all these sites hosted on the same box? -Brad -Original Message- From: Kevin [mailto:[EMAIL PROTECTED] Sent: Thursday, October 26, 2006 9:37 AM To: php-general@lists.php.net Subject: Re: [PHP] PHP Template Trouble Hi Brad, That sounds like a good idea however: Where would config.php go? If it goes on the www.solution.com side of things, then $_SERVER[HTTP_HOST] will always be www.solution.com and if it goes on another then it would be www.example1.com. What you have put would be the kind of solution I am looking for but its the $_SERVER[HTTP_HOST] variable that would need to be posted through correctly, even if using frames on www.example1.com (using them to load www.solution.com) $_SERVER[HTTP_HOST] would still equal www.example1.com Thanks Kevin Brad Fuller wrote: Hi, I am trying to have 1 template site and have an unlimited number of websites using this template site to call there own information. The sites are exactly the same except for the database, each of the sites also needs there own URL, for example one of these urls may be www.example1.com and the other www.example2.com. These sites are identical apart from the database they call to, one will call to a database called example1 and the other example2. I want another site (for example www.solution.com) to read what url has been entered and to pull in the database for that site (either example1 or example2) and show that information. I have tried using the CURL library without success (not sure how to use it fully) and have tried using frames but had loads of problems regarding losing session data. can anyone help? Thanks Kev Here's just an idea to give you maybe a starting point to go from... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Template Trouble
Well, I'm sure there is a better way to do it, but this should work. config.php does not need to be dynamic in this scenario. 1. Copy index.php and config.php into each site's directory. 2. Change the $db_name variable in config.php to use the correct database. ".$_SERVER['HTTP_HOST'].""; print "This site is using the database name \"{$db_name}\""; print ""; ?> If you can't get it to work using this method, I give up :P Cheers ;) - Brad > -Original Message- > From: Kevin [mailto:[EMAIL PROTECTED] > Sent: Thursday, October 26, 2006 10:39 AM > To: php-general@lists.php.net > Subject: Re: [PHP] PHP Template Trouble > > But the dedicated server has security. In order to use it you must > create accounts (these are your ftp accounts) so basically I have > > example mapped to www.example.com > > and > > example2 mapped to www.example2.com > > example's root dir would be along the lines of: > c:\inetpub\www\example\htdocs > > example2's root dir would be c:\inetput\www\example2\htdocs > > Example2 cannot access the root dir of example because of the security, > it gives a permission denied error and the same the other way around. > > Kevin > > Brad Fuller wrote: > > Cool, then what you want to do is make all the domains point to the same > > directory, have your files index.php and config.php in that directory > and it > > should work like magic. > > > > Then you end up with one copy of the files and how ever many sites you > need. > > > > No frames, no duplicated code. > > > > It's been a long time (5+ years) since I worked with Windows/IIS, sorry > I > > don't have more specific instructions on how to do the above. > > > > Hope that's enough to get you started in the right direction. > > > > -Brad > > > > > > -Original Message- > > From: Kevin [mailto:[EMAIL PROTECTED] > > Sent: Thursday, October 26, 2006 10:15 AM > > To: php-general@lists.php.net > > Subject: Re: [PHP] PHP Template Trouble > > > > Yes all the sites are located on a Windows 2003 Dedicated Server. > > > > Kevin > > > > > > > > Brad Fuller wrote: > > > >> Kevin, > >> > >> Are all these sites hosted on the same box? > >> > >> -Brad > >> > >> > >> > >> -Original Message- > >> From: Kevin [mailto:[EMAIL PROTECTED] > >> Sent: Thursday, October 26, 2006 9:37 AM > >> To: php-general@lists.php.net > >> Subject: Re: [PHP] PHP Template Trouble > >> > >> Hi Brad, > >> > >> That sounds like a good idea however: > >> > >> Where would config.php go? If it goes on the www.solution.com side of > >> things, then $_SERVER[HTTP_HOST] will always be www.solution.com and if > >> it goes on another then it would be www.example1.com. > >> > >> What you have put would be the kind of solution I am looking for but > its > >> the $_SERVER[HTTP_HOST] variable that would need to be posted through > >> correctly, even if using frames on www.example1.com (using them to load > >> www.solution.com) $_SERVER[HTTP_HOST] would still equal > www.example1.com > >> > >> Thanks > >> > >> Kevin > >> > >> Brad Fuller wrote: > >> > >> > > Hi, > > > > I am trying to have 1 template site and have an unlimited number of > > websites using this template site to call there own information. > > > > The sites are exactly the same except for the database, each of the > > sites also needs there own URL, for example one of these urls may be > > www.example1.com and the other www.example2.com. These sites are > > identical apart from the database they call to, one will call to a > > database called example1 and the other example2. I want another site > > (for example www.solution.com) to read what url has been entered and > > to pull in the database for that site (either example1 or example2) > > and show that information. I have tried using the CURL library > > without success (not sure how to use it fully) and have tried using > > frames but had loads of problems regarding losing session data. can > > anyone help? > > > > Thanks > > Kev > > > > > > > > > >>> Here's just an idea to give you maybe a starting point to go from... > >>> > >>> >>> // config.php > >>> > >>> $db_host = "localhost"; > >>> $db_user = "foo"; > >>> $db_pass = "bar"; > >>> > >>> switch($_SERVER["HTTP_HOST"]){ > >>> case "www.example1.com": > >>> $db_name = "example1"; > >>> break; > >>> Case "www.example2.com": > >>> $db_name = "example2"; > >>> break; > >>> case "www.template.com": > >>> $db_name = "template"; > >>> break; > >>> } > >>> ?> > >>> > >>> >>> // index.php > >>> > >>> include("config.php"); > >>> > >>> $link = mysql_connect($db_host, $db_user, $db_pass); > >>> mysql_select_db($db_name); > >>> > >>> ... > >>> > >>> ?> > >>> > >>> > >>> > >> > >> > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php
Re: [PHP] PHP Template Trouble
Brad, I cant thank you enough!!! This has been getting to me for weeks. I simply moved the mapping of the URL's so that all the URL's point to the same website, i could then use that http _host to pick them up and then i've basically used this to query the database and give me what I want. It was so simple in the end but I never even thought about doing it this way, i knew there would be an easy solution though. It works perfectly, finally i can get some sleep.. now just got to get around to fixing all the installation! Well, I'm sure there is a better way to do it, but this should work. config.php does not need to be dynamic in this scenario. 1. Copy index.php and config.php into each site's directory. 2. Change the $db_name variable in config.php to use the correct database. ".$_SERVER['HTTP_HOST'].""; print "This site is using the database name \"{$db_name}\""; print ""; ?> If you can't get it to work using this method, I give up :P Cheers ;) - Brad -Original Message- From: Kevin [mailto:[EMAIL PROTECTED] Sent: Thursday, October 26, 2006 10:39 AM To: php-general@lists.php.net Subject: Re: [PHP] PHP Template Trouble But the dedicated server has security. In order to use it you must create accounts (these are your ftp accounts) so basically I have example mapped to www.example.com and example2 mapped to www.example2.com example's root dir would be along the lines of: c:\inetpub\www\example\htdocs example2's root dir would be c:\inetput\www\example2\htdocs Example2 cannot access the root dir of example because of the security, it gives a permission denied error and the same the other way around. Kevin Brad Fuller wrote: Cool, then what you want to do is make all the domains point to the same directory, have your files index.php and config.php in that directory and it should work like magic. Then you end up with one copy of the files and how ever many sites you need. No frames, no duplicated code. It's been a long time (5+ years) since I worked with Windows/IIS, sorry I don't have more specific instructions on how to do the above. Hope that's enough to get you started in the right direction. -Brad -Original Message- From: Kevin [mailto:[EMAIL PROTECTED] Sent: Thursday, October 26, 2006 10:15 AM To: php-general@lists.php.net Subject: Re: [PHP] PHP Template Trouble Yes all the sites are located on a Windows 2003 Dedicated Server. Kevin Brad Fuller wrote: Kevin, Are all these sites hosted on the same box? -Brad -Original Message- From: Kevin [mailto:[EMAIL PROTECTED] Sent: Thursday, October 26, 2006 9:37 AM To: php-general@lists.php.net Subject: Re: [PHP] PHP Template Trouble Hi Brad, That sounds like a good idea however: Where would config.php go? If it goes on the www.solution.com side of things, then $_SERVER[HTTP_HOST] will always be www.solution.com and if it goes on another then it would be www.example1.com. What you have put would be the kind of solution I am looking for but its the $_SERVER[HTTP_HOST] variable that would need to be posted through correctly, even if using frames on www.example1.com (using them to load www.solution.com) $_SERVER[HTTP_HOST] would still equal www.example1.com Thanks Kevin Brad Fuller wrote: Hi, I am trying to have 1 template site and have an unlimited number of websites using this template site to call there own information. The sites are exactly the same except for the database, each of the sites also needs there own URL, for example one of these urls may be www.example1.com and the other www.example2.com. These sites are identical apart from the database they call to, one will call to a database called example1 and the other example2. I want another site (for example www.solution.com) to read what url has been entered and to pull in the database for that site (either example1 or example2) and show that information. I have tried using the CURL library without success (not sure how to use it fully) and have tried using frames but had loads of problems regarding losing session data. can anyone help? Thanks Kev Here's just an idea to give you maybe a starting point to go from... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Template Trouble
I haven't used IIS for a while, but this should still be similar in the latest version... In the website properties hit the Advanced... button next to the IP address. IIRC the top box is labelled "Web Site Identities" or similar. You can add identities with the same IP address but a different host header for each domain. Requests for each domain will then be directed to that same site. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] heredoc usage [WAS:
At 1:04 AM -0700 10/26/06, Paul Novitski wrote: At 10/25/2006 11:24 PM, Robert Cummings wrote: I use a tag based template system, there's no PHP in my content so my content files for the most part just look like more HTML. This is a different topic, but also one close to my heart. Yes, I too use my own selector-based templating system. It does allow me to embed PHP variables into the template if I want, but the primary merge between plain HTML template and MySQL content happens through CSS-style selectors. I also embed php variables inside css -- it gives it more functionality. Hello , Cool. My comparable example (but in an HTML context) would look like: Hello FIRSTNAME, where the engine replaces the content of the span with the value from the database based on a match of 'span.firstName' or perhaps just '.firstName'. (In this example the 'FIRSTNAME' content in the template is merely a place-holder to make it easier to preview the markup and isn't necessary to the merge process.) I think a would work just as well -- seems so old-world to me. :-) However, if you used preg_match_all, I think you could do away with the spans all together by matching FIRSTNAME to your first name variable. That way your document would simply read: Hello FIRSTNAME Just an idea. 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] heredoc usage [WAS:
tedd wrote: I think a would work just as well -- seems so old-world to me. :-) The span element is in no way old-world. Spans and divs are two different things with different goals. A div is a block-level element, whereas spans are inline. Spans are intended for stylistic changes that span a chunk of text within a block. Divs are intended to describe the block. Not really relevant to the discussion, but worth pointing out. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP]
On Thu, October 26, 2006 8:31 am, Jochem Maas wrote: > bunch of space wasters ;-) > > $selDay?' > selected="selected"':''),'>',$d,''; ?> You messed up. :-) $d == $selDay would be the correct expression in the middle of that. My personal choice is: $last_day = 31; //calculated from date()/mktime() etc for ($day = 1; $day <= $last_day; $day++){ $selected = $chosen_day == $ ? 'selected="selected"' : ''; echo " $day\n"; } I don't *think* the w3c requires/recommends a value= in there, if the label *IS* the value, but can live with it either way... echo " $day\n"; is fine. I used to be distracted by \" but I've grown so used to it that it no longer bothers me in my reading flow, unless it's excessive and the expression spans multiple lines. Separation of logic and presentation is all very well, but this isn't even business logic. It's "presentation logic" which, to me, shouldn't be crammed into the complex business portion of my application. I'd much rather have the complex business logic focus on the application needs than the minutae of date formatting. It's all down to personal choice, though. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] exec("mysql -h hhh -u uuu -pppp
On Wed, October 25, 2006 2:41 pm, Gert Cuykens wrote: > i do not get any output from mysql except form echo $bin that displays > 1 ? > exec("mysql -h hhh -u uuu - print_r($out); > echo $bin; > ?> And what does 'perror 1' tell you on the command line? Or you could go whole-hog and install this: http://l-i-e.com/perror :-) -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How does the Zend engine behave?
On Wed, October 25, 2006 11:58 am, [EMAIL PROTECTED] wrote: > Are the include files only compiled when execution hits them, or are > all > include files compiled when the script is first compiled, which would > mean a cascade through all statically linked include files. By > statically linked files I mean ones like "include ('bob.php')" - i.e > the > filename isn't in a variable. As far as I know, the files are only loaded as execution hits them. If your code contains: Then foo.inc will never ever be read from the hard drive. You realize you could have tested this in less time than it took you to post, right?. :-) > Are included files ever unloaded? For instance if I had 3 include > files > and no loops, once execution had passed from the first include file to > the second, the engine might be able to unload the first file. Or at > least the code, if not the data. I doubt that the code is unloaded -- What if you called a function from the first file while you were in the second? > Thirdly, I understand that when a request arrives, the script it > requests is compiled before execution. Now suppose a second request > arrives for the same script, from a different requester, am I right in > assuming that the uncompiled form is loaded? I.e the script is > tokenized > for each request, and the compiled version is not loaded unless you > have > engine level caching installed - e.g. MMCache or Zend Optimiser. You are correct. The Caching systems such as Zend Cache (not the Optimizer), MMCache, APC, etc are expressly designed to store the tokenized version of the PHP script to be executed. Note that their REAL performance savings is actually in loading from the hard drive into RAM, not actually the PHP tokenization. Skipping a hard drive seek and read is probably at least 95% of the savings, even in the longest real-world scripts. The tokenizer/compiler thingie is basically easy chump change they didn't want to leave on the table, rather than the bulk of the performance "win". I'm sure somebody out there has perfectly reasonable million-line PHP script for a valid reason that the tokenization is more than 5% of the savings, but that's going to be a real rarity. > Fourthly, am I right in understanding that scripts do NOT share > memory, > even for the portions that are simply instructions? That is, when the > second request arrives, the script is loaded again in full. (As > opposed > to each request sharing the executed/compiled code, but holding data > separately.) Yes, without a cache, each HTTP request will load a "different" script. > Fifthly, if a script takes 4MB, given point 4, does the webserver > demand > 8MB if it is simultaneously servicing 2 requests? If you have a PHP script that is 4M in length, you've done something horribly wrong. :-) Of course, if it loads a 4M image file, then, yes, 2 at once needs 8M etc. > Lastly, are there differences in these behaviors for PHP4 and PHP5? I doubt it. I think APC is maybe going to be installed by default in PHP6 or something like that, but I dunno if it will be "on" by default or not... At any rate, not from 4 to 5. Note that if you NEED a monster body of code to be resident, you can prototype it in simple PHP, port it to C, and have it be a PHP extension. This should be relatively easy to do, if you plan fairly carefully. If a village idiot like me can write a PHP extension (albeit a dirt-simple one) then anybody can. :-) -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] heredoc usage [WAS:
On Thu, 2006-10-26 at 01:04 -0700, Paul Novitski wrote: > At 10/25/2006 11:24 PM, Robert Cummings wrote: > >Now, the thing that I dislike about heredoc for such small strings is > >the switching between heredoc mode and the switching back. It's ugly on > >the scale of switching in and out of PHP tags. > > It's so interesting that some details bug some people and others bug > others. In an expression such as this: > > echo '' . $day > . ''; HEY! what's with all those spaces around the dots? ;) > ...I count eight transitions (instances of switching between PHP > syntax and output text) -- one each time you open or close a quote -- > compared to just two transitions (the opening & closing labels) for > the comparable heredoc statement: > > print <<< hdDay > $day > > hdDay; > > > >it would be less ugly if > >the closing delimiter didn't have to be at the beginning of it's own > >line in which case code could still maintain indentation formatting. > > I agree. Too bad the PHP developers didn't come up with a special > symbol for heredoc closing labels to give us more control over script > formatting. I do however find this a fairly minor irritation, a > small price to pay for heredoc's power. > > > >To lighten the mess of heredoc I > >personally use the following format: > > > > $foo = <<<_ > ... > >_; > > Nice and concise! Thanks, I'll use that. > > > >However that's only useful if indenting the content is not an issue. > > I don't see how you draw that conclusion. Heredoc doesn't become > useless if we need to indent the content, it just means we lose > complete control over indenting every line of our PHP script. The > functionality is still totally there. Sorry, I should have re-iterated -- useful to my sense of aesthetics :D > > This script indenting issue with heredoc is for me one of the few > irritations of PHP. I love the language and the power that heredoc > gives me. I'm also irritated by the class member syntax $this->that > but I still use it as well. Oh yeah, in no way do i think that heredoc reduces PHP. I love PHP too, one of it's great attractions is the flexibility it gives to the developer while not being reduced to a pile of PERL resembling gibberish :) Mind you, some developers are extremely adept at making their code look like gibberish regardless. > > > I ask because I use heredoc all the time, sometimes for inline code > > > as above but most often for template assembly, maintaining HTML in > > > external files that can be edited independently of the PHP logic. > > > >I use a tag based template system, there's no PHP in my content so my > >content files for the most part just look like more HTML. > > This is a different topic, but also one close to my heart. Yes, I > too use my own selector-based templating system. It does allow me to > embed PHP variables into the template if I want, but the primary > merge between plain HTML template and MySQL content happens through > CSS-style selectors. > > > >Hello , > > Cool. > > My comparable example (but in an HTML context) would look like: > > Hello FIRSTNAME, > > where the engine replaces the content of the span with the value from > the database based on a match of 'span.firstName' or perhaps just > '.firstName'. (In this example the 'FIRSTNAME' content in the > template is merely a place-holder to make it easier to preview the > markup and isn't necessary to the merge process.) Out of curiosity is your template engine just a search and replace based on the span tags? Mine involves parsing out the tags and recompilation of tag generated content (so you can output template tags within a template tag). Tags can also load modules and provide meta logic. The following is an example of a form template: Username: Password: As you may be noticing, my template engine is a pull engine. Modules are pulled into play by the template and accessed via the render tags (the tag shows another way to access module fields). The exception is for the email example I formerly sent since the email module is instantiated for the email template by virtue of being loaded by the mail service -- but the email template can also load modules and can access any other custom tags created for the project. For instance I often have tags like the following: Some content Which means only a user with admin access will see the content. Also, for simplicity I'll have: Which will inject the firstName value of the currently logged in user. So basically, my code never references my templates, my templates just include modules themselves which makes the code far more re
Re: [PHP] heredoc usage [WAS:
On Thu, 2006-10-26 at 10:50 +0100, Arpad Ray wrote: > Incidentally, a nice side effect of heredoc is that some editors (like > vim) recognise << accordingly. That's really cool. Never even thought to do that. I wonder if anyone has done the footwork for joe to save me some time *hehe*. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How does the Zend engine behave?
On Thu, October 26, 2006 9:33 am, [EMAIL PROTECTED] wrote: >> If your include file is actually included, it will use memory. If it >> is not included because of some condition, then it won't use memory. > > I wonder if that's the same when a cache/optimiser is used. Probably. > Maybe I'll check. Almost for sure no PHP opcode cache attempts to load files that *might* be included later. That would be daft. :-) They load the file, tokenize it, and store the opcode output of the tokenizer for later re-execution. > Thanks Jon. So in summary: use a cache if possible. Late load files to > save memory. Buy more memory to handle more sessions. And it's > conceivable that when caches are used, different rules may apply. If your PHP source scripts themselves are chewing up large chunks of RAM, that's pretty unusual... -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP]
On Thu, 2006-10-26 at 15:31 +0200, Jochem Maas wrote: > bunch of space wasters ;-) > > $selDay?' > selected="selected"':''),'>',$d,''; ?> Specifically: > range(1, 31) Memory waster ;) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] any one can give an idea on this question ?
On Thu, October 26, 2006 6:36 am, Stut wrote: > Sancar Saran wrote: >> I just wondering this.. >> >> For example I had a several php pages. In this page there was an >> array named >> $arrHede >> >> It has lots of values. >> >> in index.php >> $arrHede['antin']='yada'; >> >> in config.php >> $arrHede['kuntin']='bada'; >> >> and so. >> >> So I want to write a scrpit check all those files to get all >> $arrHede keys. >> And I do not want to include those files because of errors. >> > > Maybe it's just me, but I didn't see a question anywhere in that lot, > just a statement of what you want to do. Seems obvious to me that you > need to open each file, find assignments to the $arrHede array and > pull > out the values. Have you even tried to do that yet? We're not here to > write scripts for you. Try it and come back if/when you have problems. Something like: grep -r -e "^\s\$arrHede\[[a-z0-9_]+\]\s=\s.*$" . | php might do it for you... I'm horrible at bash/regexp and escaping, but you get the idea. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] heredoc usage [WAS:
On Thu, 2006-10-26 at 11:24 -0400, tedd wrote: > At 1:04 AM -0700 10/26/06, Paul Novitski wrote: > >At 10/25/2006 11:24 PM, Robert Cummings wrote: > >>I use a tag based template system, there's no PHP in my content so my > >>content files for the most part just look like more HTML. > > > >This is a different topic, but also one close to my heart. Yes, I > >too use my own selector-based templating system. It does allow me > >to embed PHP variables into the template if I want, but the primary > >merge between plain HTML template and MySQL content happens through > >CSS-style selectors. > > I also embed php variables inside css -- it gives it more functionality. I embed them in the CSS template, which is compiled to a CSS stylesheet file and so the variables become static after compilation. This is useful if you're not determining values by any PHP logic, since then your stylesheet can be served up as a static document while retaining the flexibility of using variably defined values to generate the stylesheet. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] heredoc usage [WAS:
On Thu, 2006-10-26 at 11:43 +0200, clive wrote: > Paul Novitski wrote: > > It's so interesting that some details bug some people and others bug > > others. In an expression such as this: > > > > echo '' . $day . > > ''; > or you could write it likes this ' > echo " $day "; > > much easier to read, but slightly more taxing on the server. Also slightly more taxing on standards since single quotes are bad :) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Template Trouble
On Wed, October 25, 2006 4:49 am, Kevin wrote: > I am trying to have 1 template site and have an unlimited number of > websites using this template site to call there own information. > > The sites are exactly the same except for the database, each of the > sites also needs there own URL, for example one of these urls may be > www.example1.com and the other www.example2.com. These sites are > identical apart from the database they call to, one will call to a > database called example1 and the other example2. I want another site > (for example www.solution.com) to read what url has been entered and > to > pull in the database for that site (either example1 or example2) and > show that information. I have tried using the CURL library without > success (not sure how to use it fully) and have tried using frames but > had loads of problems regarding losing session data. can anyone help? Instead of focussing on the domain name, perhaps you should just connect to a different HOST in the database connection for the different sites. You might also want to consider using: example1.template.com example2.template.com and then you can use the sub-domain as your key to which database to use. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP]
On Thu, 2006-10-26 at 11:43 -0500, Richard Lynch wrote: > > $last_day = 31; //calculated from date()/mktime() etc > for ($day = 1; $day <= $last_day; $day++){ > $selected = $chosen_day == $ ? 'selected="selected"' : ''; > echo " $day\n"; > } > > I don't *think* the w3c requires/recommends a value= in there, if the > label *IS* the value, but can live with it either way... > echo " $day\n"; > is fine. >From the XHTML standard: http://www.w3.org/TR/html/#diffs We read the following: XML does not support attribute minimization. Attribute-value pairs must be written in full. Attribute names such as compact and checked cannot occur in elements without their value being specified. CORRECT: unminimized attributes INCORRECT: minimized attributes So even if you aren't using XHTML yet, it's wise to get into the practice. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP]
for ($i=1;$i<=31;$i++) : ?> >
Re: [PHP] [php] passing variables doesn't work
Every HTTP request is separate. Nothing is preserved from one to the next unless you program it to be preserved. You can pass around hidden inputs. You can use sessions. You can store stuff in the DB. You can use shared memory. But ain't nothing gonna get shared that you don't make it be shared. That's by DESIGN so that HTTP and PHP can "scale up" by just throwing more servers into a web farm. Any bottle-neck you create with your data-sharing is your bottle-neck, by your choice, with your architecture, that you have to fix when it breaks because you need to handle 100 million hits a second. It ain't PHP's or HTTP's problem, though, cuz they're designed to handle that by just buying more servers. :-) On Wed, October 25, 2006 2:46 am, WILLEMS Wim \(BMB\) wrote: > Dear all, > > I am trying to pass variables from one php-file to another but that > doesn't seem to work. Anyone an idea what I am doing wrong? > > The first file shows a dropdown with all the databases on the server > (only 1 for me). You have to select a database and put an SQL query in > the textarea. > Pushing "Execute query!" then calls the second file test2.php which > should put all the variables on the screen (first there was another > routine but that did not work, so I created this simple output to test > the veriables). > > > > PHP SQL Code Tester > > > > $host="localhost"; > $user="some_user"; > $password="some password"; > ?> > > Please select the database for the query: > > $wim = 5; /* this is added to test the passing of the variables - > doesn't work either */ > $link = mysql_connect($host, $user, $password) >or die(" Cannot connect : " . mysql_error()); > $db_table = mysql_list_dbs(); > > for ($i = 0; $i < mysql_num_rows($db_table); $i++) { > echo("" . mysql_tablename($db_table, $i)); > } > ?> > > Please input the SQL query to be executed: > > > > > > > > > This routine which is called with the routine above should print all > variables but it doesn't. Well, the routine itself works but the > variables are empty. > > > PHP SQL code tester > > > > echo "Dit is een test"; /* this is printed to the screen */ > echo "$wim"; /* this is NOT printed to the screen */ > echo "$host";/* only the is printed */ > echo "$database";/* only the is printed */ > echo "query: $query";/* only the is printed */ > echo "Dit is test 2";/* this is printed to the screen */ > ?> > > > > > Thanks for your help, > Wim. > > DISCLAIMER > http://www.proximus.be/maildisclaimer > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with EXEC and PASSTHRU
http://php.net/flush may be of interest. On Wed, October 25, 2006 2:35 am, Matt Beechey wrote: > I am writing a php website for users to edit a global whitelist for > Spam > Assassin - all is going fairly well considering I hadn't ever used php > until > a couple of days ago. My problem is I need to restart AMAVISD-NEW > after the > user saves the changes. I've acheived this using SUDO and giving the > www-data users the rights to SUDO amavisd-new. My problem is simply a > user > friendlyness issue - below is the code I'm running - > > if(isset($_POST["SAVE"])) > { > file_put_contents("/etc/spamassassin/whitelist.cf", > $_SESSION[whitelist]); > $_SESSION[count]=0; > echo "Restarting the service."; > exec('sudo /usr/sbin/amavisd-new reload'); > echo "Service was restarted.. Returning to the main page."; > sleep(4) > echo ''; > } > > The problem is that the Restarting the Service dialogue doesn't get > displayed until AFTER the Service Restarts even though it appears > before the > shell_exec command. I've tried exec and passthru and its always the > same - I > want it to display the "Service was restarted" - wait for 4 seconds > and then > redirect to the main page. Instead nothing happens on screen for the > browser > user until the service has restarted at which point they are returned > to > index.php - its as if the exec and the sleep and the refresh to > index.php > are all kind of running concurently. > > Can someone PLEASE tell me what I'm doing wrong - or shed light on how > I > should do this. > > Thanks, > > Matt > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] heredoc usage [WAS:
At 10/26/2006 08:24 AM, tedd wrote: At 1:04 AM -0700 10/26/06, Paul Novitski wrote: My comparable example (but in an HTML context) would look like: Hello FIRSTNAME, where the engine replaces the content of the span with the value from the database based on a match of 'span.firstName' or perhaps just '.firstName'. (In this example the 'FIRSTNAME' content in the template is merely a place-holder to make it easier to preview the markup and isn't necessary to the merge process.) I think a would work just as well -- seems so old-world to me. :-) By default, div is a block element and span is inline, so span seemed like the natural fit for a sentence fragment. I don't think there's anything old-world (!) about spans, Tedd, they're just tags. I use both in my markup with a clear conscience. However, if you used preg_match_all, I think you could do away with the spans all together by matching FIRSTNAME to your first name variable. That way your document would simply read: Hello FIRSTNAME That's true, and in tighly-defined micro-contexts that might work just fine. For a robust general CMS, though, I want a completely unambiguous demarcation of replacable content. All-caps tags will work in some circumstances but certainly won't in others. Regards, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] counting records in db
hi! what would be better solution to count records in table (e.g., how many customers have last name 'Smith'): $query = mysql_query(" SELECT COUNT(*) as NoOfRecords FROM customers WHERE last_name = 'Smith'"); $result = mysql_fetch_array($query); $NoOfRecords = $result['NoOfRecords']; OR $query = mysql_query(" SELECT cust_id FROM customers WHERE last_name = 'Smith'"); $NoOfRecords = mysql_num_rows($query); OR something else? Thanks. -afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counting records in db
$query = mysql_query(" SELECT COUNT(*) as NoOfRecords FROM customers WHERE last_name = 'Smith'"); $result = mysql_result($query, 0);
Re: [PHP] counting records in db
WOW! That was fast! :D Thanks Dave! -afan > $query = mysql_query(" >SELECT COUNT(*) as NoOfRecords >FROM customers >WHERE last_name = 'Smith'"); > $result = mysql_result($query, 0); > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Job postings?
On Tue, October 24, 2006 8:22 am, Steve Lane wrote: > I have a job posting for a junior PHP programmer. Are there any of the > PHP > mailing lists to which it would be appropriate to post that? PHP-General would be appropriate, I think, unless we get flooded with job offers. > If not, can anyone recommend a good place to post, especially a place > that > might be read by many people with specifically PHP skills? I would suggest that job postings that are non-telecommute should have the city/region in the Subject: line. Your local PHP User Group and Linux User Group are probably a better place for a non-telecommute job, actually. There are, of course, many job sites such as Dice and Monster that will let you post for a "small" fee. There is a nice list here of sites that publish PHP-related job opportunities: http://us2.php.net/links.php near the bottom of the page. Presumably those that are listed are the more active ones in PHP jobs. If that's where PHP job-seekers are looking, that's where you should consider posting. I would add craigslist to that list, though with craigslist you have to sift through job offers with "great ideas" which are completely unworkable and the pay scale is ludicrous. YMMV And, of course, your local head-hunters may be able to put decent candidates in front of you. Or not. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counting records in db
Hm. There is a little problem - this doesn't work. Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /var/www/html/xxx/tests/count.php on line 28 ? > $query = mysql_query(" >SELECT COUNT(*) as NoOfRecords >FROM customers >WHERE last_name = 'Smith'"); > $result = mysql_result($query, 0); > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Zip Question
Post a link to your on-line application. Also, use LiveHTTPHeaders and such to make sure you are getting what you think you are getting. And use vi or TextPad or whatever on your desktop to open up the .zip file and see what's in there. If it starts with: ERROR: PHP error blah blah blah then you've got a pretty good idea why it's not a valid zip file :-) On Tue, October 24, 2006 6:39 am, Matt Street wrote: > Dear all, > > I am trying to create a zipping mechanism that allows the user to > select a > number of files from a list; these files are then zipped and > downloaded to > the user's machine. I presently have: > > $zip = new ZipArchive(); > $filename = $zipfinalpath."tutor/zipfiles/".$tutorzipfile; > > if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) { > exit("cannot open <$filename> \n"); > } > else { > $loopCount = 0; > foreach ($filelisttozip as $i => $fileValue) { > //the > $zip->addFile($fileValue,$filenamelisttozip[$loopCount]); > $loopCount ++; > } > } > > $zip->close(); > > In my test sample of files I have the following file types: > > .doc > .zip > .jpg > .doc > > And the zip mechanism works when I ask for all or omit any of the > files from > the list, except when I omit the zip file! E.g. > > 1. Asking for all works > 2. Asking for .zip,.jpg,.doc works > 3. Asking for .doc,.zip works > 4. Asking for .doc,.jpg,.doc doesn't work - 7-zip tells me that the > file is > not support archive and windows tells me the Compressed(folder) is > invalid > or corrupted! > > I have used different zip files to make sure that it's not the file, > but all > to no avail. . .but if I add: > > $zip = zip_open($filename); > while ($zip_entry = zip_read($zip)) { > $file = basename(zip_entry_name($zip_entry)); > > echo 'a'.$file.''; > } > zip_close($zip); > > to the bottom of my page it correctly displays, on screen, the 3 files > I > expect to be in the zip file. > > Any help would be very gratefully received as this is driving me > mad!!! > > Matt > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counting records in db
At 10/26/2006 10:38 AM, [EMAIL PROTECTED] wrote: what would be better solution to count records in table (e.g., how many customers have last name 'Smith'): $query = mysql_query(" SELECT COUNT(*) as NoOfRecords FROM customers WHERE last_name = 'Smith'"); $result = mysql_fetch_array($query); $NoOfRecords = $result['NoOfRecords']; OR $query = mysql_query(" SELECT cust_id FROM customers WHERE last_name = 'Smith'"); $NoOfRecords = mysql_num_rows($query); My understanding of why COUNT() is the better solution is that mysql_num_rows() requires MySQL to cycle through the found records on a second pass to count them, whereas the first gathers the count during the first pass, the record-selection phase. Of course, if you also need to have the selected records accessible to a loop, using COUNT() will force you to execute two queries, one for the record count and one for the data themselves, so at that point the relative advantage is less clear. While we're talking about optimization, I'd want to check to make sure COUNT(*) didn't ask MySQL to generate a throw-away recordset consisting of all fields. I wonder if it would be more machine-efficient to use COUNT(`last_name`), specifying a single field, in this case the same field your query is examining anyway. Regards, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paginating searchs = performance problem
On Mon, October 23, 2006 8:58 pm, Chris wrote: > Richard Lynch wrote: >> On Fri, October 20, 2006 10:04 am, Fourat Zouari wrote: >>> I have PHP/PostgreSQL application were i got a search page with >>> some >>> items >>> to search, am building the search query on server side. >>> >>> I need to display a paginated search and for this i need to get the >>> total >>> count of lines matching the search before OFFSET/LIMITing my page, >>> am >>> i >>> obliged to repeat the query twice ??? first to get the total count, >>> second >>> to get my page. >>> >>> it's very heavy >>> >>> Any one's suggesting better doing ? >> >> Use a cursor. > > Cursors won't help - they don't store the info about how many results > the query would fetch (I asked this question a few months ago on one > of > the postgres lists). The Original Post made it sound like getting the total count was a means, not an end... :-) I believe the following is true: A PostgreSQL cursor doesn't store how many results it would fetch because it may not always even KNOW how many results it would fetch, because it may be able to avoid actually doing all the work to compute all the rows if it can prove that it has the correct first N rows to return when all you asked for was N so far. I won't swear to that in court, mind you, but I think they've got some optimizations that work that way... -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counting records in db
Sorry, my bad! It works jsut fine. I did misstake. :) >> >> >> > $query = mysql_query(" >> >SELECT COUNT(*) as NoOfRecords >> >FROM customers >> >WHERE last_name = 'Smith'"); >> > $result = mysql_result($query, 0); >> > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counting records in db
On Thu, October 26, 2006 12:57 pm, Paul Novitski wrote: >>$query = mysql_query(" >> SELECT COUNT(*) as NoOfRecords >> FROM customers >> WHERE last_name = 'Smith'"); >>$result = mysql_fetch_array($query); >>$NoOfRecords = $result['NoOfRecords']; This would be faster. Index on last_name will probably help a great deal. >>$query = mysql_query(" >> SELECT cust_id >> FROM customers >> WHERE last_name = 'Smith'"); >>$NoOfRecords = mysql_num_rows($query); This will be slower as MySQL/PHP have to store and maintain a dataset of all 'Smith' records. > My understanding of why COUNT() is the better solution is that > mysql_num_rows() requires MySQL to cycle through the found records on > a second pass to count them, whereas the first gathers the count > during the first pass, the record-selection phase. That too. > Of course, if you also need to have the selected records accessible > to a loop, using COUNT() will force you to execute two queries, one > for the record count and one for the data themselves, so at that > point the relative advantage is less clear. You'd have to test on your hardware and your dataset to see which is faster at that point, I think. And if the dataset is small enough to get the whole shebang, then you probably don't care. And if it's not, then you want LIMIT/OFFSET and then you want SQL_CALC_FOUND_ROWS or whatever it is with the mysql_num_rows() so you know how many rows there were without the LIMIT. > While we're talking about optimization, I'd want to check to make > sure COUNT(*) didn't ask MySQL to generate a throw-away recordset > consisting of all fields. I wonder if it would be more > machine-efficient to use COUNT(`last_name`), specifying a single > field, in this case the same field your query is examining anyway. count(*) is heavily optimized in MySQL, as I understand it. All this belongs on a MySQL list, not here, anyway. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP]
On Thu, October 26, 2006 12:14 pm, Robert Cummings wrote: > On Thu, 2006-10-26 at 11:43 -0500, Richard Lynch wrote: >> >> $last_day = 31; //calculated from date()/mktime() etc >> for ($day = 1; $day <= $last_day; $day++){ >> $selected = $chosen_day == $ ? 'selected="selected"' : ''; >> echo " $day\n"; >> } >> >> I don't *think* the w3c requires/recommends a value= in there, if >> the >> label *IS* the value, but can live with it either way... >> echo " $day\n"; >> is fine. > >>From the XHTML standard: > > http://www.w3.org/TR/html/#diffs > > We read the following: > > XML does not support attribute minimization. Attribute-value pairs > must be written in full. Attribute names such as compact and > checked > cannot occur in elements without their value being specified. > > CORRECT: unminimized attributes > > > > INCORRECT: minimized attributes > > > > So even if you aren't using XHTML yet, it's wise to get into the > practice. A) I see no need, now or ever, to use XHTML. B) What you are referencing has ZERO BEARING on the question of not having ANY value attribute at all, as far as I can see: 5 This does not have a minimized VALUE attribute. It has *NO* value attribute at all. :-) -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counting records in db
Would it be ok to use the same code to check if customer is loged in? $query = mysql_query(" SELECT COUNT(Username) as NoOfRecords FROM customers WHERE Username = '$Username' AND Password = '$Password'"); if (mysql_result($query, 0) == 0) { echo 'Please try again'; } else { header('location: index.php); exit; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP]
Wow, pretty aggressive. No reason to EVER use xhtml - hmmm, good attitude, good evolutionary sense. Let's wait and see. I believe the gent was referring to the use of 'selected="selected"' and trying to encourage good habits in someone - which I think is commendable. Why so angry?
Re: [PHP] counting records in db
Why would you want to do that? Think about what you're trying to do. In the first case you want a COUNT of records in the database, in the second you just want to see if the user/password combination or whatever exist, so just use a normal SELECT query, no need to use the wrong tool for the job...!
RE: [PHP] counting records in db
> Would it be ok to use the same code to check if customer is loged in? > > $query = mysql_query(" >SELECT COUNT(Username) as NoOfRecords >FROM customers >WHERE Username = '$Username' AND Password = '$Password'"); > if (mysql_result($query, 0) == 0) > { >echo 'Please try again'; > } > else > { >header('location: index.php); >exit; > } Assuming that the 'Username' field is unique, then the COUNT() is not necessary in this case as the number of returned results would never be greater than 1. A more reasonable approach would be something like this: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counting records in db
At 10/26/2006 11:16 AM, [EMAIL PROTECTED] wrote: Would it be ok to use the same code to check if customer is loged in? $query = mysql_query(" SELECT COUNT(Username) as NoOfRecords FROM customers WHERE Username = '$Username' AND Password = '$Password'"); if (mysql_result($query, 0) == 0) I'd question whether you really needed to get a record count. If your logon system is robust, each member will be listed only once; even if not, it's probably not the number of records you're interested in learning but whether or not there are any. I'd suffice with: SELECT Username FROM customers WHERE Username = '$Username' AND Password = '$Password' LIMIT 1,0; In a case like this, where I'm confident I have either one record or none, I'd be happy to use mysqsl_num_rows(). In the example above, which field you select is arbitrary, unless you actually want more information about the logged-on user: SELECT FirstName, LastName, SecurityLevel FROM customers WHERE Username = '$Username' AND Password = '$Password' LIMIT 1,0; Regards, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counting records in db
>>Would it be ok to use the same code to check if customer is loged in? >> >>$query = mysql_query(" >>SELECT COUNT(Username) as NoOfRecords >>FROM customers >>WHERE Username = '$Username' AND Password = >> '$Password'"); >>if (mysql_result($query, 0) == 0) I just realized that the answer I already got in previous answers :) Didn't pay an atention! :) Thanks. -afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP]
On Thu, 2006-10-26 at 13:13 -0500, Richard Lynch wrote: > On Thu, October 26, 2006 12:14 pm, Robert Cummings wrote: > > On Thu, 2006-10-26 at 11:43 -0500, Richard Lynch wrote: > >> > >> $last_day = 31; //calculated from date()/mktime() etc > >> for ($day = 1; $day <= $last_day; $day++){ > >> $selected = $chosen_day == $ ? 'selected="selected"' : ''; > >> echo " $day\n"; > >> } > >> > >> I don't *think* the w3c requires/recommends a value= in there, if > >> the > >> label *IS* the value, but can live with it either way... > >> echo " $day\n"; > >> is fine. > > > >>From the XHTML standard: > > > > http://www.w3.org/TR/html/#diffs > > > > We read the following: > > > > XML does not support attribute minimization. Attribute-value pairs > > must be written in full. Attribute names such as compact and > > checked > > cannot occur in elements without their value being specified. > > > > CORRECT: unminimized attributes > > > > > > > > INCORRECT: minimized attributes > > > > > > > > So even if you aren't using XHTML yet, it's wise to get into the > > practice. > > A) I see no need, now or ever, to use XHTML. YMMV. > B) What you are referencing has ZERO BEARING on the question of not > having ANY value attribute at all, as far as I can see: > 5 > This does not have a minimized VALUE attribute. > It has *NO* value attribute at all. Ahh, I just re-read your email, and well... I need to go drink some coffee :) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP]
Richard Lynch wrote: > On Thu, October 26, 2006 8:31 am, Jochem Maas wrote: >> bunch of space wasters ;-) >> >> > $selDay?' >> selected="selected"':''),'>',$d,''; ?> > > You messed up. :-) dang :-P try again: function genDayOptionTags($c = 31, $sv = 0, $eco = 1) { $o = ''; foreach (range(1, $c) as $d) $o .= '',$d,''; if ($eco) echo $o; return $o; } genMonthSelectTag($m = 1, $sv = 0, $attrs = array(), $eco = 1) { // allowed attribs static $dattr = array('name' => 1, 'id' => 1, 'class' => 1, 'name' => 1,); // speedy literal for looking up number of days static $h = array(1,2,3,4,5,6,7,8,9,10,11,12); // 'normalize' month (13 -> 1, 14 -> 2, 15 -> 3, etc) $m -= ((intval($m) % 12) * 12); // php5.1.0RC1 or higher for array_intersect_key // otherwise STW for a userland variant (PEAR)? $attrs = array_intersect_key($attrs, $dattrs); foreach ($attrs as $k => $v) $attrs[$k] = $v ? "{$k}=\"{$v}\"": ''; $o = ' echo " $day\n"; > } lately I have been fond of dropping braces around single if/foreach expressions, I like the fact it makes the code compacter. > > I don't *think* the w3c requires/recommends a value= in there, if the > label *IS* the value, but can live with it either way... > echo " $day\n"; > is fine. > > I used to be distracted by \" but I've grown so used to it that it no > longer bothers me in my reading flow, unless it's excessive and the > expression spans multiple lines. I know that feeling. :-) > > Separation of logic and presentation is all very well, but this isn't > even business logic. It's "presentation logic" which, to me, > shouldn't be crammed into the complex business portion of my > application. here, here. > > I'd much rather have the complex business logic focus on the > application needs than the minutae of date formatting. quite, why would business logic need to deal with anything other than a timestamp (+zone) ? > > It's all down to personal choice, though. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: DATETIME or UNIX TIMESTAMPS?
I use always unix timestamp as well, except in birth date. ""Marcelo de Moraes Serpa"" <[EMAIL PROTECTED]> escreveu na mensagem news:[EMAIL PROTECTED] > Hello list, > > I've always used Unix Timestamps until now, but lately I've reading about > MySQL's datetime datatype and its benefits (dates before 1970, after 2030, > SQL functions to deal with them, etc). However, I don't see much support > for > them in the PHP API. I'm also a Flash programmer and the Flash 8 API Date > datatype also only understands unix timestamps. Taking this into account, > I'm not really sure if it really worths it to "move" to the DATETIME > datatype. What would you do? Any advice would be much appreciated! > > Marcelo. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] DATETIME or UNIX TIMESTAMPS?
Hello list, I've always used Unix Timestamps until now, but lately I've reading about MySQL's datetime datatype and its benefits (dates before 1970, after 2030, SQL functions to deal with them, etc). However, I don't see much support for them in the PHP API. I'm also a Flash programmer and the Flash 8 API Date datatype also only understands unix timestamps. Taking this into account, I'm not really sure if it really worths it to "move" to the DATETIME datatype. What would you do? Any advice would be much appreciated! Marcelo.
Re: [PHP]
Robert Cummings wrote: > On Thu, 2006-10-26 at 15:31 +0200, Jochem Maas wrote: >> bunch of space wasters ;-) >> >> > $selDay?' >> selected="selected"':''),'>',$d,''; ?> > > Specifically: > >> range(1, 31) > > Memory waster ;) any idea as to what the damage is as compared to the classic for loop? > > Cheers, > Rob. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] natsort()
Hi php5 $d = '/somedir/subdir'; $od = opendir($d); if ($od) { $dl = scandir($d); natsort($dl); } The sorted array is available through print_r(). How can I obtain a natsorted array that can be listed using : while ($i <= $array_count){print $dl[$i]} Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] natsort()
natsort() places the array elements in natural order but not the keys. If you want your elements printed using "print" in a loop either reorganise the keys first or use "foreach". The easiest method would be to use: foreach($dl as $filename){ print $filename; } If you insist on using a while loop you could use: $dl = array_merge($dl); to reorder the keys from 0 to array size-1. then use: while ($i <= $array_count){print $dl[$i]; $i++;} If you use "while" you must increment $i to get all of the elements printed. Alternatively you could use a for loop after reordering the keys: for($i=0;$i Hi php5 $d = '/somedir/subdir'; $od = opendir($d); if ($od) { $dl = scandir($d); natsort($dl); } The sorted array is available through print_r(). How can I obtain a natsorted array that can be listed using : while ($i <= $array_count){print $dl[$i]} Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] session id contains illegal characters
hey all, I'm moving my page from php4 to php5 and I get this error: Warning: Unknown: The session id contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0 this is the code I use to start my session: $_SESSION['user_id']=$user_id; $_SESSION['user_login']=$user_login; $_SESSION['user_pass']=$user_pass; $_SESSION['user_level']=$user_level; $_SESSION['session_bool']="true"; $sessionid = session_id(); $_SESSION['session_id']= $sessionid; $user_real_id=$_SESSION['user_id']; $user_real_login=$_SESSION['user_login']; $realsessionid = $_SESSION['session_id']; any idea what's wrong? thanx in advance Pat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Running a Java Program
Hello List, I have a situation where, when the user logs into the system (Apache 2/PHP 5.1/Win XP) the php script should activate a Java program to run in the background. This program will keep running in the background while everytime the user requests something, the subsequent php scripts communicates with this Java program on a preassigned port. (This is for controlling a robot I descibed in on of my earlier mails) My questions are: 1. How do I make the Java program to keep running even after the PHP script terminates. In Linux I would have easily done using '&' - how about windows? 2. What is the safest way to do it? Thanks in advance. Prathap P.S - Richard & Tedd - I appreciate your comments on my previous issue. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Running a Java Program
On Thursday 26 October 2006 6:48 pm, Prathaban Mookiah wrote: > Hello List, > > I have a situation where, when the user logs into the system (Apache 2/PHP > 5.1/Win XP) the php script should activate a Java program to run in the > background. This program will keep running in the background while > everytime the user requests something, the subsequent php scripts > communicates with this Java program on a preassigned port. (This is for > controlling a robot I descibed in on of my earlier mails) > > My questions are: > > 1. How do I make the Java program to keep running even after the PHP script > terminates. In Linux I would have easily done using '&' - how about > windows? > > 2. What is the safest way to do it? > > > Thanks in advance. > > Prathap > > P.S - Richard & Tedd - I appreciate your comments on my previous issue. Does the Java program HAVE to be started by a script? I've worked in a few places that had desktop apps that would just run on startup, or a service, and then the webserver/php would communicate to it since it's already running. The downside to that is manual intervention when the program stops. Although... you could probably to an exec() and if it was installed as a service you should be able to run "net start ' (or something like that. I haven't kept up on your previous post so I may be completely wrong ;) -- Ray Hauge Application Development Lead American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File extension for PHP's serialization format?
I have a web application (not written in PHP) that can return data in various formats, including JSON and PHP's serialization format. At the moment my URL scheme looks like this: staff/engineering?format=json but I'd like to switch to using a file extension to denote the format: staff/engineering.json But what file extension should I use for PHP's serialization format? Obviously it can't be .php - aside from being inaccurate (it's not PHP code), using this extension would probably trigger the web server into trying to run a (nonexistent) PHP script. Thanks, Hamish Lawson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Running a Java Program
Ray, Nope - I cannot have the program running all the time because the port that it this program will connect to will be accessed by other programs too. So it needs to run only when the user is online and logged into the system. Any ideas? Prathap -- Original Message --- From: Ray Hauge <[EMAIL PROTECTED]> To: php-general@lists.php.net Cc: "Prathaban Mookiah" <[EMAIL PROTECTED]> Sent: Thu, 26 Oct 2006 18:39:26 -0500 Subject: Re: [PHP] Running a Java Program > On Thursday 26 October 2006 6:48 pm, Prathaban Mookiah wrote: > > Hello List, > > > > I have a situation where, when the user logs into the system (Apache 2/PHP > > 5.1/Win XP) the php script should activate a Java program to run in the > > background. This program will keep running in the background while > > everytime the user requests something, the subsequent php scripts > > communicates with this Java program on a preassigned port. (This is for > > controlling a robot I descibed in on of my earlier mails) > > > > My questions are: > > > > 1. How do I make the Java program to keep running even after the PHP script > > terminates. In Linux I would have easily done using '&' - how about > > windows? > > > > 2. What is the safest way to do it? > > > > > > Thanks in advance. > > > > Prathap > > > > P.S - Richard & Tedd - I appreciate your comments on my previous issue. > > Does the Java program HAVE to be started by a script? I've worked > in a few places that had desktop apps that would just run on startup, > or a service, and then the webserver/php would communicate to it > since it's already running. The downside to that is manual > intervention when the program stops. Although... you could probably > to an exec() and if it was installed as a service you should be able > to run "net start ' (or something like that. > > I haven't kept up on your previous post so I may be completely wrong > ;) > > -- > Ray Hauge > Application Development Lead > American Student Loan Services > www.americanstudentloan.com > 1.800.575.1099 > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php --- End of Original Message --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File extension for PHP's serialization format?
Hamish Lawson wrote: I have a web application (not written in PHP) that can return data in various formats, including JSON and PHP's serialization format. At the moment my URL scheme looks like this: staff/engineering?format=json but I'd like to switch to using a file extension to denote the format: staff/engineering.json But what file extension should I use for PHP's serialization format? Obviously it can't be .php - aside from being inaccurate (it's not PHP code), using this extension would probably trigger the web server into trying to run a (nonexistent) PHP script. You can rewrite the url using mod_rewrite or some such variant to handle this. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Running a Java Program
On Thursday 26 October 2006 7:28 pm, Prathaban Mookiah wrote: > Ray, > > Nope - I cannot have the program running all the time because the port that > it this program will connect to will be accessed by other programs too. So > it needs to run only when the user is online and logged into the system. > > Any ideas? > > Prathap > I kind of mentioned it before, but what about making the java program a service? Then you could exec()/shell_exec() "net start" or "net stop" as needed. Beyond that I don't have any ideas without checking Google. -- Ray Hauge Application Development Lead American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File extension for PHP's serialization format?
Hello Chris Thanks for responding. > But what file extension should I use for PHP's serialization format? > Obviously it can't be .php - aside from being inaccurate (it's not PHP > code), using this extension would probably trigger the web server into > trying to run a (nonexistent) PHP script. You can rewrite the url using mod_rewrite or some such variant to handle this. Yes, there may well be ways to get round what the web server would otherwise do when it encounters a .php extension, but I feel that I'd be breaking an expectation. I'd much rather use an extension that was specific to the serialization format. Hamish -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How does the Zend engine behave?
Richard Lynch wrote: On Wed, October 25, 2006 11:58 am, [EMAIL PROTECTED] wrote: Are the include files only compiled when execution hits them, or are all include files compiled when the script is first compiled, which would mean a cascade through all statically linked include files. By statically linked files I mean ones like "include ('bob.php')" - i.e the filename isn't in a variable. As far as I know, the files are only loaded as execution hits them. If your code contains: Then foo.inc will never ever be read from the hard drive. You realize you could have tested this in less time than it took you to post, right?. :-) I don't know the extent to which the engine optimises performance, and I know very little about how different versions of the engine deal with the issue, but I guessed it depended on the behaviour of the engine, cache and maybe optimiser, and know/knew I don't know enough... My thinking: for dynamically linked files, one speed optimisation is to load the file before it's needed, at the expense of memory, while continuing execution of the loaded portions. It's easy to do if the filename is static. The code may never be executed, but still takes up space. Some data structures can also be pre-loaded in this way. Are included files ever unloaded? For instance if I had 3 include files and no loops, once execution had passed from the first include file to the second, the engine might be able to unload the first file. Or at least the code, if not the data. I doubt that the code is unloaded -- What if you called a function from the first file while you were in the second? I agree it's unlikely, but it's feasible if coded is loaded whenever required. Especially if data and code are separated by the engine, and that's quite likely because of the garbage collection. Thirdly, I understand that when a request arrives, the script it requests is compiled before execution. Now suppose a second request arrives for the same script, from a different requester, am I right in assuming that the uncompiled form is loaded? I.e the script is tokenized for each request, and the compiled version is not loaded unless you have engine level caching installed - e.g. MMCache or Zend Optimiser. You are correct. The Caching systems such as Zend Cache (not the Optimizer), MMCache, APC, etc are expressly designed to store the tokenized version of the PHP script to be executed. Note that their REAL performance savings is actually in loading from the hard drive into RAM, not actually the PHP tokenization. Skipping a hard drive seek and read is probably at least 95% of the savings, even in the longest real-world scripts. The tokenizer/compiler thingie is basically easy chump change they didn't want to leave on the table, rather than the bulk of the performance "win". I'm sure somebody out there has perfectly reasonable million-line PHP script for a valid reason that the tokenization is more than 5% of the savings, but that's going to be a real rarity. Thanks - that's really useful - I didn't realise that the bulk of the saving wasn't in tokenising. Fourthly, am I right in understanding that scripts do NOT share memory, even for the portions that are simply instructions? That is, when the second request arrives, the script is loaded again in full. (As opposed to each request sharing the executed/compiled code, but holding data separately.) Yes, without a cache, each HTTP request will load a "different" script. Do you know if, when a cache is used, whether requests in the same thread use the same in-memory object. I.e. Is the script persistent in the thread? Fifthly, if a script takes 4MB, given point 4, does the webserver demand 8MB if it is simultaneously servicing 2 requests? If you have a PHP script that is 4M in length, you've done something horribly wrong. :-) Sort of. I'm using Drupal with lots of modules loaded. PHP memory_limit is set to 20MB, and at times 20MB is used. I think that works per request. All the evidence points to that. So 10 concurrent requests, which is not unrealistic, it could use 400MB + webserver overhead. And I still want to combine it with another bit of software that will use 10 to 15MB per request. It's time to think about memory usage and whether there are any strategies to disengage memory usage from request rate. Of course, if it loads a 4M image file, then, yes, 2 at once needs 8M etc. Lastly, are there differences in these behaviors for PHP4 and PHP5? I doubt it. I think APC is maybe going to be installed by default in PHP6 or something like that, but I dunno if it will be "on" by default or not... At any rate, not from 4 to 5. Thanks. Note that if you NEED a monster body of code to be resident, you can prototype it in simple PHP, port it to C, and have it be a PHP extension. A good idea, but not feasible in this situation. Thank you. Jeff This should
Re: [PHP] File extension for PHP's serialization format?
Hamish Lawson wrote: Hello Chris Thanks for responding. > But what file extension should I use for PHP's serialization format? > Obviously it can't be .php - aside from being inaccurate (it's not PHP > code), using this extension would probably trigger the web server into > trying to run a (nonexistent) PHP script. You can rewrite the url using mod_rewrite or some such variant to handle this. Yes, there may well be ways to get round what the web server would otherwise do when it encounters a .php extension, but I feel that I'd be breaking an expectation. I'd much rather use an extension that was specific to the serialization format. You could "convert" it to a php file: RewriteCond %{REQUEST_URI} *.json RewriteRule ^(.*).json$ json.php?$1 [T=application/x-httpd-php,L] Might not work straight away but that should give you an idea of what's possible. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Job Opening
On Wednesday 25 October 2006 22:15, Larry Garfield wrote: > Well since the consensus seemed to be to allow job postings, I'll make > one. :-) > > My company is looking for a few good PHP programmers. > > We are a Chicago-area web consulting firm developing web sites and web > applications for a variety of clients, including several large academic > institutions. We are looking for skilled PHP developers to join our team. > (Sorry, that means yes, you'd have to work with me.) It's a small but > growing company of less than 10 people, all fairly young and geeky. :-) > Experience with PHP (although not necessarily prior work experience) is a > must. > > If interested, contact me OFF-LIST for more information. Note: I am NOT in > a hiring position, so do NOT send me your resume. :-) I'm just going to > pass you on to the person who is. As a follow-up, since several people have asked: We are looking for permanent legal US residents only, and primarily for people that can work on-site rather than telecommute. We are open to hearing from off-site people who can consult for future reference, however. -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DATETIME or UNIX TIMESTAMPS?
On Thursday 26 October 2006 15:36, Marcelo de Moraes Serpa wrote: > Hello list, > > I've always used Unix Timestamps until now, but lately I've reading about > MySQL's datetime datatype and its benefits (dates before 1970, after 2030, > SQL functions to deal with them, etc). However, I don't see much support > for them in the PHP API. I'm also a Flash programmer and the Flash 8 API > Date datatype also only understands unix timestamps. Taking this into > account, I'm not really sure if it really worths it to "move" to the > DATETIME datatype. What would you do? Any advice would be much appreciated! > > Marcelo. I tend to stick to unix timestamps as well, because date formats are completely unstandard between different SQL databases. MySQL's date futzing functions are nice, but they're different than Postgres', which are different than Oracle's, etc. Generally, most of the the math I need to do I can do in PHP either before or after grabbing the timestamp. I am sure there is a counter point, but this for what I do I just stick to timestamps. :-) -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How does the Zend engine behave?
On Thursday 26 October 2006 20:28, [EMAIL PROTECTED] wrote: > > If you have a PHP script that is 4M in length, you've done something > > horribly wrong. :-) > > Sort of. I'm using Drupal with lots of modules loaded. PHP memory_limit > is set to 20MB, and at times 20MB is used. I think that works per > request. All the evidence points to that. So 10 concurrent requests, > which is not unrealistic, it could use 400MB + webserver overhead. And I > still want to combine it with another bit of software that will use 10 > to 15MB per request. It's time to think about memory usage and whether > there are any strategies to disengage memory usage from request rate. Drupal tends to use about 10 MB of memory in normal usage for a reasonable set of modules in my experience, but a crapload more on the admin/modules page because it has to load everything in order to do so. Normally you won't hit that page very often. :-) However, Drupal is deliberately friendly toward APC. I don't recall the stats (I know someone made some pretty graphs at one point, but I can't find them), but simply throwing APC at Drupal should give you a hefty hefty performance boost. I believe APC does cache-one-run-many, so the code, at least, will only be stored in RAM once rather than n times. (Richard is correct, though, that data is generally larger than code in most apps.) Also, search the Drupal forums for something called "Split mode". It was something chx was putting together a while back. I don't know what it's status is, but he claimed to get a nice performance boost out of it. Cheers. -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem compiling PHP 4.4.2 with mcrypt
I have to get a temporary server in place under a tight time frame and am using a pre-existing server that wasn't configured really for hosting websites. I've upgraded all the services on it like going from Apache 1.3.x to Apache 2.0.59 and PHP from it's old version to 4.4.2 however I need to have mcrypt compiled with PHP and I'm running into a problem. If I compile PHP without mcrypt I can install PHP without issue. However, when I try to compile PHP with --with-mcrypt=/usr/local/mcrypt I get the following error: main/internal_functions.lo -lcrypt -lcrypt -lmcrypt -lltdl -lresolv -lm -ldl -lnsl -lcrypt -lcrypt -o libphp4.la /usr/lib/gcc-lib/i486-suse-linux/3.2/../../../../i486-suse-linux/bin/ld: cannot find -lltdl collect2: ld returned 1 exit status make: *** [libphp4.la] Error 1 Now I went back and compiled without mcrypt and looked for that line and this is what was there: main/internal_functions.lo -lcrypt -lcrypt -lresolv -lm -ldl -lnsl -lcrypt -lcrypt -o libphp4.la I see that along with -lmcrypt not being there neither is -lltdl is there something I'm missing? Do I need to have something else installed on the box? Normally I haven't had this problem with this. But this is an old suse 8.x box that is being used due to time frame issues. Like I said I can compile PHP without mcrypt, but the project requires mcrypt so any help on this would be appreciated. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Job Opening
This one time, at band camp, Larry Garfield <[EMAIL PROTECTED]> wrote: > My company is looking for a few good PHP programmers. 8<--- snip - > > As a follow-up, since several people have asked: ---8< --- snip - How much?? Kevin -- "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem compiling PHP 4.4.2 with mcrypt
Tom Ray [Lists] wrote: I have to get a temporary server in place under a tight time frame and am using a pre-existing server that wasn't configured really for hosting websites. I've upgraded all the services on it like going from Apache 1.3.x to Apache 2.0.59 and PHP from it's old version to 4.4.2 however I need to have mcrypt compiled with PHP and I'm running into a problem. If I compile PHP without mcrypt I can install PHP without issue. However, when I try to compile PHP with --with-mcrypt=/usr/local/mcrypt I get the following error: main/internal_functions.lo -lcrypt -lcrypt -lmcrypt -lltdl -lresolv -lm -ldl -lnsl -lcrypt -lcrypt -o libphp4.la /usr/lib/gcc-lib/i486-suse-linux/3.2/../../../../i486-suse-linux/bin/ld: cannot find -lltdl collect2: ld returned 1 exit status make: *** [libphp4.la] Error 1 Now I went back and compiled without mcrypt and looked for that line and this is what was there: main/internal_functions.lo -lcrypt -lcrypt -lresolv -lm -ldl -lnsl -lcrypt -lcrypt -o libphp4.la I see that along with -lmcrypt not being there neither is -lltdl is there something I'm missing? Do I need to have something else installed on the box? Normally I haven't had this problem with this. But this is an old suse 8.x box that is being used due to time frame issues. Like I said I can compile PHP without mcrypt, but the project requires mcrypt so any help on this would be appreciated. Looks like mcrypt has an extra dependency. Do you have the mcrypt-dev or mcrypt-devel package installed (whatever suse calls it) ? When I just went to install mcrypt on my debian machine it added "libltdl3" to the list of packages it needed. Do you have that one installed? How come you're compiling and not installing the package(s) ? Is suse too old to be able to install 4.4.2? Last question :P how come you're installing 4.4.2 and not the latest - 4.4.4 ? -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How does the Zend engine behave?
The Caching systems such as Zend Cache (not the Optimizer), MMCache, APC, etc are expressly designed to store the tokenized version of the PHP script to be executed. Note that their REAL performance savings is actually in loading from the hard drive into RAM, not actually the PHP tokenization. Skipping a hard drive seek and read is probably at least 95% of the savings, even in the longest real-world scripts. Interesting. If PHP tokenization is such a small cost, what makes a special caching system better than the OS for caching files in memory after the first disk read? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Job Opening
Kevin Waterson wrote: This one time, at band camp, Larry Garfield <[EMAIL PROTECTED]> wrote: > My company is looking for a few good PHP programmers. 8<--- snip - As a follow-up, since several people have asked: ---8< --- snip - How much?? My guess - $27 total :P If you really want to know, ask off list please. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How does the Zend engine behave?
Sean Pringle wrote: >> The Caching systems such as Zend Cache (not the Optimizer), MMCache, >> APC, etc are expressly designed to store the tokenized version of the >> PHP script to be executed. >> >> Note that their REAL performance savings is actually in loading from >> the hard drive into RAM, not actually the PHP tokenization. >> >> Skipping a hard drive seek and read is probably at least 95% of the >> savings, even in the longest real-world scripts. > > Interesting. If PHP tokenization is such a small cost, what makes a > special caching system better than the OS for caching files in memory > after the first disk read? APC actually executes the opcodes directly in shared memory, so unlike a disk cache, you are not copying lots of stuff around. APC does need to copy some things down into process-local memory, but most can be left where it is. Disk caches also tend to expire pretty fast because everything your OS does tends to touch the disk and when you application starts eating memory your disk cache is the first to go when things get tight. With a dedicated shared memory segment that won't happen. Things will stay put. It is also possible to run APC in no-stat mode which means it will never touch the disk at all. If you are on an Intel cpu with an older OS like freebsd4, disk-touching syscalls are massively slow and you can gain a lot by skipping the up-to-date stat check on each request and include file. Finally the compiler does more than just tokenize your script. It will cache functions and classes when it can and rewrite the opcodes so these functions and classes won't have to be created at execution time. Of course, that assumes you haven't gone all framework-crazy and made everything dynamic with autoload or weird conditional function and class declarations. If it becomes a runtime decision whether class or a function is declared, or heaven forbid, the same class takes on different signatures based on some runtime condition, then there isn't much the compiler can do to speed that up. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Shopping Cart
Hi, A client has requested a cart with the following features, any leads on such a package, preferably open-source? Is there a way to add things like: •Customer ratings to the cart? •Qualifying criteria: Is there a way to add that to the cart as a checkbox with descriptor? For example, if someone's selling a monitor that's made with no toxic materials and 50% recycled plastic, the administrator would check a box that says "no toxic" and another that says "recycled" and then add a descriptor for the recycled button that gives the amount of recycled content? •Data for accounting purposes: (sales info and the like). I'd like to collect customer info for internal purposes, or if they opt-in, for further communication. I'd like to get the usual web traffic stats (referring sites, etc.). Return True, CK Principal/Designer/Programmer -Bushidodeep www.bushidodeep.com ___ "An ideal is merely the projection, on an enormously enlarged scale, of some aspect of personality." -- Aldus Huxley -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File extension for PHP's serialization format?
# [EMAIL PROTECTED] / 2006-10-27 02:06:22 +0100: > Hello Chris > > Thanks for responding. > > >> But what file extension should I use for PHP's serialization format? > >> Obviously it can't be .php - aside from being inaccurate (it's not PHP > >> code), using this extension would probably trigger the web server into > >> trying to run a (nonexistent) PHP script. > > > >You can rewrite the url using mod_rewrite or some such variant to handle > >this. > > Yes, there may well be ways to get round what the web server would > otherwise do when it encounters a .php extension, but I feel that I'd > be breaking an expectation. I'd much rather use an extension that was > specific to the serialization format. Hamish, there's no standard filename extension for PHP-serialized data, I'd just use txt or something... .psdf or whatever. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php