Re: [PHP] List of sessions
If you store your sessions in a database then your could gain a little mode control over your session, but I think what you're asking is if there's a way to tell if a user has closed the browser thus killing the session on their side. If that's what you're asking then the answer is not going to lie strictly with PHP as the server has no way to ping a user's browser. A quick hack off the top of my head might be to find a creative way of using the onBeforePageUnload() (or w/e it is) javascript function along with frames. Anyway, you can check out php.net for more details on how to use a database for session storage: http://www.php.net/manual/en/function.session-set-save-handler.php Cheers, - Joe On 5/4/06, Tony Aldrich [EMAIL PROTECTED] wrote: Well, I mean visitors of site. They can open it in several windows or in several browsers. I understand that each browser on a machine will be a session (in simple explanation). And for all of them I create some info in database. Then they close browser. I must clean up unused info. That's why I want to query alive sessions. Or query their death time (timeout). I thought of something like $sess=get_session_list(); or $isalive=is_session_alive($session_id); Thanks. On 5/4/06, Gerry D [EMAIL PROTECTED] wrote: Can you have more than 1 session? On 5/2/06, Tony Aldrich [EMAIL PROTECTED] wrote: Good day, Does anybody know how to get a list of current sessions? I need to clear some database rows that where associated with some SID. Can it be done without probing of maxlifetime?
Re: [PHP] Paged Results Set in MySQL DB with one result
Miles Thompson wrote: At 03:51 PM 5/3/2006, Phillip S. Baker wrote: Greetings Gents, ... However - why do you think paging an article improves readability? What it does do is control the amount of text you display on a page so you can profitably surround it with advertising. It has no effect on readabilty -- that depends on the quality of the writing, clarity and size of font, and line length. So, give them good dynamic design, a legible font, the ability to resize the type and ensure that the pieces are well-edited and written for easy reading in a browser. Guess I'm an iconoclast, but when I see an artificially paged article I look for the Print View link so I can read it all at once. Heresy! Maybe that's another reason for paging -- you get more hits on the site. Guess this has been more like a semi-rant, and probably not helpful. g on the contrary you gave arguments based on real world experience. and when I think about it, sites like 'A list Apart' spring to mind and I can't help thinking that you have a really good point. nice one :-) Cheers - Miles -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] List of sessions
Thanks all for explanations. I'll try to use callback functions. Tony. On 5/4/06, Joe Wollard [EMAIL PROTECTED] wrote: If you store your sessions in a database then your could gain a little mode control over your session, but I think what you're asking is if there's a way to tell if a user has closed the browser thus killing the session on their side. If that's what you're asking then the answer is not going to lie strictly with PHP as the server has no way to ping a user's browser. A quick hack off the top of my head might be to find a creative way of using the onBeforePageUnload() (or w/e it is) javascript function along with frames. Anyway, you can check out php.net for more details on how to use a database for session storage: http://www.php.net/manual/en/function.session-set-save-handler.php Cheers, - Joe On 5/4/06, Tony Aldrich [EMAIL PROTECTED] wrote: Well, I mean visitors of site. They can open it in several windows or in several browsers. I understand that each browser on a machine will be a session (in simple explanation). And for all of them I create some info in database. Then they close browser. I must clean up unused info. That's why I want to query alive sessions. Or query their death time (timeout). I thought of something like $sess=get_session_list(); or $isalive=is_session_alive($session_id); Thanks. On 5/4/06, Gerry D [EMAIL PROTECTED] wrote: Can you have more than 1 session? On 5/2/06, Tony Aldrich [EMAIL PROTECTED] wrote: Good day, Does anybody know how to get a list of current sessions? I need to clear some database rows that where associated with some SID. Can it be done without probing of maxlifetime?
[PHP] Getting the array element
Hi again all, Here my next PHP newbie question. When I'm building an array as bellow. Is there any way I can get the left element out of the array? $salesperson = array(); while($row=mysql_fetch_array($result)) { $salesperson[$row[1]] = '0'; } If I write: echo $salesperson[$row[3]]; I get the value. I think you know what I mean?! Thanks // Jonas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting the array element
Jonas Rosling wrote: Hi again all, Here my next PHP newbie question. When I'm building an array as bellow. Is there any way I can get the left element out of the array? the 'left element' is the key. $salesperson = array(); while($row=mysql_fetch_array($result)) { $salesperson[$row[1]] = '0'; } try a var_dump($salesperson); here If I write: echo $salesperson[$row[3]]; echo $row[3]; I get the value. I think you know what I mean?! // an example of looping an array: foreach ($salesperson as $empId = $fullName) { echo salesperson '{$fullName}' has employee id {$empId}; } Thanks // Jonas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] List of sessions
On Wed, May 3, 2006 11:29 pm, Tony Aldrich wrote: Well, I mean visitors of site. They can open it in several windows or in several browsers. I understand that each browser on a machine will be a session (in simple explanation). And for all of them I create some info in database. Then they close browser. I must clean up unused info. That's why I want to query alive sessions. Or query their death time (timeout). I thought of something like $sess=get_session_list(); or $isalive=is_session_alive($session_id); Honestly, the easiest way to solve this is to switch to 'user' PHP sessions: http://php.net/session-set-save-handler Once you do that, you're already nuking the actual session data for expired sessions in your database, and you can delete anything else in parallel. Your only other option would be to troll through /tmp looking for PHP session filenames that match the session ID or whatever, and then searching your database for IDs that aren't listed in there, and... You'd probably end up with a race condition sooner or later, and this would be dog-slow if you have lots of visitors, and you really don't want to do it this way. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php script fails when run from cron
It's remotely possible that your database classes are trying to create temp files or cache files or something in the current working directory which for cron would be... The home directory of the user running it??? I don't even know what it would be, but I know it can be problematic. The cron job IS running as the same user as when you do it on command-line right??? I mean, maybe freetds refuses to connect as 'root' user, and you put the cron in as 'root'? It's going to boil down to user/path/permissions, almost for sure. On Wed, May 3, 2006 9:27 pm, blackwater dev wrote: I have a script which runs fine from the command line but when I try to run it via cron, it seems to fail when the db class is instatiated, here is some code: $yesterday = date(Y-m-d,mktime(0, 0, 0, date(m) , date(d)-1, date(Y))); $file=fopen(/usr/local/apache2/htdocs/core/logs/import.log,a); fwrite($file,-DATE:.date(Y-m-d).-\n); fwrite($file,Starting:.date(H:i:s).\n); include(/usr/local/apache2/htdocs/includes/lib/ms_db.class.php); include(/usr/local/apache2/htdocs/includes/lib/database.php); fwrite($file,got two classes:.date(H:i:s).\n); $ms_sql= new ms_db(); $my_sql=new Database(); fwrite($file,got 1:.date(H:i:s).\n); The code then goes on to move some data from a remote SQL Server db to the local mysql. When finished, the log stops at got two classes. I am trying to debug now to see which of the two classes it seems to be failing on. I don't have anything in the php error log. The MSSQL connection uses freetds so I am not sure if it is something there but again this script runs fine with just php myfile.php. Any ideas? Thanks! -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Portfolio suggestions
On Thu, 2006-05-04 at 00:24 +0200, Rory Browne wrote: I'd like to rectify this, but I can't think of a suitable project. I'd like to do something new / useful as opposed to a glorified Hello World demonstration. Depends on your interests. I would say, join an established project and contribute in such a way that you can definitely say Thats my code. blatent punt of my project I would say, take a look at http://avoir.uwc.ac.za and send me a mail off list to get going. Nice thing with this project/framework is that it is completely modular, so you can definitely claim that you wrote the X module for it. Its also for a good cause (education in Africa, so you can still sleep at night. If you would like some additional info, contact me off list. /blatent punt of my project --Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Creating an OO Shopping Cart
On Wed, May 3, 2006 5:15 pm, Chris W. Parker wrote: Steve mailto:[EMAIL PROTECTED] on Friday, April 21, 2006 5:58 PM said: So everyone's aware, I have NO intention of storing credit card #'s. I don't see why anyone needs to.. especially after reading Richard's past posts in the archive. Perhaps if you don't use a merchant account and process all your cards in house instead?? We keep the cc numbers stored until the card has * But if we did get a lot of orders I would reconsider even the current implementation and decided whether or not it was suitable. In fact I'm going to be redoing the entire thing coming up soon so this is good. Contact the bank with which you already HAVE a merchant account for your point-of-sale credit card swiper thingies. You're already working with them, paying them good money for essentially the same services. Almost-for-sure they would be happy to provide you with on-line merchant account for not too much more than you already pay them. If not, I'm guessing that their competitors WILL do a package deal of on-line and POS merchant account, for the same price you're paying now, to lure you away from your current bank. If you're re-doing it anyway, you might as well do it right. :-) Because, frankly, the way you are doing it now is just not an acceptable risk... Who has access to the computer which is used to get the admin data? How long do you think it would take a disgruntled employee or even a customer to add a key-stroke monitor application to that computer, and come back a week later to steal your login? Game Over. Is that computer on the Internet? Even the BEST virus-protection software is reactive rather than proactive for the most part. How long before some virus infects it and that virus snoops on your login? Game Over. You're using SSL for all the admin pages, right? If not, Game Over. How do you transfer data from that screen to the POS device? Is it only in the admin user head, with the computer right next to the POS, or does he write them down and/or print them out? If the CC#s go onto paper, it's Game Over. I don't care if you shred the paper after -- what about the hold sideways pencil rubbing on the next sheet trick? Obviously you gave this some thought and are minimizing your risk to what you think is an acceptable level. But if those 5 current numbers do leak out, I do believe you are required by law to inform ALL your customers that you leaked CC numbers. Are you prepared to send out that mail? If you're really prepared for this, sit down and write that mail, and have it on file, as a contingency plan. You'll need it in an awful big hurry if you ever do need it. If you can't bring yourself to write that letter as a contingency then you're not really prepared to accept your current Risk. :-) Believe me, I know where you're coming from. I *ALMOST* did the same thing you are doing for a tiny store that already has POS, because I had the owner on my back every day for months wanting this, and they didn't want to spend $$$ on the on-line merchant account. Thank [deity] others on this list educated me about all the ways this can go wrong. I've maybe hit 10% in this email. I started describing these things to the store owner. After the blood came back to his face, he realized just how badly he did NOT want me to do this the wrong way. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] idn-functions in PHP
Marten Lehmann wrote: Hello, is there any function in PHP which binds to libidn? I found only a PEAR-project, but PEAR-projects are often beta and not as stable as PHP-builtin functions. that statement is rather baseless. the extension you refer to may be marked as EXPERIMENTAL but that doesn't mean it doesn't work - and you either misquotes or there is a PEAR package, but I think you mean to refer to the PECL package here: http://pecl.php.net/package-info.php?package=idnversion=0.1 why not install it and test if it is stable enough to use - it does seem to be rather dated but then again it only exports 2 functions and their description suggests that the functionality could well have not changed in all that time. Regards Marten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
On Wed, May 3, 2006 1:51 pm, Phillip S. Baker wrote: I have an interesting problem I would like some ideas on for a solution. I cannot seem to find any code examples on the net, though I might not be looking in the right place really. I have some articles stored in a MySQL DB. What I want is if the article is above a certain length in characters, to page article through a few pages for site readability. So I would want to print X number of words/characters. Save the where the pointer is, move on to the next page, and display the same amount and so on for as many pages as needed. I know about pulling paged results using the limit function but that would not seem to apply as really I would want to page the results within one record (one field really). It's pretty much the same as paging through records, but instead of: LIMIT $limit OFFSET $offset you would do: SELECT substring(monster_text, $offset, $limit) FROM whatever You will probably then want to dink around with things so that you don't break your text up in mid-word, but you can do that fairly easy on the PHP end once you have the chunk of text with http://php.net/strrpos: $pos = strrpos($text, ' '); $next_offset = $offset + $limit - ($limit - $pos); $text = substr($text, 0, $pos); There's probably an off-by-one error in that, but you get the idea. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
On Wed, May 3, 2006 6:57 pm, Jochem Maas wrote: a. who said anything about sessions? Jay did. He suggested sucking down the whole article, paginating it all, and cramming the pages into session, presumably so you don't have to suck down the whole article again. Which, by the way, is what I dislike about most of these answers... If the article is REALLY big, a query to get the whole damn thing is slow. parsing for html comments that could get blasted by an errant edit. the marker is either there or not - and if it'd borked (e.g. '!-- PAGE MAR') then it would break the page, sure - but so could ANY broken markup so the argument is somewhat moot. besides a routine to strip markers (broken or otherwise) is as simple to write as marker splitting function is. I think the assumption is that the article is actually HTML in the databse... At which point, almost any pagination you try to do programmatically is just plain borked. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sanity checker?
On Wed, May 3, 2006 12:51 pm, Ezra Nugroho wrote: I envision a tool that would audit your php code, and tell you if your code is good or not, if it has scaling issues, etc, etc. Basically it tells if your php code is sane or not. Oooh. I know what you mean. I call that tool a Consultant :-) Seriously: What you are attempting to do is pretty much about on par with making the computer intelligent as far as I can tell. I have a few ideas of how a sane php code should look like, but I certainly don't know everything. That's the reasons behind my earlier questions. Basically I am looking for things to check in codes that pose high running time risks. Or even simpler, I am looking for best practices, advices, guidelines that you would give to new php developers. The best advice I can give is: Read the beginning section of http://php.net/manual/ all the way up to the first extension functions. Then read the front-page of each extension you plan to use. You MUST READ: http://phpsec.org Every damn page on that site. You may not completely understand it all. So you keep re-reading it as you code until you DO understand it all. Does anyone know of any tools to test the sanity of your php code? I am confident that there are no existing tools such as you describe, other than syntax checkers. If you were to check the sanity of your code, what would you look for? Everything in http://php.net/faq.php would be a good start. Make sure all data is validated and scrubbed. Make sure there is error-checking code for all function return values. *HOW* you would detect this programmatically is way beyond my comprehension -- mainly because I don't think it is POSSIBLE. But I'll tell you one thing: If you can write the tool you describe, I'd sure be happy to give it a serious trial run. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] array insights
On 03 May 2006 18:27, Jason Gerfen wrote: I am looking for some information on how to do this the correct way, here is the data I am working with: Array ( [hostname-0] = hostname [mac-0] = 00:0a:b3:aa:00:5d [ip-0] = 192.168.0.1 [subnet] = MMC-Subnet [group] = MMC-PXE [hostname-1] = tester01 [mac-1] = 00:09:02:bb:cc:zz [ip-1] = 192.168.0.2 [hostname-2] = new-test [mac-2] = 00:09:02:bb:cc:99 [ip-2] = 192.168.0.3 [cmd] = edit [import] = Re-submit ) Here is how I need the above data to look when finished processing. Array ( [0] = Array ( [0] = hostname [1] = 00:0a:b3:aa:00:5d [2] = 192.168.0.1 ) [1] = Array ( [0] = tester01 [1] = 00:09:02:bb:cc:zz [2] = 192.168.0.2 ) [2] = Array ( [0] = new-test [1] = 00:09:02:bb:cc:99 [2] = 192.168.0.3 ) ) Here's one way: $new = array(); for ($i=0; isset($array[hostname-$i]; ++$i): $new[$i] = array($array[hostname-$i], $array[mac-$i], $array[ip-$i]); endfor; If your list of prefixes is likely to change at all (e.g. to add a port number), you could generalize it like this: $prefixes = array('hostname', 'mac', 'ip', 'port'); $new = array(); for ($i=0; isset($array[{$prefixes[0]}-$i]; ++$i): foreach ($prefixes as $k=$pfx): $new[$i][$k] = $array[{$pfx}-$i]; endforeach; endfor; Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] printf and number_format rounding
On Wed, May 3, 2006 12:25 pm, Duffy, Scott E wrote: Are printf and number_format supposed to round? echo ($hcount-$lcount)/$hilow. ; echo number_format(($hcount-$lcount)/$hilow,2,'.',''); 0.208333 0.21 0.145833 0.15 0.17 0.17 0.083 0.08 Printf (%.2f,($hcount-$lcount)/$hilow); Does the same. It would appear to be. If there is a function to print just to the digit could you point me in the direction? So I would want 0.20 0.14 0.16 0.08 respectively. http://php.net/substring might do what you want. You'll have to calculate the decimal point for yourself and work from there. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Polymorphism [was] [Fwd: Re: [PHP] Parents constructor]
On Wed, May 3, 2006 9:17 am, Jochem Maas wrote: BUT there is a fourth form of polymorphism - one I would argue if the most common form when speaking about polymorphism with respect to programming, namely the ability to derive a subclass from more than one base class (simutaneously), this is something that php cannot do (thank deity). In my CS classes we always called that multiple inheritence I ain't saying multiple inheritence isn't a subclass* of polymorhism or anything, just that that's what we called it. This was 20 years ago, and I've sat through WAY too many arguments about what is or isn't polymorphism to count. I think anybody would agree that PHP's support for polymorphism is minimal, at best :-) * pun intended -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Imagemagick Displaying Images
Ray Hauge wrote: convert -resize 800x600 AR-M455N_20060420_130446.pdf[0] - The '-' makes it display the contents of the image to stdout. I want to caputre that binary data and somehow display the images inline with the website. Is this possible, or am I living in a dream world ;) http://php.net/ob_start -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
Richard Lynch wrote: On Wed, May 3, 2006 6:57 pm, Jochem Maas wrote: a. who said anything about sessions? Jay did. dang - I didn't read properly - apologies go out to Edward for that! He suggested sucking down the whole article, paginating it all, and cramming the pages into session, presumably so you don't have to suck down the whole article again. Which, by the way, is what I dislike about most of these answers... If the article is REALLY big, a query to get the whole damn thing is slow. agreed - but then caching concepts/implementations of content/data/etc belongs on a whole other level imho. parsing for html comments that could get blasted by an errant edit. the marker is either there or not - and if it'd borked (e.g. '!-- PAGE MAR') then it would break the page, sure - but so could ANY broken markup so the argument is somewhat moot. besides a routine to strip markers (broken or otherwise) is as simple to write as marker splitting function is. I think the assumption is that the article is actually HTML in the databse... I made the same assumption. At which point, almost any pagination you try to do programmatically is just plain borked. absolutely - assuming the programmic pagination is based on 'logic' as opposed to being based on 'commands' (i.e. specific markers) put in place by the author of said article (whihc to me equates to putting seperate 'pages' in seperate records in the DB because the pagination is explicit rather than inferred). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XSLT issue
$xml = blah balh blah; $tournaments = explode(/tournament, $xml); $tournaments = array_slice($tournaments, 0, 3); //maybe 4 $xml = implode(/tournament, $tournaments); $xml .= \n/xmlfeed; Crude, but effective Captain -- Spock On Wed, May 3, 2006 5:40 am, Dave Goodchild wrote: Hi all, maybe slightly off list but I AM using php and Sablotron to generate xslt. I have a live poker games feed that takes the following format: ?xml version=1.0 encoding=utf-8?xmlfeed tournament tid10035522/tid nameTexas Holdem/name gameTexas Holdem Poker/game buyin5/buyin entryfee0.5/entryfee currencyUSD/currency stateRunning/state players110/players blindstructureNormal NL 1/blindstructure typeRegular/type limitNo Limit/limit starttime2006-04-24T07:00:00/starttime /tournament tournament tid10035126/tid nameTexas Holdem/name gameTexas Holdem Poker/game buyin20/buyin entryfee2/entryfee currencyUSD/currency stateRunning/state players79/players blindstructureNormal NL 1/blindstructure typeRegular/type limitNo Limit/limit starttime2006-04-24T08:00:00/starttime /tournament etc etc and all I want to do is output the first THREE tournament elements and no more. I realise XSLT has no general repetition mechanism but does anyone know how I would do this? Thanks in advance, and to my Dutch friend, I meant it when I said lovely baby. -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon! -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] printf and number_format rounding
Richard Lynch schrieb: On Wed, May 3, 2006 12:25 pm, Duffy, Scott E wrote: Are printf and number_format supposed to round? echo ($hcount-$lcount)/$hilow. ; echo number_format(($hcount-$lcount)/$hilow,2,'.',''); 0.208333 0.21 0.145833 0.15 0.17 0.17 0.083 0.08 Printf (%.2f,($hcount-$lcount)/$hilow); Does the same. It would appear to be. If there is a function to print just to the digit could you point me in the direction? So I would want 0.20 0.14 0.16 0.08 respectively. http://php.net/substring might do what you want. You'll have to calculate the decimal point for yourself and work from there. I use this function to add tax to a price. Probably it will help you: function addtax($price,$tax) { bcscale(6); $calc = bcmul(bcdiv($price,100,6),bcadd(100,$tax,6),6); $output = bcadd (0,$calc,2); $roundarray = explode (.,$calc); if (substr($roundarray[1],2,1) = 5) { $output = $roundarray[0]+(substr($roundarray[1],0,2)/100)+0.01; } else $output = $roundarray[0]+(substr($roundarray[1],0,2)/100)+0.0; return $output; } -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Removing key and value
How's the best way to remove a key and it's value from an array? Like in the code bellow where I would like to remove AK and it's value. $salesperson = array( 'AK' = '1000', 'AT' = '1500', 'BT' = '2000' ); // Jonas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Removing key and value
On Thu, 4 May 2006, Jonas Rosling wrote: How's the best way to remove a key and it's value from an array? Like in the code bellow where I would like to remove AK and it's value. $salesperson = array( 'AK' = '1000', 'AT' = '1500', 'BT' = '2000' ); unset($salesperson['AK']); See http://www.php.net/unset for more. Cheers, -- --Jyry C|:-(C|:-/C|8-OC|8-/C|:-( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Mail and hotmail
Best group member, I am sending email to a hotmail thru PHP. When I send it like this it arrives (in the junk mail, but it arrives): mail('[EMAIL PROTECTED]', 'A nice subject', 'Some text'); It works well, but I want to change the FROM header so I do this: mail('[EMAIL PROTECTED]', 'A nice subject', 'Some text', 'From: Peter Lauri [EMAIL PROTECTED]'); This email does not arrive to the Hotmail inbox. If I send to a regular email, like Google Email (gmail) or a regular POP3 it arrives without problems. Anyone who has experienced this problem with sending emails to Hotmail? And how do you solve it? Best regards, Peter Lauri -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XSLT issue
Why would I want to mess with the xml file like that? I use it in other places. The actual xslt solution I came up with (with assistance) is the preferred one. On 04/05/06, Richard Lynch [EMAIL PROTECTED] wrote: $xml = blah balh blah; $tournaments = explode(/tournament, $xml); $tournaments = array_slice($tournaments, 0, 3); //maybe 4 $xml = implode(/tournament, $tournaments); $xml .= \n/xmlfeed; Crude, but effective Captain -- Spock On Wed, May 3, 2006 5:40 am, Dave Goodchild wrote: Hi all, maybe slightly off list but I AM using php and Sablotron to generate xslt. I have a live poker games feed that takes the following format: ?xml version=1.0 encoding=utf-8?xmlfeed tournament tid10035522/tid nameTexas Holdem/name gameTexas Holdem Poker/game buyin5/buyin entryfee0.5/entryfee currencyUSD/currency stateRunning/state players110/players blindstructureNormal NL 1/blindstructure typeRegular/type limitNo Limit/limit starttime2006-04-24T07:00:00/starttime /tournament tournament tid10035126/tid nameTexas Holdem/name gameTexas Holdem Poker/game buyin20/buyin entryfee2/entryfee currencyUSD/currency stateRunning/state players79/players blindstructureNormal NL 1/blindstructure typeRegular/type limitNo Limit/limit starttime2006-04-24T08:00:00/starttime /tournament etc etc and all I want to do is output the first THREE tournament elements and no more. I realise XSLT has no general repetition mechanism but does anyone know how I would do this? Thanks in advance, and to my Dutch friend, I meant it when I said lovely baby. -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon! -- Like Music? http://l-i-e.com/artists.htm -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon!
Re: [PHP] Mail and hotmail
On Thu, 2006-05-04 at 17:37 +0700, Peter Lauri wrote: mail('[EMAIL PROTECTED]', 'A nice subject', 'Some text', 'From: Peter Lauri [EMAIL PROTECTED]'); This email does not arrive to the Hotmail inbox. This has been discussed ad nauseum on this list. I suggest going through the list archives on proper ways to send through additional headers. (or you could RTFM) --Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mail and hotmail
Peter Lauri wrote: Best group member, I am sending email to a hotmail thru PHP. When I send it like this it arrives (in the junk mail, but it arrives): mail('[EMAIL PROTECTED]', 'A nice subject', 'Some text'); It works well, but I want to change the FROM header so I do this: mail('[EMAIL PROTECTED]', 'A nice subject', 'Some text', 'From: Peter Lauri [EMAIL PROTECTED]'); This email does not arrive to the Hotmail inbox. If I send to a regular email, like Google Email (gmail) or a regular POP3 it arrives without problems. Anyone who has experienced this problem with sending emails to Hotmail? And how do you solve it? Best regards, Peter Lauri you need to set your mail headers for the mail to be assumed valid, namely: X-Sender From Date Subject Delivered-to MIME-Version Reply-To Content-type X-Priority Importance Return-Path X-Mailer HTH Angelo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Mail and hotmail
Paul, I did make a search on this. However, as you understand, searching for hotmail mail header will generate to much junk because it will be replies from hotmails that also will be included. /Peter -Original Message- From: Paul Scott [mailto:[EMAIL PROTECTED] Sent: Thursday, May 04, 2006 5:43 PM To: Peter Lauri Cc: php-general@lists.php.net Subject: Re: [PHP] Mail and hotmail On Thu, 2006-05-04 at 17:37 +0700, Peter Lauri wrote: mail('[EMAIL PROTECTED]', 'A nice subject', 'Some text', 'From: Peter Lauri [EMAIL PROTECTED]'); This email does not arrive to the Hotmail inbox. This has been discussed ad nauseum on this list. I suggest going through the list archives on proper ways to send through additional headers. (or you could RTFM) --Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP][Solved] Mail and hotmail
Sending email to hotmail using mail(); you need to set your mail headers for the mail to be assumed valid, namely: X-Sender From Date Subject Delivered-to MIME-Version Reply-To Content-type X-Priority Importance Return-Path X-Mailer HTH Angelo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Mail and hotmail
On Thu, 2006-05-04 at 17:51 +0700, Peter Lauri wrote: Paul, I did make a search on this. However, as you understand, searching for hotmail mail header will generate to much junk because it will be replies from hotmails that also will be included. Try the mail function on http://za2.php.net/ as well as a google for php mail headers. Hotmail has very little to do with your question. --Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php and ssl
Greetings All, I am currently implementing a form for a client that will run over https. Now, all is good and well except, for some reason when the form loads in IE the lock in the status bar displays for a short while and then goes away, it is fine in Firefox though. The way I have the form coded is something like this: ?php // Handle POST method. if ($_POST) { $name = $_POST['name']; $street_address = $_POST['street_address']; $to = 'address'; $subject = subject; $headers = MIME-Version: 1.0\r\n. Content-type: text/html; charset=iso-8859-1\r\n. From: .$name.\r\n. Reply-to: .$email.\r\n. Date: .date(r).\r\n; // Compose message: $message = message; // Send message mail($to, $subject, $message, $headers); // Thank the generous user echo h1Thank You!/h1; } else { ? form name=donation_eng action=?php echo $_SERVER['PHP_SELF']; ? method=post fieldset legendFill in your details/legend table cellspacing=0 cellpadding=0 class=form-container tr td colspan=2 label for=nameName: input name=name type=text id=name tabindex=1 size=35 maxlength=150 / /label /td /tr /table /fieldset /form ?php } ? The page in question is here: https://www.epda.cc/donation_eng.php Is there any reason why coding the form like this will cause IE to think that the form is not secure and not loaded over https? Thank you in advance! -- Kind Regards Schalk Neethling Web Developer.Designer.Programmer.President Volume4.Business.Solution.Developers -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php and ssl
Schalk schrieb: Greetings All, I am currently implementing a form for a client that will run over https. Now, all is good and well except, for some reason when the form loads in IE the lock in the status bar displays for a short while and then goes away, it is fine in Firefox though. The way I have the form coded is something like this: ?php // Handle POST method. if ($_POST) { $name = $_POST['name']; $street_address = $_POST['street_address']; $to = 'address'; $subject = subject; $headers = MIME-Version: 1.0\r\n. Content-type: text/html; charset=iso-8859-1\r\n. From: .$name.\r\n. Reply-to: .$email.\r\n. Date: .date(r).\r\n; // Compose message: $message = message; // Send message mail($to, $subject, $message, $headers); // Thank the generous user echo h1Thank You!/h1; } else { ? form name=donation_eng action=?php echo $_SERVER['PHP_SELF']; ? method=post fieldset legendFill in your details/legend table cellspacing=0 cellpadding=0 class=form-container tr td colspan=2 label for=nameName: input name=name type=text id=name tabindex=1 size=35 maxlength=150 / /label /td /tr /table /fieldset /form ?php } ? The page in question is here: https://www.epda.cc/donation_eng.php Is there any reason why coding the form like this will cause IE to think that the form is not secure and not loaded over https? Thank you in advance! Since you load it framewise. is there probably a problem with the loaded frames? It has nothing to do with PHP though. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Mail and hotmail
The only one I do not know what to set it to is Importance. What values are possible there? Is it the same as for X-priority? Regards, Peter -Original Message- From: Angelo Zanetti [mailto:[EMAIL PROTECTED] Sent: Thursday, May 04, 2006 5:53 PM To: Peter Lauri Cc: php-general@lists.php.net Subject: Re: [PHP] Mail and hotmail Peter Lauri wrote: Best group member, I am sending email to a hotmail thru PHP. When I send it like this it arrives (in the junk mail, but it arrives): mail('[EMAIL PROTECTED]', 'A nice subject', 'Some text'); It works well, but I want to change the FROM header so I do this: mail('[EMAIL PROTECTED]', 'A nice subject', 'Some text', 'From: Peter Lauri [EMAIL PROTECTED]'); This email does not arrive to the Hotmail inbox. If I send to a regular email, like Google Email (gmail) or a regular POP3 it arrives without problems. Anyone who has experienced this problem with sending emails to Hotmail? And how do you solve it? Best regards, Peter Lauri you need to set your mail headers for the mail to be assumed valid, namely: X-Sender From Date Subject Delivered-to MIME-Version Reply-To Content-type X-Priority Importance Return-Path X-Mailer HTH Angelo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
At 11:51 AM 5/3/2006, Phillip S. Baker wrote: I have some articles stored in a MySQL DB. What I want is if the article is above a certain length in characters, to page article through a few pages for site readability. So I would want to print X number of words/characters. Save the where the pointer is, move on to the next page, and display the same amount and so on for as many pages as needed. Phillip, There's a fundamental problem with trying to slice text into resizable web pages the same way it's sliced on paper. Paper pages work because they're set in a fixed font size. When you change the ratio of font size to column width, the places where lines of text wrap changes. Because of the varying lengths of words, strings of words spill over to the next line in non-linear rates. Unless you use a fixed font size (boo, hiss) or you change the font size and the column width at exactly the same rate by sizing your layout in ems, your text columns are going to change in height (line-count) with font resizing. This means that the amount of text that fits on a page changes dynamically with browser events and cannot be predicted or controlled server-side by PHP -- unless you can accept a layout sized in ems both horizontally and vertically, which few people seem willing to do, or you force your readers to accept your choice of font size, which would be an ironic and depressing decision for a modern publisher to make. Here's a related problem: Say you calculate the number of words that can fit in N column inches and dish out that much text from your database, and let's say that the last line on the page is in mid-paragraph. When the user resizes their browser font, the word-wrap will change and suddenly the last line on the page will end halfway across the column even though it isn't the end of the sentence or the paragraph. In addition, all this means dynamically changing widows and orphans, also of concern to the serious typographer. As a final coup de grace, any calculation of words per line must take into account the metrics of the specific font being rendered, a practical impossibility when fonts are selected from the users' computers and not the publisher's. While PHP and MySQL can supply the raw text from the server, these issues beg for a client-size solution at the reader's end. My first choice of solution would be to size my columns in ems to allow the entire layout to zoom both horizontally and vertically with font-size, in which case your problem of how to extract contiguous text strings again becomes relevant. And that's trivial, really, compared to the algorithm you'll have to write to predict how many words will wrap into a given number of lines when you can't even predict the font being used. You could make the problem much more solvable by dishing up whole paragraphs only, and learning to accept (nay, embrace!) the resultant variation in page-length. Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Avoiding user refresh of pages with forms
On 5/3/06, Satyam [EMAIL PROTECTED] wrote: I used that method initially, some months ago, but finally dropped it. It looked nice at first, but then I started getting into problems and required too many special cases to make it work. In the end, it wasn't a clean nor elegant solution. Satyam, Would you care to give some more details as to those edge cases that swayed you to drop the unique id approach? I've just recently added it to my forms (for those that I find need it), in addition to the redirect method you outlined below. Those two combined seem to really go the distance in creating a reliable exchange of data between client and server, as well as a better experience for the user (since the form is capable of handling a larger set of error cases). Also, with regards to sending success/failure messages across the redirection of your forms, I'd recommend considering sessions for passing the data. It keeps your URLs clean, and allows you to send complex data a bit easier (IMHO). For example if a user makes an error on a few different form elements, you can send back an array of messages to the user without having to serialize/unserialize in the ugly URL. -John W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php and ssl
Barry wrote: Schalk schrieb: Greetings All, I am currently implementing a form for a client that will run over https. Now, all is good and well except, for some reason when the form loads in IE the lock in the status bar displays for a short while and then goes away, it is fine in Firefox though. The way I have the form coded is something like this: The page in question is here: https://www.epda.cc/donation_eng.php Is there any reason why coding the form like this will cause IE to think that the form is not secure and not loaded over https? Thank you in advance! Since you load it framewise. is there probably a problem with the loaded frames? It has nothing to do with PHP though. Barry, Not sure what you mean by frames If you look at the HTML source there are no frames in there. Do you mean the fieldset? -- Kind Regards Schalk Neethling Web Developer.Designer.Programmer.President Volume4.Business.Solution.Developers emotionalize.conceptualize.visualize.realize Landlines Tel: +27125468436 US Tel: (440) 499-5484 Fax: +27125468436 Web email:[EMAIL PROTECTED] Global: www.volume4.com Messenger Yahoo!: v_olume4 AOL: v0lume4 MSN: [EMAIL PROTECTED] We support OpenSource Get Firefox!- The browser reloaded - http://www.mozilla.org/products/firefox/ The information transmitted is intended solely for the individual or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this email in error, please contact the sender and please delete all traces of this material from all devices. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mod_rewrite help
On 5/3/06, Jay Blanchard [EMAIL PROTECTED] wrote: [aha moment] I finally get it. PHP developers are the smartest people on the planet and therefore we know and use everything. JavaScript, Java, C++, SQL, network management, Apache internals, women and even PHP. That is why people come on this list to ask questions totally unrelated to PHP even if they try to relate it to PHP by including the URL of a PHP page within the request. [/aha moment] [dream_sequence] Beautiful Woman: So how do you useFFP to make all of those pretty-looking website adresses? Me: Well actually, *P.H.P.* doesn't do it, but if you're running your website on Apache, you can use mod_rewrite and some regex pattern matching to forward your requests onto the appropriate page. And then you can parse any number of your server's global variables, like SCRIPT_URL, to handle the request. Beautiful Woman:That's hot. Let's make out! [/dream_sequence] [gratuitous_back_patting] This probably is a good opportunity to send out general thanks and acknowledgement at just how active and *helpful* this list is on a daily basis (sarcasm included). In contrast, I just subscribed to the RubyOnRails list to see what sort of chatter goes on within their community. In less than a week the list has already seen well over 300 messages, and the majority of them are never replied to. Sure, the RoR world is still in its infancy, but even so. And at least on our list, if you don't feel like answering a JavaScript question you don't have to; but on the RoR list you have little choice, since it's all tied together. Cheers to the PHP list. I love it here. [/gratuitous_back_patting] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Avoiding user refresh of pages with forms
Also, with regards to sending success/failure messages across the redirection of your forms, I'd recommend considering sessions for passing the data. It keeps your URLs clean, and allows you to send complex data a bit easier (IMHO). For example if a user makes an error on a few different form elements, you can send back an array of messages to the user without having to serialize/unserialize in the ugly URL. IE has a url length limit, so depending on how many steps you go through you might have issues with it not unserializing properly because the URL gets chopped off... -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php script fails when run from cron
[snip] The code then goes on to move some data from a remote SQL Server db to the local mysql. When finished, the log stops at got two classes. I am trying to debug now to see which of the two classes it seems to be failing on. I don't have anything in the php error log. The MSSQL connection uses freetds so I am not sure if it is something there but again this script runs fine with just php myfile.php. [/snip] Are you logging errors? If so you will likely locate the cause there. If I were to hazard a guess at would be because include files are not getting included as I have seen that behavior before. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Echo a value from an arrays position
Is there any way to call for an element value in an array by the position? Like position 2 in the array and not the key name. // Jonas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Echo a value from an arrays position
[snip] Is there any way to call for an element value in an array by the position? Like position 2 in the array and not the key name. [/snip] I hate to say this, but you really need to RTFM http://www.php.net/array To get a value from position 2 in an array you use $arrayName[1] (all array elements start numbering at 0, unless you do something to the array to change it). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sanity checker?
On Wed, May 3, 2006 12:51 pm, Ezra Nugroho wrote: I envision a tool that would audit your php code, and tell you if your code is good or not, if it has scaling issues, etc, etc. Basically it tells if your php code is sane or not. No, but If you're in a team environment, the best advice I've heard is to have the team share accountability. Meaning, if you write a piece of code, you _must_ have a colleague double-check it and sign off on it. Then if a bug is discovered down the road, _both_ of you will be held responsible. This will do two things: 1. Ensure that code you write is readable. If someone else simply can't understand it or consider it too confusing, they can hand it back to you and say clean this up. 2. It increases the chance of catching bugs or weak code prcocesses. Also, develop/adopt specific coding standards (refer to PEAR's standards as a flavor), and the steps above will help adherence to that as well. I'm willing to say that those two techniques will make you sleep much sounder at night then just stuffing thousands of lines of code through some regex checker. Oh, plus some solid QA testing. Your last defense. There will always be newbies in PHP (and elsewhere). The solution is education (being proactive), not sanity checking (being reactive)... Although I don't blame you for asking. :) -John W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] can't work out the syntax error
Hi, The line was this. echo TD WIDTH=\25%\ ALIGN=\CENTER\ A HREF=\javascript:open_window('$PHP_SELF?action=view_recorduserid=$userid');\View/A A HREF=\$PHP_SELF?action=delete_recorduserid=$userid\ onClick=\return confirm('Are you sure?');\Delete/A/TD\n; I have registered globals off so tried this... echo TD WIDTH=\25%\ ALIGN=\CENTER\ A HREF=\javascript:open_window('$_SERVER['PHP_SELF']?action=view_recorduserid=$userid');\View/A What is the problem with it? R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Echo a value from an arrays position
Will this also work with an associative array? If this is what he is talking about, I tried it and it does not work I put this together though and it works, not sure if it is the *best* way though... ?php $colors = array('white'='#ff','black'='#00','blue'='#ff'); $count = 0; foreach( $colors as $k = $v) { $count++; if( $count == 2 ) echo \$colors[$k] = $v.\n; } ? -Brad Jay Blanchard wrote: [snip] Is there any way to call for an element value in an array by the position? Like position 2 in the array and not the key name. [/snip] I hate to say this, but you really need to RTFM http://www.php.net/array To get a value from position 2 in an array you use $arrayName[1] (all array elements start numbering at 0, unless you do something to the array to change it). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Paged Results Set in MySQL DB with one result
[snip] There's a fundamental problem with trying to slice text into resizable web pages the same way it's sliced on paper. Paper pages work because they're set in a fixed font size. When you change the ratio of font size to column width, the places where lines of text wrap changes. Because of the varying lengths of words, strings of words spill over to the next line in non-linear rates. Unless you use a fixed font size (boo, hiss) or you change the font size and the column width at exactly the same rate by sizing your layout in ems, your text columns are going to change in height (line-count) with font resizing. More [/snip] Paul states here more eloquently what I hinted at in my response in terms liquid layouts, et. al. You must quit thinking of web pages in print pages terms, a concept which may be more difficult than arrays. Also, Jochem made a statement about allowing authors to determine logical page breaks in their tomes, and he is correct. You'll see that articles on Evolt, A List Apart, SitePoint and others are broken logically (almost in chapters). This would be preferred. I did use an array and sessions in my example because I want to save round trips to the database. Using Jochem's suggestion with an HTML comment you can achieve the same thing by placing the chunks of the article between the comments into session variables. The wheel here has been created many times and many ways. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Echo a value from an arrays position
Seem like your missunderstanding me. I'm not using an orignal array. I'm using an map-array. $array = ('element' = 'value'); // Jonas Den 06-05-04 14.29, skrev Jay Blanchard [EMAIL PROTECTED]: [snip] Is there any way to call for an element value in an array by the position? Like position 2 in the array and not the key name. [/snip] I hate to say this, but you really need to RTFM http://www.php.net/array To get a value from position 2 in an array you use $arrayName[1] (all array elements start numbering at 0, unless you do something to the array to change it). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] session cookie and domains
Hi there, I am operating 3 sites where I would like to be able to login cross site. Means with one login have a valid session on all 3 domain. Currently I do set the cookie like this: setcookie($cookiename,$sessid,0,'/','.'.$domain[name],0); That makes is available for all subdomains. Is there a possiblity to make it available for all domains like example: .domainname. Thank you for any hint, Merlin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] can't work out the syntax error
Ross wrote: Hi, The line was this. echo TD WIDTH=\25%\ ALIGN=\CENTER\ A HREF=\javascript:open_window('$PHP_SELF?action=view_recorduserid=$userid');\View/A A HREF=\$PHP_SELF?action=delete_recorduserid=$userid\ onClick=\return confirm('Are you sure?');\Delete/A/TD\n; I have registered globals off so tried this... echo TD WIDTH=\25%\ ALIGN=\CENTER\ A HREF=\javascript:open_window('$_SERVER['PHP_SELF']?action=view_recorduserid=$userid');\View/A I would go with your second option here... try this: echo TD WIDTH=\25%\ ALIGN=\CENTER\ A HREF=\javascript:open_window('.$_SERVER['PHP_SELF'].?action=view_recorduserid=$userid');\View/A ---^---^ concatenate the $_SERVER variable to the string... HTH -Brad What is the problem with it? R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Sanity checker?
[snip] If you're in a team environment, the best advice I've heard is to have the team share accountability. Meaning, if you write a piece of code, you _must_ have a colleague double-check it and sign off on it. Then if a bug is discovered down the road, _both_ of you will be held responsible. This will do two things: [/snip] In a team environment may I suggest (as John does here) a peer code review? We used to do his on Friday afternoon, everyone knew it was coming and I usually got milk and cookies for the team (you'd be amazed at the response as hockey as it sounds). That ay all of the projects got reviewed, code was scrutinized and everyone could bug out on Friday knowing where they had to go on Monday. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Echo a value from an arrays position
[snip] $colors = array('white'='#ff','black'='#00','blue'='#ff'); [/snip] What happens when you echo $colors[1]? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Echo a value from an arrays position
I get nothing do you get something different? Jay Blanchard wrote: [snip] $colors = array('white'='#ff','black'='#00','blue'='#ff'); [/snip] What happens when you echo $colors[1]? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Echo a value from an arrays position
[snip] I get nothing do you get something different? [/snip] Not even 'array'? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Echo a value from an arrays position
Nothing. // Jonas Den 06-05-04 14.40, skrev Jay Blanchard [EMAIL PROTECTED]: [snip] $colors = array('white'='#ff','black'='#00','blue'='#ff'); [/snip] What happens when you echo $colors[1]? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Echo a value from an arrays position
Nope... dead air. Of course getting an indexed value into an associative array seems a bit odd to me... maybe Jonas could shed some light on why he would go this route... Jay Blanchard wrote: [snip] I get nothing do you get something different? [/snip] Not even 'array'? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Echo a value from an arrays position
This may clarify - in php, integer and associate arrays are created arbitrarily, ie keys can be numbers or strings. So, either create an array like this: array('1' = 'first element', '2' = 'second element'); and call by the key! On 04/05/06, Jonas Rosling [EMAIL PROTECTED] wrote: Is there any way to call for an element value in an array by the position? Like position 2 in the array and not the key name. // Jonas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon!
Re: [PHP] Echo a value from an arrays position
On 5/4/06, Brad Bonkoski [EMAIL PROTECTED] wrote: Will this also work with an associative array? If this is what he is talking about, I tried it and it does not work I think you're correct. This is because PHP arrays are a mash-up (as Jochem put it) of numerical indexes/hashtables/assoc. arrays/etc Example: [php] $jonas = array('color' = 'blue', 'number' = 'three'); echo $jonas[1]; // prints nothing $jonas = array('color' = 'blue', 'number' = 'three', 1 = 'readme'); echo $jonas[1]; // prints 'readme', even though it's technically the third element [/php] So, your solution might be to first pull all of the array values out into a new array, like this: [php] $jonas = array('color' = 'blue', 'number' = 'three', 1 = 'readme'); $jonas_new = array_values($jonas); echo $jonas_new[1]; // prints 'three', as you'd hoped [/php] p.s. Bonus: If you wanted to get the keys out, use array_keys() And yes, as Jay said, RTFM. It's very very helpful. HTH, John W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Echo a value from an arrays position
[snip] Of course getting an indexed value into an associative array seems a bit odd to me... maybe Jonas could shed some light on why he would go this route... [/snip] Exactly [snip] To get a value from position 2 in an array you use $arrayName[1] (all array elements start numbering at 0, unless you do something to the array to change it). [/snip] I was being too subtle. Anyhow, he has done something to change the array keys. He would have to know that 'black' is the key in position 2. I suspect that he may be overcomplicating code, as many new to programming have a tendency to do (not a hit, just a fact). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Echo a value from an arrays position
[snip] Seem like your missunderstanding me. I'm not using an orignal array. I'm using an map-array. $array = ('element' = 'value'); [/snip] It is called an associative array, a value is associated with a key. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] session cookie and domains
[snip] That makes is available for all subdomains. Is there a possiblity to make it available for all domains like example: .domainname. [/snip] Are you trying to share a cookie across domain names? If so that cannot be done. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Upgrade Question
Tom Ray wrote: snip Ok so I can't find apxs on the server at all, even though the 4.3.4 phpinfo claims to have been configured with --with-apxs2=/usr/sbin/apxs2-prefork. I did some search via google and I reconfigured using --enable-cli and --disable-cgi but I still had to use --with-apache2=/usr/sbin/httpd2 because I need to have that correct? Since all the builds I done with PHP call on a Apache source in some way. It still compiled with it's SAPI choice being cgi then I ran 'make install-cli' and now when I do a /usr/bin/php -v I get: /snip If you don't tell it otherwise in your configure script, the cli is going to install in /usr/local/bin ^ -- John C. Nichel IV Programmer/System Admin (ÃœberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] preg_replace_callback
Hi. I have problem with preg_replace_callback. It seems that my pattern is bad, but I can't find any error. Pattern : \[\s*((\d|\w|_)+)\s*\] this pattern is intended to find strings like [field], [ fi12_eld]... but every time I get warning message Warning: preg_replace_callback(): Delimiter must not be alphanumeric or backslash in test.php on line 100 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Removing key and value
Jonas Rosling wrote: How's the best way to remove a key and it's value from an array? Like in the code bellow where I would like to remove AK and it's value. $salesperson = array( 'AK' = '1000', 'AT' = '1500', 'BT' = '2000' ); // Jonas PHP Manual - Variables Handling - Unset -- John C. Nichel IV Programmer/System Admin (ÃœberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Echo a value from an arrays position
[snip] Lasso can do the following, can PHP? ?LassoScript Variable: 'Colors'=(Map:'red'='#ff','green'='#00ff00','blue'='#ff'); Loop: $Colors-Size; Output: 'br' + $Colors-(Get: Loop_Count),-EncodeNone; /Loop; ? This outputs; ff 00ff00 ff I'm new at PHP but not Lasso that's why I'm for you asking odd questions. [/snip] 1. Always respond to the list as a single user may not be there to answer your question or your individual e-mail may get dumped to the spam list. I just happened to be cleaning my spam folder when your message popped up. B. Reading backwards is a pain. Why? Please do no top post. Less code than Lasso; $colors = array('white'='#ff','black'='#00','blue'='#ff'); foreach($colors AS $key = $value){ echo $value . br /\n; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mod_rewrite help
John Wells wrote: On 5/3/06, Jay Blanchard [EMAIL PROTECTED] wrote: [aha moment] I finally get it. PHP developers are the smartest people on the planet and therefore we know and use everything. JavaScript, Java, C++, SQL, network management, Apache internals, women and even PHP. That is why people come on this list to ask questions totally unrelated to PHP even if they try to relate it to PHP by including the URL of a PHP page within the request. [/aha moment] [dream_sequence] Beautiful Woman: So how do you useFFP to make all of those pretty-looking website adresses? Me: Well actually, *P.H.P.* doesn't do it, but if you're running your website on Apache, you can use mod_rewrite and some regex pattern matching to forward your requests onto the appropriate page. And then you can parse any number of your server's global variables, like SCRIPT_URL, to handle the request. Beautiful Woman:That's hot. Let's make out! [/dream_sequence] [gratuitous_back_patting] This probably is a good opportunity to send out general thanks and acknowledgement at just how active and *helpful* this list is on a daily basis (sarcasm included). In contrast, I just subscribed to the RubyOnRails list to see what sort of chatter goes on within their community. In less than a week the list has already seen well over 300 messages, and the majority of them are never replied to. Sure, the RoR world is still in its infancy, but even so. And at least on our list, if you don't feel like answering a JavaScript question you don't have to; but on the RoR list you have little choice, since it's all tied together. Cheers to the PHP list. I love it here. [/gratuitous_back_patting] Try the qmail list (for a laugh, not for help). -- John C. Nichel IV Programmer/System Admin (ÃœberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session cookie and domains
Merlin wrote: Hi there, I am operating 3 sites where I would like to be able to login cross site. Means with one login have a valid session on all 3 domain. Currently I do set the cookie like this: setcookie($cookiename,$sessid,0,'/','.'.$domain[name],0); That makes is available for all subdomains. Is there a possiblity to make it available for all domains like example: .domainname. Thank you for any hint, Merlin If you mean sharing the cookie between domain1.com, domain2.com, domain3.com, then no -- John C. Nichel IV Programmer/System Admin (ÃœberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] preg_replace_callback
[snip] Hi. I have problem with preg_replace_callback. It seems that my pattern is bad, but I can't find any error. Pattern : \[\s*((\d|\w|_)+)\s*\] this pattern is intended to find strings like [field], [ fi12_eld]... but every time I get warning message Warning: preg_replace_callback(): Delimiter must not be alphanumeric or backslash in test.php on line 100 [/snip] I think you need pipes or forward slashes around your pattern. Have a look at TFM to see how they do it there; http://www.php.net/preg_replace_callback -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Echo a value from an arrays position
[snip] $colors = array('white'='#ff','black'='#00','blue'='#ff'); foreach($colors AS $key = $value){ echo $value . br /\n; } But I don't get anything out of this code. Why? Doesn't echo anything? [/snip] Seriously? Works fine here. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] can't work out the syntax error
On 5/4/06, Brad Bonkoski [EMAIL PROTECTED] wrote: try this: echo TD WIDTH=\25%\ ALIGN=\CENTER\ A HREF=\javascript:open_window('.$_SERVER['PHP_SELF'].?action=view_recorduserid=$userid');\View/A ---^---^ concatenate the $_SERVER variable to the string... Or wrap the variables with curly braces so that PHP knows what's a variable and what's not: [php] echo TD WIDTH=\25%\ ALIGN=\CENTER\ A HREF=\javascript:open_window('{$_SERVER['PHP_SELF']}?action=view_recorduserid=$userid');\View/A [/php] Personally, I get tired (and confused) when having to escape all of those quotes like in the string you're trying to echo above. Perhaps you'd consider HEREDOC as an alternative approach: [php] echoHEREDOC TD WIDTH=25% ALIGN=CENTER A HREF=javascript:open_window('{$_SERVER['PHP_SELF']}?action=view_recorduserid=$userid');View/A HEREDOC; [/php] If you haven't read about HEREDOC before, RTFM because there are some rules you should know about it... HTH, John W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Echo a value from an arrays position
On 04 May 2006 13:52, John Wells wrote: On 5/4/06, Brad Bonkoski [EMAIL PROTECTED] wrote: Will this also work with an associative array? If this is what he is talking about, I tried it and it does not work I think you're correct. This is because PHP arrays are a mash-up (as Jochem put it) of numerical indexes/hashtables/assoc. arrays/etc They're not even that. They're pure associative arrays, or maps -- it's just that integer keys are treated somewhat specially so that an array with *only* integer keys will look like a traditional array. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] preg_replace_callback
On 04 May 2006 14:04, tJey wrote: Hi. I have problem with preg_replace_callback. It seems that my pattern is bad, but I can't find any error. Pattern : this pattern is intended to find strings like [field], [ fi12_eld]... but every time I get warning message Warning: preg_replace_callback(): Delimiter must not be alphanumeric or backslash in test.php on line 100 The error message suggests you haven't included the necessary pattern delimiters, like for example: preg_replace_callback(|\[\s*((\d|\w|_)+)\s*\]|, ... or preg_replace_callback(@\[\s*((\d|\w|_)+)\s*\]@, ... or preg_replace_callback({\[\s*((\d|\w|_)+)\s*\]}, ... etc, etc! Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] causing HTTP error status
I'm having trouble with setting HTTP error status from PHP4. The PHP docs say that if I have this : Directory /mydir ErrorDocument 400 /mydir/error.html /Directory then the script /mydir/test.php: ?php header(HTTP/1.0 400); ? will cause the page /mydir/error.html to be displayed. But that's not what I get. I just get the error header and no response body; eg: HTTP/1.1 400 Bad Request Date: Thu, 04 May 2006 13:40:02 GMT Server: Apache/2.0.54 (Debian GNU/Linux) PHP/4.3.10-16 X-Powered-By: PHP/4.3.10-16 Connection: close Transfer-Encoding: chunked Content-Type: text/html This suggests that PHP or Apache is not doing something right, or that I've got this round the back of my neck. Anyone help? Nic Ferrier -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Echo a value from an arrays position
On 5/4/06, Ford, Mike [EMAIL PROTECTED] wrote: They're not even that. They're pure associative arrays, or maps -- it's just that integer keys are treated somewhat specially so that an array with *only* integer keys will look like a traditional array. True true, thanks for making it crystal clear! -John W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Avoiding user refresh of pages with forms
- Original Message - From: John Wells [EMAIL PROTECTED] On 5/3/06, Satyam [EMAIL PROTECTED] wrote: I used that method initially, some months ago, but finally dropped it. It looked nice at first, but then I started getting into problems and required too many special cases to make it work. In the end, it wasn't a clean nor elegant solution. Satyam, Would you care to give some more details as to those edge cases that swayed you to drop the unique id approach? I've just recently added it to my forms (for those that I find need it), in addition to the redirect method you outlined below. Those two combined seem to really go the distance in creating a reliable exchange of data between client and server, as well as a better experience for the user (since the form is capable of handling a larger set of error cases) Actually, I don't know if any of those 'fixes' actually did anything. I got some repeated log records (some of the operations were updates so they wouldn't harm the data, only update again what was already updated, but the log showed me both updates) and I can't really tell what was wrong and, in the end, those attempts at fixing them didn't work so they didn't fix anything. The redirection technique (which I learned about in this list) never failed me so in the end I dropped investigating any further, and I use that one alone. --- Also, with regards to sending success/failure messages across the redirection of your forms, I'd recommend considering sessions for passing the data. It keeps your URLs clean, and allows you to send complex data a bit easier (IMHO). For example if a user makes an error on a few different form elements, you can send back an array of messages to the user without having to serialize/unserialize in the ugly URL. --- It took a while for me to get used to accept to rely on session data and I'm still not completely comfortable with it. In a couple of places where the confirmation data would be too large to send in the URL, I would just send the primary key and re-read the data from the database, hopefully still cached and not requiring any actual disk access. As for the error messages, they don't go into the redirection which I only do on success. At first I did concatenate errors into a string, each enclosed in p tags and all shown in a div class=errormessage. In one app, and that is the style I will probably follow from now on, the error messages go into an array with the input field name as the key so each message can be shown right by the corresponding field. Actually a style I liked and will try in some real site is to put a simple and small error icon and have the text of the message in the 'alt' attribute so it shows when the cursor is over the icon. In that way, you can signal the place of the error without disrupting the layout of the form with a long text but you are not limited to show too brief a message. Most of the time, the user will realize what the error was anyway. (I'm talking about an intranet system with trained operators and somewhat dense forms). I fancy a floating div somewhere around but not covering the input field in error might also work, like a cartoon balloon dialog, but I'm not sure about it. Satyam -John W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
At 4:30 AM -0700 5/4/06, Paul Novitski wrote: At 11:51 AM 5/3/2006, Phillip S. Baker wrote: I have some articles stored in a MySQL DB. What I want is if the article is above a certain length in characters, to page article through a few pages for site readability. So I would want to print X number of words/characters. Save the where the pointer is, move on to the next page, and display the same amount and so on for as many pages as needed. Phillip, There's a fundamental problem with trying to slice text into resizable web pages the same way it's sliced on paper. Paper pages work because they're set in a fixed font size. When you change the ratio of font size to column width, the places where lines of text wrap changes. Because of the varying lengths of words, strings of words spill over to the next line in non-linear rates. Unless you use a fixed font size (boo, hiss) or you change the font size and the column width at exactly the same rate by sizing your layout in ems, your text columns are going to change in height (line-count) with font resizing. -snip- (good stuff) You could make the problem much more solvable by dishing up whole paragraphs only, and learning to accept (nay, embrace!) the resultant variation in page-length. Paul Paul et al: If the text is organized into paragraphs, which I can't imagine it not being, then the solution can be found in using a combination of javascript and php. Javascript can detect the size (height width) of window the user is currently using and the web site has control over the font size and margins. With that information, via ajax, it's certainly solvable to calculate what text would fit into the space provided and display it in real time. Granted it would make for a boring presentation because no titles or variations in font sizes, but if someone wanted to simply throw text to an open window, one could calculate how many paragraphs would fit in the available space and the users actions (on-load, window-resize) could trigger the operation. Furthermore, if headings where identifiable, then those could be thrown into the mix and calculated as well. tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
On May 4, 2006, at 4:16 AM, Richard Lynch wrote: On Wed, May 3, 2006 6:57 pm, Jochem Maas wrote: a. who said anything about sessions? Jay did. He suggested sucking down the whole article, paginating it all, and cramming the pages into session, presumably so you don't have to suck down the whole article again. Which, by the way, is what I dislike about most of these answers... If the article is REALLY big, a query to get the whole damn thing is slow. That was my thought. Plus if the user closes the browser you loose the session(usually, for anonymous sessions, not logged in users), then you have to do the processing/session storing all over again if they wanted to look at it again right away. Multiply by a couple thousand and your server is doing a lot of work it really doesn't have to if the 'pages' are pre-set and you're only grabbing a small chunk at a time. Plus you can get relevant urls to a 'page' that can be bookmarked, to a degree. Aside from not having to do a lot of text processing, the queries would be simpler too. And the author would still have control over the length of the 'pages', which is probably much preferable to some kind of automatic system that has no concept of context. I'm not saying all of the 'pages' would be exactly the same length, but they would make sense as pages when you read them, if the author knew what they were doing. parsing for html comments that could get blasted by an errant edit. the marker is either there or not - and if it'd borked (e.g. '!-- PAGE MAR') then it would break the page, sure - but so could ANY broken markup so the argument is somewhat moot. besides a routine to strip markers (broken or otherwise) is as simple to write as marker splitting function is. I think the assumption is that the article is actually HTML in the databse... I wasn't making that assumption. define('HTML_stored_in_the_DB_for_dynamic_content', 'bad'); // IMHO :) What if you write a cool pdf generator (or rss feed or whateverNewThingComesAlong) in a couple years to deliver those articles? Wouldn't it be easier to adapt a tag replacer that you already have ( because you're not storing the html, and folks want to be able to make a word bold in the web page 'cause they can do it in MSWord :P) to other formats than try to write an html parser from scratch? (Yeah, I know that you still have the danger of users borking the replacement tags, no idea is perfect) Plus having easy access to 'sections' of articles means that those sections aren't necessarily tied to a particular article. Mix and match(repurpose) anyone? As a personal note, I prefer to read things that have been broken up into logical chunks for me, as opposed to being fed some 2000 word essay all at once. I *hate* scrolling. But then I didn't learn to read on a computer screen either. Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Array Sorting
Hi All, I've got an array which has the following properties: $file_array[$filename] = array (Date = $Date, size = $size, permissions = $permissions); I can quite happily sort the array by filename (using natksort and natkrsort), which I found on the php manual - and for reference have included as a PS What I'm not sure about doing is sorting by say Size or Date? I've again had a look through the php manual but I'm not sure how to sort by a property... Can anyone point me in a direction? Cheers Nunners PS as promised! function natksort($aToBeSorted) { $aResult = array(); $aKeys = array_keys($aToBeSorted); natcasesort($aKeys); foreach ($aKeys as $sKey) { $aResult[$sKey] = $aToBeSorted[$sKey]; } $aToBeSorted = $aResult; return True; } function natkrsort($aToBeSorted) { $aResult = array(); $aKeys = array_keys($aToBeSorted); $aKeys = array_reverse(natcasesort($aKeys)); foreach ($aKeys as $sKey) { $aResult[$sKey] = $aToBeSorted[$sKey]; } $aToBeSorted = $aResult; return True; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Imagemagick Displaying Images
Richard Lynch wrote: Ray Hauge wrote: convert -resize 800x600 AR-M455N_20060420_130446.pdf[0] - The '-' makes it display the contents of the image to stdout. I want to caputre that binary data and somehow display the images inline with the website. Is this possible, or am I living in a dream world ;) http://php.net/ob_start That's obvious. It's necessary but not sufficient. Notice Richard said display the images inline. It's easy if the image is all that is on the page. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Sorting
James Nunnerley wrote: I've got an array which has the following properties: $file_array[$filename] = array (Date = $Date, size = $size, permissions = $permissions); I can quite happily sort the array by filename (using natksort and natkrsort), which I found on the php manual - and for reference have included as a PS What I'm not sure about doing is sorting by say Size or Date? I've again had a look through the php manual but I'm not sure how to sort by a property... Can anyone point me in a direction? http://php.net/usort -- it be thataway! -Stut PS. Please start a new thread instead of just replying to someone elses and changing the subject - it screws up the threading in decent email clients. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: preg_replace_callback
tJey wrote: Hi. I have problem with preg_replace_callback. It seems that my pattern is bad, but I can't find any error. Pattern : \[\s*((\d|\w|_)+)\s*\] this pattern is intended to find strings like [field], [ fi12_eld]... but every time I get warning message Warning: preg_replace_callback(): Delimiter must not be alphanumeric or backslash in test.php on line 100 $pattern= %\[[\s\w]+\]%; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Array Sorting
I think I may have written down my variable structure incorrectly in the first place, which even has me confused... The $file_array[$filename] is I don't think a further array. The sub values are created as follows: $file_array[$filename][Date] = ... $file_array[$filename][Size] = ... Looking at usort, it will put the list of Dates in order (by doing a pure if is bigger or smaller...) but will loose the link between the particular filename and it's date properties. Does that make sense - or am I loosing the plot? Am I also making a mistake by not defining $file_array[$filename]? I don't think so, but would be happy to be corrected! Cheers Nunners -Original Message- From: Stut [mailto:[EMAIL PROTECTED] Sent: 04 May 2006 16:24 To: James Nunnerley Cc: php-general@lists.php.net Subject: Re: [PHP] Array Sorting James Nunnerley wrote: I've got an array which has the following properties: $file_array[$filename] = array (Date = $Date, size = $size, permissions = $permissions); I can quite happily sort the array by filename (using natksort and natkrsort), which I found on the php manual - and for reference have included as a PS What I'm not sure about doing is sorting by say Size or Date? I've again had a look through the php manual but I'm not sure how to sort by a property... Can anyone point me in a direction? http://php.net/usort -- it be thataway! -Stut PS. Please start a new thread instead of just replying to someone elses and changing the subject - it screws up the threading in decent email clients. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with usort
Hi folks, Config is Apache/1.3.34 (Unix) PHP/4.4.1 mod_ssl/2.8.25 OpenSSL/0.9.7i. If my usort callback has in it: if ($aday == $bday) {return 0;} else {return ($aday $bday) ? -1 : 1;} everything works - lots of sort operations happen on the array (three elements) and it sorts correctly. If however, I change it to: $ret_val = 0; if ($aday == $bday) {$ret_val = 0;} else {$ret_val = ($aday $bday) ? -1 : 1;} return ret_val; Then it does not sort correctly and only performs two sort operations (on a three element array). I must be missing something obvious. I'm not the most experienced PHP coder so perhaps some esoteric feature of the language has confounded me. Open to liberal use of the clue by four. :) Cheers! Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Sorting
James Nunnerley wrote: I think I may have written down my variable structure incorrectly in the first place, which even has me confused... The $file_array[$filename] is I don't think a further array. The sub values are created as follows: $file_array[$filename][Date] = ... $file_array[$filename][Size] = ... Looking at usort, it will put the list of Dates in order (by doing a pure if is bigger or smaller...) but will loose the link between the particular filename and it's date properties. Does that make sense - or am I loosing the plot? That is indeed what it will do. If that's a problem you probably also want to define a Filename element for each item... $file_array[$filename][Filename] = $filename; It's worth noting that if you're not using the fact that they're indexed on the filename it's probably faster to use integer keys instead of strings, but don't quote me on that. I'm not overly familiar with the internals of PHP... yet! Am I also making a mistake by not defining $file_array[$filename]? I don't think so, but would be happy to be corrected! PHP is quite relaxed about these things, but from syntactic(?) completeness and security points of view it should really be initialised to an empty array. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with usort
Jon Earle wrote: $ret_val = 0; if ($aday == $bday) {$ret_val = 0;} else {$ret_val = ($aday $bday) ? -1 : 1;} return ret_val; I could be wrong, but I think you need some extra brackets on the else line... else {$ret_val = (($aday $bday) ? -1 : 1);} -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] htmlentities() with utf8
Hello, I want to use htmlentities() with UTF-8, which I can set with the third parameter. But to use the third parameter, I have to provide the second parameter. Currently the default for the second parameter is ENT_COMPAT. But as this might change, I don't want to call htmlentities with htmlentities($text, ENT_COMPAT, UTF-8); all the time. Is there another way? Regards Marten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Creating an OO Shopping Cart
Richard Lynch mailto:[EMAIL PROTECTED] on Thursday, May 04, 2006 2:06 AM said: Contact the bank with which you already HAVE a merchant account for your point-of-sale credit card swiper thingies. Already have the info in front of me. :) If you're re-doing it anyway, you might as well do it right. :-) I totally agree. Thanks Richard! Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Geting feet wet with REGEX and url rewriting (maybe a bit 0T)
Hey all, Every now and then I start on using REGEXs and URL rewriting as needed then stop again, this is one of those times :-) I have a simple url rewite that goes like this: RewriteRule ^blog-([0-9]+).html$ index.php?act=blogid=$1 and I send urls to the page like this: mysite.com/blog/blog-2.html which gets processed like this: index.php?act=blogid=$1 which works perfectly fine, now i would like to add another parameter so the url looks something like this: mysite.com/blog/blog-2-the_great_escape.html which should be processed like this: index.php?act=blogid=$1string=$2 going through the regex tutoral I see I need to use $2 for the second parameter and $3 etc if i keep adding parameters but still getting stumped on the first regex part (eg: ^blog-([0-9]+).html$ ) Thanks! Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) - Fight back spam! Download the Blue Frog. http://www.bluesecurity.com/register/s?user=bXVzaWNndTc%3D __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with usort
On 5/4/06, Jon Earle [EMAIL PROTECTED] wrote: $ret_val = 0; if ($aday == $bday) {$ret_val = 0;} else {$ret_val = ($aday $bday) ? -1 : 1;} return ret_val; You're missing the $ for ret_val on the return line. PHP thus understands the return value as a string, ret_val, which would be taken as 0. Since all elements are now equal, the order of the elements in the array is undefined. Rabin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with usort
On 5/4/06, Stut [EMAIL PROTECTED] wrote: Jon Earle wrote: $ret_val = 0; if ($aday == $bday) {$ret_val = 0;} else {$ret_val = ($aday $bday) ? -1 : 1;} return ret_val; I could be wrong, but I think you need some extra brackets on the else line... else {$ret_val = (($aday $bday) ? -1 : 1);} Not true actually, it's a quick if/else using the ternary operator. It's also difficult to read all on one line: $ret_val = 0; if ($aday == $bday) { $ret_val = 0; } else { // what this does is test if $aday is less than $bday. // If so, it sets $ret_val to -1. If not, it sets $ret_val to 1. $ret_val = ($aday $bday) ? -1 : 1; } return ret_val; HTH, John W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with usort
John Wells wrote: Not true actually, it's a quick if/else using the ternary operator. It's also difficult to read all on one line: $ret_val = 0; if ($aday == $bday) { $ret_val = 0; } else { // what this does is test if $aday is less than $bday. // If so, it sets $ret_val to -1. If not, it sets $ret_val to 1. $ret_val = ($aday $bday) ? -1 : 1; } return ret_val; I'm aware of that. I wasn't sure of the precedence between = and ?. Anyway, as someone else has pointed out, there is a missing $ on the return value. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with usort
On 5/4/06, Stut [EMAIL PROTECTED] wrote: Anyway, as someone else has pointed out, there is a missing $ on the return value. -Stut Yup, missed that one too. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Geting feet wet with REGEX and url rewriting (maybe a bit 0T)
On 5/4/06, Ryan A [EMAIL PROTECTED] wrote: RewriteRule ^blog-([0-9]+).html$ index.php?act=blogid=$1 This is fine, but you should really be escaping the . (by writing it as \.). Otherwise, it matches any character, not just the literal period. mysite.com/blog/blog-2-the_great_escape.html which should be processed like this: index.php?act=blogid=$1string=$2 going through the regex tutoral I see I need to use $2 for the second parameter and $3 etc if i keep adding parameters but still getting stumped on the first regex part (eg: ^blog-([0-9]+).html$ ) You just need to add another pair of parenthesis to get the second match. For your case, it'll be something like (untested): RewriteRule ^blog-([0-9]+)-([^\.]+)\.html$ index.php?act=blogid=$1string=$2 Rabin -- http://rab.in -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with usort
Rabin Vincent escribió: On 5/4/06, Jon Earle [EMAIL PROTECTED] wrote: $ret_val = 0; if ($aday == $bday) {$ret_val = 0;} else {$ret_val = ($aday $bday) ? -1 : 1;} return ret_val; You're missing the $ for ret_val on the return line. PHP thus understands the return value as a string, ret_val, which would be taken as 0. Since all elements are now equal, the order of the elements in the array is undefined. Rabin Actually, PHP first looks for a constant named ret_val, then it uses a string containing ret_val. So, if there was a constant with that name, that value would have been used. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php script fails when run from cron
I finally got it working and Chris was correct. It appears that cron was using the wrong php. Pumping the errors of even logging them wouldn't have helped as I was tweaking the ini for the php I thought it was using. When I explicitly tell it which one to use, it seems to work fine. Thanks! On 5/4/06, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] The code then goes on to move some data from a remote SQL Server db to the local mysql. When finished, the log stops at got two classes. I am trying to debug now to see which of the two classes it seems to be failing on. I don't have anything in the php error log. The MSSQL connection uses freetds so I am not sure if it is something there but again this script runs fine with just php myfile.php. [/snip] Are you logging errors? If so you will likely locate the cause there. If I were to hazard a guess at would be because include files are not getting included as I have seen that behavior before.
Re: [PHP] Re: php and ssl
Schalk Neethling wrote: Barry wrote: Schalk schrieb: Greetings All, I am currently implementing a form for a client that will run over https. Now, all is good and well except, for some reason when the form loads in IE the lock in the status bar displays for a short while and then goes away, it is fine in Firefox though. The way I have the form coded is something like this: The page in question is here: https://www.epda.cc/donation_eng.php Is there any reason why coding the form like this will cause IE to think that the form is not secure and not loaded over https? Thank you in advance! Since you load it framewise. is there probably a problem with the loaded frames? It has nothing to do with PHP though. Barry, Not sure what you mean by frames If you look at the HTML source there are no frames in there. Do you mean the fieldset? Has anyone been able to see what might be causing the problem in IE? I am really stumped :( It may even be something simple but, I cannot see why the way the form is coded will cause this problem. Any thoughts on this will be much appreciated. Thanks! -- Kind Regards Schalk Neethling Web Developer.Designer.Programmer.President Volume4.Business.Solution.Developers -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Geting feet wet with REGEX and url rewriting (maybe a bit 0T)
Works perfectly, thank you! Just got a bit confused after all the reading. Regards, Ryan You just need to add another pair of parenthesis to get the second match. For your case, it'll be something like (untested): RewriteRule ^blog-([0-9]+)-([^\.]+)\.html$ index.php?act=blogid=$1string=$2 Rabin -- http://rab.in -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) - Fight back spam! Download the Blue Frog. http://www.bluesecurity.com/register/s?user=bXVzaWNndTc%3D __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
At 07:12 AM 5/4/2006, tedd wrote: If the text is organized into paragraphs, which I can't imagine it not being, then the solution can be found in using a combination of javascript and php. Javascript can detect the size (height width) of window the user is currently using and the web site has control over the font size and margins. With that information, via ajax, it's certainly solvable to calculate what text would fit into the space provided and display it in real time. Granted it would make for a boring presentation because no titles or variations in font sizes, but if someone wanted to simply throw text to an open window, one could calculate how many paragraphs would fit in the available space and the users actions (on-load, window-resize) could trigger the operation. Furthermore, if headings where identifiable, then those could be thrown into the mix and calculated as well. Yes: cutting text into arbitrary column-lengths is most likely a client-side task and therefore not on-topic for this list, but since you've opened the door... Headlines and other variations in text size need not be a problem. No need to calculate rendered text size: let the browser do it. The way I might approach this is to feed more text to the page than I know will fit, enclose it in a container that JavaScript sets to {overflow: hidden}, and use JavaScript to detect where (at which paragraph and word) the visible text block ends. One way to find the last visible word would be to enclose a word in a span, compare its rendered position to the height of the text container, remove the span, and continue until we find a word that's lower than the bottom of the container. The most efficient way to perform this search might be to check the first word of each paragraph until a hidden word is found, then work backward from there. Once JavaScript had determined the last word on the rendered page (or the first word to be displayed on the next page), it would communicate this to PHP -- either immediately [via new Image() src or XMLHttpRequest] or on the next page request through the navigation hyperlinks or form submit. To accommodate font-resizing, JavaScript could set a self-timer to re-check the last visible first hidden words on the page and see if their 'shown' status had changed. If it has, all it has to do is report the new page boundary to PHP. This would have to work in the absence of client-side scripting, so it's JavaScript that sets {overflow: hidden} on the text container. This technique could also be used to flow text across multiple columns. I don't know how close it comes to existing techniques of calculating text-column-length. In my Copious Spare Time I'll do a proof of concept to see how this flies. Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] What editor do you use?
I am currently looking for a good PHP editor for Windows. I know, the question must have been asked so many times, but I thought I could ask it again now that a few editors have evolved, others have appeared. Before I used something called Ultraedit but I was disappointed by the lack of features, I love the search capabilities, but the autocomplete is very clumsy as well as the HTML elements. I have tried Zend 5.0 beta and I am not satisfied for several reasons. Although I love the powerful debugger and I think it is very code smart, I dislike the lack of HTML elements. If I want to add a table with 2 rows and 3 columns, I have to type the HTML tags and I am trying to save time with that. I love the powerful coding capabilites but dislike the lack of a WYSIWYG interface. I am also using Dreamweaver 8, which has become a lot smarter than it used to be, has a lot of nice bells and whistles but it is not as code smart as Zend and it becomes lost if you use the very standard technique of headers and footers. But I love the HTML editor otherwise, it is quite powerful. I am looking for something which would be code smart as well as a good HTML editor, a mix of Zend and Dreamweaver. Where else should I look? I also have Visual Studio, what about Visual PHP, is it worth a shot? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] What editor do you use?
[snip] I am currently looking for a good PHP editor for Windows. I know, the question must have been asked so many times, but I thought I could ask it again now that a few editors have evolved, others have appeared. [/snip] Eclipse. You could also STFA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mail and hotmail
Hi Peter, RFC 2156 (http://www.faqs.org/rfcs/rfc2156.html) defines the importance header as following: importance = low / normal / high Which means that you can either use the values low, normal or high HTH, Christian The only one I do not know what to set it to is Importance. What values are possible there? Is it the same as for X-priority? Regards, Peter -Original Message- From: Angelo Zanetti [mailto:[EMAIL PROTECTED] Sent: Thursday, May 04, 2006 5:53 PM To: Peter Lauri Cc: php-general@lists.php.net Subject: Re: [PHP] Mail and hotmail Peter Lauri wrote: Best group member, I am sending email to a hotmail thru PHP. When I send it like this it arrives (in the junk mail, but it arrives): mail('[EMAIL PROTECTED]', 'A nice subject', 'Some text'); It works well, but I want to change the FROM header so I do this: mail('[EMAIL PROTECTED]', 'A nice subject', 'Some text', 'From: Peter Lauri [EMAIL PROTECTED]'); This email does not arrive to the Hotmail inbox. If I send to a regular email, like Google Email (gmail) or a regular POP3 it arrives without problems. Anyone who has experienced this problem with sending emails to Hotmail? And how do you solve it? Best regards, Peter Lauri you need to set your mail headers for the mail to be assumed valid, namely: X-Sender From Date Subject Delivered-to MIME-Version Reply-To Content-type X-Priority Importance Return-Path X-Mailer HTH Angelo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Maximum URL length (Pretty much 0T)
Hey, When i started on the net I was told that if sending than 256 characters via a form to use a POST instead of a GET method, now that I am playing with URL rewriting I wanted to know if member served me right, but searching via google I see that IE takes up to 2040-2083 characters in a GET, another article warns that it varies from server to server too.. I'm sure quite a few of you must be fiddling with URLs nearly every day so a little of your feedback would be appreciated. - Do you stick within the 256 character mark? (or my memory is false anyway and that limit never existed) - Till what character (eg: 200) do you push it and still feel safe? - Any idea if apache bitches if the url string is too long? (will be searching via the SEs for this, but if you know the answer it would confirm it for me) - Anything else you wish to add pertaining to the above. Thanks! Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) - Fight back spam! Download the Blue Frog. http://www.bluesecurity.com/register/s?user=bXVzaWNndTc%3D __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Maximum URL length (Pretty much 0T)
[snip] - Anything else you wish to add pertaining to the above. [/snip] People who use GET requests are lazy. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php