php-general Digest 25 Jan 2007 14:33:22 -0000 Issue 4589
php-general Digest 25 Jan 2007 14:33:22 - Issue 4589 Topics (messages 247745 through 247778): Re: most powerful php editor 247745 by: Roman Neuhauser 247746 by: Curt Zirzow 247748 by: Jochem Maas 247749 by: John Meyer 247750 by: Robert Cummings 247751 by: Robert Cummings 247752 by: Larry Garfield 247753 by: Robert Cummings 247754 by: tedd 247755 by: tedd 247756 by: Larry Garfield 247761 by: David Robley 247763 by: Roman Neuhauser 247768 by: Sancar Saran 247769 by: Roman Neuhauser 247772 by: clive 24 by: Robert Cummings Re: JPEG info needed 247747 by: Gerry Danen Re: Validating a link in php 247757 by: sleestak2.earthlink.net 247762 by: Frank Arensmeier sortind arrays 247758 by: William Stokes 247764 by: Paul Novitski 247766 by: Roman Neuhauser 247776 by: Alexander Sagen Parsing AJAX post data -- The Way 247759 by: M5 247760 by: M5 247765 by: Roman Neuhauser 247770 by: Stut 247774 by: Bernhard Zwischenbrugger 247775 by: Colin Guthrie Re: Unserialize problem (and or bug) 247767 by: Sancar Saran Re: preg_match problem 247771 by: Jim Lucas Re: Multi lingual pages 247773 by: Satyam Send Email to Mobiles 247778 by: Marcelo Ferrufino Murillo Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: php-general@lists.php.net -- ---BeginMessage--- # [EMAIL PROTECTED] / 2007-01-24 18:23:10 -0600: On Wed, January 24, 2007 7:41 am, Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-24 13:57:03 +0200: and also in these days I'm looking for 19 inch (or more) wide LCD sceerns to able to fit longer lines in my screen... Number of reading errors people make grows with line length, this has been known for as long as I remember. You're increasing the probability of bugs in the code, and get tired sooner because following long lines requires more energy. I believe those results are specific to what is being read. Surely it's easier to read: SELECT blah, blah, blah, blah, blah, blah, blah, blah, blah Not for me. SQL is just another programming language, and I fail to see why principles of programming hygiene shouldn't apply to it. Sure, it can be hard to find/read the individual field names, on the rare occasion that you need to do that... Like, on the rare occasion that you need to find a bug in a program with poor formatting. Assuming you actually planned your DB and queries out to fit your application needs in the first place. I guess if you're coding in an unstructured iterative way to design the db, then, yeah, it would be harder on the eyes as you morph that statement into what it should be... :-v That's a strong argument against indenting source code: all you need is a solid design upfront! Of course, if your queries sum up to blah, blah, blah, it might not be worth designing them in the first place. :-^ -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 ---End Message--- ---BeginMessage--- On 1/20/07, Vinicius C Silva [EMAIL PROTECTED] wrote: hi everyone! i'd like to ask something maybe commonly asked here. what is the most powerful php editor? So now we have a 4 day thread of discussing nothing but, this is what i use Curt. ---End Message--- ---BeginMessage--- Curt Zirzow wrote: On 1/20/07, Vinicius C Silva [EMAIL PROTECTED] wrote: hi everyone! i'd like to ask something maybe commonly asked here. what is the most powerful php editor? So now we have a 4 day thread of discussing nothing but, this is what i use let see if we can make it a full week :-P Curt. ---End Message--- ---BeginMessage--- Jochem Maas wrote: Curt Zirzow wrote: On 1/20/07, Vinicius C Silva [EMAIL PROTECTED] wrote: hi everyone! i'd like to ask something maybe commonly asked here. what is the most powerful php editor? So now we have a 4 day thread of discussing nothing but, this is what i use let see if we can make it a full week :-P If we want to argue about this, let's set a few guidelines as to what powerful means. I propose these guidelines 1. Syntax highlighting 2. Web server integration 3. Link checking 4. Browser check in the top three (Mozilla-IE-Opera) Now maybe you disagree, maybe you agree. I'd love to just use vi and type away, but quite frankly I'm not that smart. And if you have your own guidelines, let's hear them. ---End Message--- ---BeginMessage--- On Wed, 2007-01-24 at 18:23 -0600, Richard Lynch wrote: On Wed, January 24, 2007 7:41
Re: [PHP] Unserialize problem (and or bug)
Hi On Thursday 25 January 2007 02:16, Richard Lynch wrote: On Wed, January 24, 2007 9:17 am, Sancar Saran wrote: After updating company test server to dotdeb 5.2.0 it star to give memory problems (even 32mb session). I tought it was because of suhosin. And I cannot update that server to vanilla debian php5 package because it was a sarge so today my company gives me another debian etch (like my home pc). I setup latest php 5.2.0.8 for debian etch. Then unserialize gives another problem Message: unserialize(): Error at offset 1384 of 3177 bytes Code: 8 Line: 419 My pc uses debian etch and have php 5.1.6-5 my scripts working normally. Is there any suggestion for handle this ? What is in the data at byte 1384 that can't be unserialized? some UTF-8 data Are you trying to take data serialized by one version of PHP and unserialize it with another? Yes That does not work in current versions, though discussion on Internals lends hope that future versions will be able to deal intelligently with this situation. Jochem was inform me, then I was re generate that arrays then problem fixed. Check http://bugs.php.net/ for similar bugs -- there may be a patch. Also check with suhosin and Debian bug tracking, as it may be specific to either of those. Currently My machine and target has same php version, Today I may do another transfer. I'll recheck situation, maybe backporting data from server solve the issue. And or I move my machine to more updated PHP... Dotdeb (including suhosin) and standart PHP act very differently. In dotdeb unserialize filling 32 mb'ed session and stop. Vanilla php 5.1.6 (at target server) and 5.2.0 (at target server) giving offset error... More interesting was I'm on so tigh schedule to do someting... Maybe I have to go and burn a candle to St.Murphy God save Jochem and you, because there was no info anywhere in web, yesterday I go crazy. And I bet myself to this serialize/unserialize thing... Many thanks... Sancar -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] most powerful php editor
On Wednesday 24 January 2007 15:41, Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-24 13:57:03 +0200: and also in these days I'm looking for 19 inch (or more) wide LCD sceerns to able to fit longer lines in my screen... Number of reading errors people make grows with line length, this has been known for as long as I remember. You're increasing the probability of bugs in the code, and get tired sooner because following long lines requires more energy. Yes and no, because these days I'm obsessed very very large arrays like $arr['this']['is']['what']['i']['m']['looking']['for']; And If I start to do if( ($arr['this']['is']['what']['i']['m']['looking']['for'] 5) ($arr['this']['is']['what']['i']['m']['looking']['for'] 10)) blah blah then problem begins :) -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] most powerful php editor
# [EMAIL PROTECTED] / 2007-01-25 11:06:22 +0200: On Wednesday 24 January 2007 15:41, Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-24 13:57:03 +0200: and also in these days I'm looking for 19 inch (or more) wide LCD sceerns to able to fit longer lines in my screen... Number of reading errors people make grows with line length, this has been known for as long as I remember. You're increasing the probability of bugs in the code, and get tired sooner because following long lines requires more energy. Yes and no, because these days I'm obsessed very very large arrays like $arr['this']['is']['what']['i']['m']['looking']['for']; Well, ugh! And If I start to do if( ($arr['this']['is']['what']['i']['m']['looking']['for'] 5) ($arr['this']['is']['what']['i']['m']['looking']['for'] 10)) blah blah then problem begins :) That's atrocious no matter how wide your screen is. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing AJAX post data -- The Way
M5 wrote: Just wondering what smart people do for parsing data sent by the Javascript XMLHTTP object--e.g., http.send(post,url,true)... In a normal form submit, the $_POST global nicely allocates form elements as array elements automatically. But with the AJAX way, the data get stuffed inside $HTTP_RAW_POST_DATA as a string, thereby making extraction more tedious. What format is the data you are posting in? If it's in the usual format, PHP should parse it for you. An AJAX (hate that acronym) post request is no different to a normal post, unless you are not posting in the form format (var1=val2var2=val2). -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_match problem
Beauford wrote: Here is my rendition of what I think you are looking for. $str = 'tab()/space( )/[EMAIL PROTECTED]*();:...'; if ( preg_match('|[EMAIL PROTECTED]*();:_. /\t-]+$|', $str) ) { echo 'success'; } else { echo 'failure'; } Here is the problem, and it is strange. If I enter each of the above characters into my form one at a time and hit submit after each one, NO error is produced for any of them. If I cut and past this all at once: [EMAIL PROTECTED]*();:_.\ then an error IS returned. If I continue to remove one character at a time, submitting the form each time, errors ARE still produced. This is the code in a nutshell: If(isset($submit)) { $name = stripslashes($_POST['name']); I have tried this with and without $formerror = array(); unset($result); I have tried this with and without if($result = ValidateString($name)) { $formerror['name'] = $invalidcharacters; Function ValidateString($string) { if (!preg_match('|[EMAIL PROTECTED]*();:_. /\t-]+$|', $string) ) { return invalidchars; } } } Form Stuff input name=name size=30 type=text /form Thanks Here is a link to a page that has this on it, but with the added ' Plus a link to the source code for it. Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] most powerful php editor
Vinicius C Silva wrote: hi everyone! i'd like to ask something maybe commonly asked here. what is the most powerful php editor? Just thought I'd add my bit, I used to use phpedit when I developed on a windows systems, then I started using Zend. Ive now moved to linux and still use Zend and I am slowly learning VIM. Now, eddie, the dude I work with is a vi master, he does stuff in that editor that Zend can't even comprehend. Watching eddie work with vi, is like watching a conductor conducting a orchestra, quick, efficient and pretty much amazing. clive ps. I dont really listen to orchestral music. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multi lingual pages
I wrote something about this, but it is in Spanish: http://www.satyam.com.ar/blog/2007/01/17/internacionalizacion-y-localizacion-indice/ Satyam - Original Message - From: Otto Wyss [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Wednesday, January 24, 2007 10:44 PM Subject: [PHP] Multi lingual pages I'd like to make my pages multi lingual, showing everything in the language the user chooses. My pages show mostly static text. So what's the usual implementation for this case. O. Wyss -- 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] Parsing AJAX post data -- The Way
hi The X in AJAX says that the data are XML Data. To parse XML I use DOM. It is also possible to validate the data using RelaxNG, DTD or XMLSchema before processing. A receiver in PHP looks like ?php //read the string ($HTTP_RAW_POST_DATA is by default //not active - use php://input) $content=file_get_contents(php://input); //make a dom object //many people know DOM already from programming javascript $dom=domDocument::loadXML($content); //validate with DTD,RelaxNG or XMLSchema //http://at.php.net/manual/de/function.dom-domdocument-relaxngvalidate.php if($dom-relaxNGValidate(test.rng)){ //than read the data you need //for example if your XML looks like //person born=1935 //firstnameDalei/firstnamelastnameLama/lastname ///person $firstname=$dom-getElementsByTagName('firstname')-item(0); $lastname=$dom-getElementsByTagName('lastname')-item(0); $born=$dom-documentElement-getAttribute('born'); }else{ echo data are not valid; } ? If you don't like XML (AJAX) use JSON. Bernhard Am Donnerstag, den 25.01.2007, 00:00 -0700 schrieb M5: Just wondering what smart people do for parsing data sent by the Javascript XMLHTTP object--e.g., http.send(post,url,true)... In a normal form submit, the $_POST global nicely allocates form elements as array elements automatically. But with the AJAX way, the data get stuffed inside $HTTP_RAW_POST_DATA as a string, thereby making extraction more tedious. Any ideas? ...Rene -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Parsing AJAX post data -- The Way
Stut wrote: M5 wrote: Just wondering what smart people do for parsing data sent by the Javascript XMLHTTP object--e.g., http.send(post,url,true)... In a normal form submit, the $_POST global nicely allocates form elements as array elements automatically. But with the AJAX way, the data get stuffed inside $HTTP_RAW_POST_DATA as a string, thereby making extraction more tedious. What format is the data you are posting in? If it's in the usual format, PHP should parse it for you. An AJAX (hate that acronym) post request is no different to a normal post, unless you are not posting in the form format (var1=val2var2=val2). Yes, just to elaborate, consider the following (simple AJAX post (using prototype.js as it's great!). function SendRemote(action) { new Ajax.Request('backend.php', { parameters: 'submit='+action }); } This sends a simple form POSTED to the server with one form element (named submit) which will be available to the server as $_POST['submit']. If you want to add more, just use the as Stut suggests, e.g.: function SendRemote(action) { new Ajax.Request('backend.php', { parameters: 'submit='+action+'var2=xxx' }); } etc. HTH Col. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sortind arrays
Roman Neuhauser skrev: # [EMAIL PROTECTED] / 2007-01-25 08:12:14 +0200: How can I sort an array like this so that it would be ASC ordered by the [1] key in subarrays? I need to maintain only the subarray key - value pairs. (Do I make sense?) Array ( [0] = Array ( [0] = Logo [1] = NameC [2] = Home [3] = url ) [1] = Array ( [0] = Logo [1] = NameA [2] = Home [3] = url ) [2] = Array ( [0] = Logo [1] = NameG [2] = Home [3] = url ) } http://www.php.net/usort I think usort would be a bit overkill, he would probably find himself making a function to sort and maintain the association between the subarrays. Go with array_multisort, it would be a one-liner. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] most powerful php editor
On Thu, 2007-01-25 at 10:12 +, Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-25 11:06:22 +0200: On Wednesday 24 January 2007 15:41, Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-24 13:57:03 +0200: and also in these days I'm looking for 19 inch (or more) wide LCD sceerns to able to fit longer lines in my screen... Number of reading errors people make grows with line length, this has been known for as long as I remember. You're increasing the probability of bugs in the code, and get tired sooner because following long lines requires more energy. Yes and no, because these days I'm obsessed very very large arrays like $arr['this']['is']['what']['i']['m']['looking']['for']; Well, ugh! And If I start to do if( ($arr['this']['is']['what']['i']['m']['looking']['for'] 5) ($arr['this']['is']['what']['i']['m']['looking']['for'] 10)) That's terrible... first off we'll start by doing the following: if( ($arr['this']['is']['what']['i']['m']['looking']['for'] 5) ($arr['this']['is']['what']['i']['m']['looking']['for'] 10) ) Next we'll chop off the redundant bits: if( $arr['this']['is']['what']['i']['m']['looking']['for'] 5 $arr['this']['is']['what']['i']['m']['looking']['for'] 10 ) Now we'll make sure we don't throw any sloppy errors: if( isset( $arr['this']['is']['what']['i']['m']['looking']['for'] ) $arr['this']['is']['what']['i']['m']['looking']['for'] 5 $arr['this']['is']['what']['i']['m']['looking']['for'] 10 ) :) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Send Email to Mobiles
Hi guys, I need to send a email to mobiles I don´t know if I have to use the function mail( ) or if I have to use other one. Thanks your help
RE: [PHP] sortind arrays
On 25 January 2007 10:55, Alexander Sagen wrote: Roman Neuhauser skrev: # [EMAIL PROTECTED] / 2007-01-25 08:12:14 +0200: How can I sort an array like this so that it would be ASC ordered by the [1] key in subarrays? I need to maintain only the subarray key - value pairs. (Do I make sense?) Array ( [0] = Array ( [0] = Logo [1] = NameC [2] = Home [3] = url ) [1] = Array ( [0] = Logo [1] = NameA [2] = Home [3] = url ) [2] = Array ( [0] = Logo [1] = NameG [2] = Home [3] = url ) } http://www.php.net/usort I think usort would be a bit overkill, he would probably find himself making a function to sort and maintain the association between the subarrays. Go with array_multisort, it would be a one-liner. What total tosh! array_multisort() won't handle this one -- usort() is correct. The only function needed is a (one-liner!) custom comparison to compare individual [1] elements -- usort() takes care of all the rest: function compare_1($a, $b) { return strcmp($a[1], $b[1]); } usort($array, 'compare_1'); Or even, for single use, collapse it to: usort($array, create_function('$a,$b', 'return strcmp($a[1], $b[1]);'); 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] php from address
Hi everyone, In November I sent a mail to this list asking how to get the mail From header right, I solved that but I still have a problem. The solution was using the -f option like this: $frommail = [EMAIL PROTECTED]; mail($to, $subject, $message, $headers,-f$frommail); The from address is correct now but the displayed name is still www-data (or apache, depends on the server configuration). The header looks like this: From: [EMAIL PROTECTED] (www-data) Is there anyway to change this? Thanks, regards Chantal -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fwd: Re: [PHP] most powerful php editor
On Thursday 25 January 2007 08:14, David Robley wrote: tedd wrote: At 9:07 PM -0500 1/24/07, Robert Cummings wrote: Code structure Ahem to that! You're on a roll brother -- keep going. Can I get another Ahem?! tedd I'll see your 'Ahem' and raise you an 'Amen' :-) 'n a God Bless. Cheers -- David Robley Vultures only fly with carrion luggage. Today is Setting Orange, the 25th day of Chaos in the YOLD 3173. -- --- Børge Kennel Arivene http://www.arivene.net --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sortind arrays
Ford, Mike skrev: On 25 January 2007 10:55, Alexander Sagen wrote: Roman Neuhauser skrev: # [EMAIL PROTECTED] / 2007-01-25 08:12:14 +0200: How can I sort an array like this so that it would be ASC ordered by the [1] key in subarrays? I need to maintain only the subarray key - value pairs. (Do I make sense?) Array ( [0] = Array ( [0] = Logo [1] = NameC [2] = Home [3] = url ) [1] = Array ( [0] = Logo [1] = NameA [2] = Home [3] = url ) [2] = Array ( [0] = Logo [1] = NameG [2] = Home [3] = url ) } http://www.php.net/usort I think usort would be a bit overkill, he would probably find himself making a function to sort and maintain the association between the subarrays. Go with array_multisort, it would be a one-liner. What total tosh! array_multisort() won't handle this one -- usort() is correct. The only function needed is a (one-liner!) custom comparison to compare individual [1] elements -- usort() takes care of all the rest: function compare_1($a, $b) { return strcmp($a[1], $b[1]); } usort($array, 'compare_1'); Or even, for single use, collapse it to: usort($array, create_function('$a,$b', 'return strcmp($a[1], $b[1]);'); 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 Hm, yes.. I read the question a bit quick I think, sorry about that. :) Cheers -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Parsing AJAX post data -- The Way
[EMAIL PROTECTED] / 2007-01-24 23:41:19 -0700: Just wondering what smart people do for parsing data sent by the Javascript XMLHTTP object--e.g., http.send(post,url,true)... In a normal form submit, the $_POST global nicely allocates form elements as array elements automatically. But with the AJAX way, the data get stuffed inside $HTTP_RAW_POST_DATA as a string, thereby making extraction more tedious. Try setting this header before sending your Ajax request: http_request.setRequestHeader(Content-type, application/x-www-form-urlencoded); Then $_POST should have an array, as expected. But $HTTP_RAW_POST_DATA will not be available. -- _ Myron Turner http://www.room535.org http://www.bstatzero.org http://www.mturner.org/XML_PullParser/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] preg_match problem
Hi Jim, Thanks for all the help, but where is the link. Here is a link to a page that has this on it, but with the added ' Plus a link to the source code for it. Jim -- 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] preg_match problem
Beauford wrote: Hi Jim, Thanks for all the help, but where is the link. Here is a link to a page that has this on it, but with the added ' Plus a link to the source code for it. Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php sorry that is what I get for sending things that early in the morning. :( http://www.cmsws.com/examples/php/preg_match/example01.php -- Enjoy, Jim Lucas Different eyes see different things. Different hearts beat on different strings. But there are times for you and me when all such things agree. - Rush -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php from address
Chantal Rosmuller wrote: Hi everyone, In November I sent a mail to this list asking how to get the mail From header right, I solved that but I still have a problem. The solution was using the -f option like this: $frommail = [EMAIL PROTECTED]; mail($to, $subject, $message, $headers,-f$frommail); The from address is correct now but the displayed name is still www-data (or apache, depends on the server configuration). The header looks like this: From: [EMAIL PROTECTED] (www-data) Is there anyway to change this? Thanks, regards Chantal $frommail = [EMAIL PROTECTED]; mail($to, $subject, $message, $headers,-f$frommail); is an extremely ugly way to pass variables IMO. $frommail = [EMAIL PROTECTED]; mail($to, $subject, $message, $headers, -f.$frommail); is a lot nicer IMO. Anyway, to get back to you. The name you want would be supplied by having the header From: [EMAIL PROTECTED] in the following format: From: MyName Goes Here [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Send Email to Mobiles
Marcelo Ferrufino Murillo wrote: Hi guys, I need to send a email to mobiles I don´t know if I have to use the function mail( ) or if I have to use other one. Thanks your help Hi Marcelo, if the mobile phones you are trying to email have Internet connectivity the PHP mail() will enable to send you normal email. If however, you with to text those mobile phones, you'll have to look at offers providing email to SMS gateways. Good luck -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing AJAX post data -- The Way
On 25-Jan-07, at 7:49 AM, Myron Turner wrote: [EMAIL PROTECTED] / 2007-01-24 23:41:19 -0700: Just wondering what smart people do for parsing data sent by the Javascript XMLHTTP object--e.g., http.send(post,url,true)... In a normal form submit, the $_POST global nicely allocates form elements as array elements automatically. But with the AJAX way, the data get stuffed inside $HTTP_RAW_POST_DATA as a string, thereby making extraction more tedious. Try setting this header before sending your Ajax request: http_request.setRequestHeader(Content-type, application/x-www- form-urlencoded); Then $_POST should have an array, as expected. But $HTTP_RAW_POST_DATA will not be available. Yes, that is the trick, thank you. I didn't realize sending the correct header would then make $_POST do it's magic with var=arg into an array, but now it works as desired. Thanks everyone for the assistance. ...Rene -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] bit wise math? Is there a function to easily return the bits?
Is there a php function I can call to pass in a number and get the values returned? For example, pass in 7 and get 1,2,4 ? Thanks!
Re: [PHP] bit wise math? Is there a function to easily return the bits?
If there isn't a function to do exactly what you want, you could use dec2bin() to at least get the binary and work from there: http://us3.php.net/manual/en/function.decbin.php -TG = = = Original message = = = Is there a php function I can call to pass in a number and get the values returned? For example, pass in 7 and get 1,2,4 ? Thanks! ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] bit wise math? Is there a function to easily return the bits?
function bits($num) { $bit_array = str_split(strrev(decbin(intval($num; $val_array = array(); foreach ($bit_array as $pow = $bit) { if ($val = $bit * pow(2,$pow)) $val_array[] = $val; } return($val_array); } (I wanted to see if I could write it in few LOC.) I wonder if there's a faster way... jon blackwater dev wrote: Is there a php function I can call to pass in a number and get the values returned? For example, pass in 7 and get 1,2,4 ? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] retrieve all the groups a user is memberOf from active directory?
Hi, Sorry if the top is not closely PHP related. But I need to accomplish it using PHP. I can query the attribute 'memberOf' of a user from the active directory server with no problem. The challenge I'm facing now is how to obtain all the groups a user is member of. In many cases, a user can be in many groups which could be nested. Say, user is a member of group B which is a member of group A. So user should be member of group A implicitly. But in active directory, user's account only has memberOf: CN=Group_B,OU=security groups,OU=Users,OU=Coll,DC=some,DC=edu I can then check if Group_B's LDAP entry has any 'memberOf' attribute, so on and so on. If user's LDAP entry has multiple 'memberOf' attributes, I have to check each one to see if each group has any parent groups. Anybody ever had to deal with such a kind of issue and would like to shed some light (better with some code samples) how it should be done effectively? Any ideas would be greatly appreciated. Thanks, Bing -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] bit wise math? Is there a function to easily return the bits?
# [EMAIL PROTECTED] / 2007-01-25 14:34:51 -0500: function bits($num) { $bit_array = str_split(strrev(decbin(intval($num; $val_array = array(); foreach ($bit_array as $pow = $bit) { if ($val = $bit * pow(2,$pow)) $val_array[] = $val; } return($val_array); } (I wanted to see if I could write it in few LOC.) I wonder if there's a faster way... I didn't time either version, and I'm no mathematician either, so this is prolly a stupid solution. ?php function bitarray($ored) { $rv = array(); for ($v = 1; $v = $ored; $v *= 2) { if ($ored $v) { array_push($rv, $v); } } return $rv; } class SingleBitTest extends Tence_TestCase { private function doTest($int) { return $this-assertEquals( array($int), bitarray($int) ); } function testE_ERROR() { return $this-doTest(E_ERROR); } function testE_WARNING() { return $this-doTest(E_WARNING); } function testE_NOTICE() { return $this-doTest(E_NOTICE); } function testE_USER_ERROR() { return $this-doTest(E_USER_ERROR); } function testE_USER_WARNING() { return $this-doTest(E_USER_WARNING); } function testE_USER_NOTICE() { return $this-doTest(E_USER_NOTICE); } } class BitArrayTest extends Tence_TestCase { private function doTest(array $expected, $int) { return $this-assertEquals( $expected, bitarray($int) ); } function test7() { return $this-doTest(array(1, 2, 4), 7); } function test8() { return $this-doTest(array(8), 8); } function testERROR_WARNING_NOTICE_STRICT() { return $this-doTest( array(E_ERROR, E_WARNING, E_NOTICE, E_STRICT), E_ERROR|E_WARNING|E_NOTICE|E_STRICT ); } } class bttests extends Tence_TestSuite { function __construct() { $this -add(new SingleBitTest) -add(new BitArrayTest) ; } } ? -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] bit wise math? Is there a function to easily return the bits?
Jon Anderson wrote: function bits($num) { $bit_array = str_split(strrev(decbin(intval($num; $val_array = array(); foreach ($bit_array as $pow = $bit) { if ($val = $bit * pow(2,$pow)) $val_array[] = $val; } return($val_array); } (I wanted to see if I could write it in few LOC.) I wonder if there's a faster way... jon blackwater dev wrote: Is there a php function I can call to pass in a number and get the values returned? For example, pass in 7 and get 1,2,4 ? Thanks! and for those of us running PHP5.x here is a working example function bits($num) { $bit_array = split('.',strrev(decbin(intval($num; $val_array = array(); foreach ($bit_array as $pow = $bit) { if ($val = $bit * pow(2,$pow)) $val_array[] = $val; } return $val_array; } -- Enjoy, Jim Lucas Different eyes see different things. Different hearts beat on different strings. But there are times for you and me when all such things agree. - Rush -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] retrieve all the groups a user is memberOf from active directory?
On Thu, January 25, 2007 3:07 pm, Bing Du wrote: Sorry if the top is not closely PHP related. But I need to accomplish it using PHP. I can query the attribute 'memberOf' of a user from the active directory server with no problem. The challenge I'm facing now is how to obtain all the groups a user is member of. In many cases, a user can be in many groups which could be nested. Say, user is a member of group B which is a member of group A. So user should be member of group A implicitly. But in active directory, user's account only has memberOf: CN=Group_B,OU=security groups,OU=Users,OU=Coll,DC=some,DC=edu I can then check if Group_B's LDAP entry has any 'memberOf' attribute, so on and so on. If user's LDAP entry has multiple 'memberOf' attributes, I have to check each one to see if each group has any parent groups. Anybody ever had to deal with such a kind of issue and would like to shed some light (better with some code samples) how it should be done effectively? Any ideas would be greatly appreciated. I don't know hardly anything about LDAP, and even less about Active Directory, but if you can't find a built-in function to do this and have to write your own, it should end up looking something like: function groups($user, $groups = null){ //very first time, initialize $groups to empty array: if (is_null($groups)) $groups = array(); //Find all the groups that his user/group is a memberOf: $member_of = //do your LDAP here to find the memberOf: //ex: CN=Group_B,OU=security groups,OU=Users,OU=Coll,DC=some,DC=edu //Look at each group in turn $member_of = explode(',', $member_of); foreach($member_of as $group){ //Skip any groups we have already seen: if (isset($groups[$group])) continue; //Add it to the list of groups: $groups[$group] = $group; //check for super-groups of this group: $groups = array_merge($groups, groups($group, $groups)); } } -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] bit wise math? Is there a function to easily return the bits?
At 1/25/2007 11:16 AM, blackwater dev wrote: Is there a php function I can call to pass in a number and get the values returned? For example, pass in 7 and get 1,2,4 ? Here's a slightly more off-the-wall contribution: function bin2array($iDecimal) { $aResult = array_reverse(explode(\r\n, chunk_split (decbin($iDecimal), 1))); array_walk($aResult, 'doPower'); return $aResult; } function doPower($iValue, $iIndex) { $iValue = $iValue * pow(2, $iIndex); } Here's the break-down of that eye-crossing first statement: array_reverse(explode(\r\n, trim(chunk_split (decbin($iDecimal), 1; using $iDecimal = 6: $a = decbin($iDecimal) -- '110' $b = chunk_split($a, 1) -- '1\r\n1\r\n0' $c = explode(\r\n, $b); // array(1,1,0) $d = array_reverse($c); // array(0,1,1) (If you're using PHP5 you can use split() instead of chunk_split() and explode().) The doPower function performs this transform on each member of the array: $iValue = $iValue * pow(2, $iIndex); Ix Val Math 0 0 0 * 2^0 = 0 1 1 1 * 2^1 = 2 2 1 1 * 2^2 = 4 Regards, Paul __ Juniper Webcraft Ltd. http://juniperwebcraft.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] bit wise math? Is there a function to easily return the bits?
On Thu, January 25, 2007 1:34 pm, Jon Anderson wrote: function bits($num) { $bit_array = str_split(strrev(decbin(intval($num; $val_array = array(); foreach ($bit_array as $pow = $bit) { if ($val = $bit * pow(2,$pow)) $val_array[] = $val; } return($val_array); } (I wanted to see if I could write it in few LOC.) I wonder if there's a faster way... //these might be marginally faster... function bits($num){ $bits = array(); $bin = decbin(intval($num)); $v = 1; for ($b = strlen($bin) - 1; $b = 0; $b--){ if ($bin[$b] === '1') $bits[] = $v; $v = $v * 2; } return $bits; } function bits($num){ $num = (int) $num; $v = 1; $bits = array(); while ($v = $num){ if ($v $num) $bits[] = $v; $v = $v * 2; } return $bits; } I suspect there is a much faster way, somewhere, somehow... jon blackwater dev wrote: Is there a php function I can call to pass in a number and get the values returned? For example, pass in 7 and get 1,2,4 ? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_match problem
On Thu, January 25, 2007 9:53 am, Jim Lucas wrote: http://www.cmsws.com/examples/php/preg_match/example01.php The \t inside of '' has no special meaning. So you don't have a TAB character in there. You need to get \t to mean TAB Once you do that, you should then escape the $ with \$ instead of just $ in order to be blatantly clear, even though $% is not going to parse as a variable anyway. Also, you really ought to use http://php.net/htmlentities on any data going to the browser, as what we see and what you expect won't match up otherwise. echo String is: ', htmlentities($str), 'br /\n; Finally, to be completely pedantic, echoing out raw $_GET data is a big XSS hole waiting to be exploited. Start reading here: http://phpsec.org/ -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing AJAX post data -- The Way
On Thu, January 25, 2007 12:41 am, M5 wrote: Just wondering what smart people do for parsing data sent by the Javascript XMLHTTP object--e.g., http.send(post,url,true)... In a normal form submit, the $_POST global nicely allocates form elements as array elements automatically. But with the AJAX way, the data get stuffed inside $HTTP_RAW_POST_DATA as a string, thereby making extraction more tedious. Call me crazy, but if AJAX is sending POST data correctly, your PHP code shouldn't have to do anything special... POST data is POST data. The $HTTP_RAW_POST_DATA should be there as well, if you turned that on, but that doesn't make $_POST go away. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validating a link in php
On Thu, January 25, 2007 12:06 am, [EMAIL PROTECTED] wrote: Richard Lynch wrote: I dunno what you did wrong with fsockopen... First of all, thanks for taking the time to respond. I had tried fsockopen, but here's the problem. The following calls work as expected, returning a valid file pointer for valid urls and FALSE for invalid urls: $fp = fsockopen(www.example.com, 80, $errno, $errstr, 30); $fp = fsockopen(www.youtube.com, 80, $errno, $errstr, 30); $fp = fsockopen(www.this_url_is_not_valid.com, 80, $errno, $errstr, 30); The call below does not work and always returns FALSE. If I enter the url in a web browser, it works fine, but fsockopen does not like it. $fp = fsockopen(www.youtube.com/v/JqO8ZevPJNk, 80, $errno, $errstr, 30); I think it has something to do with the way YouTube works. Any clues? What is in $errno and $errstr for YouTube? If you surf to that URL with LiveHTTPHeaders, what headers are flying by? If it's a bunch of re-directs, it's possible the fsockopen is getting closed immediately after the headers, I guess, so maybe the socket closes??? That don't sound right. Still, find out what a browser does, and then mimic that well enough that YouTube lets you through. You may end up needing to use http://php.net/curl -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] JPEG info needed
Re-read the docs more carefully. The second arg is optional, and it returns the PRIOR state of the interlaced-ness (or progressive-ness for a JPEG). Standard computer-science function trick to return prior state when altering state, and to simply return state if the second arg is not passed in. So if you do not pass in a second arg, you should be getting the state of the JPEG. Try it. On Wed, January 24, 2007 7:20 pm, Gerry Danen wrote: Richard, imageinterlace() turns the interlace bit on or off. It only returns 1 if you set it to 1 as the second parameter... Thanks Gerry On 1/24/07, Richard Lynch [EMAIL PROTECTED] wrote: On Wed, January 24, 2007 12:08 am, Gerry Danen wrote: One other possibility is to see what happens if you do imagefromjpeg() on a progressive JPEG -- There amy be functions in GD that will tell you if the JPEG is progressive, once you have sucked it into PHP... Any idea which ones to look at? No, but a quick search on php.net for JPEG progress with online documentation from the popup yeilded: http://us3.php.net/manual/en/function.imageinterlace.php If the interlace bit is set and the image is used as a JPEG image, the image is created as a progressive JPEG. This function returns whether the interlace bit is set for the image. Presumably, then, this would work: ?php $filename = '/full/path/to/filename.jpg'; $jpeg = imagecreatefromjpeg($filename); $progressive = imageinterlace($jpeg); if ($progressive) echo $filename is progressive.\n; else echo $filename is NOT progressive.\n; ? -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] most powerful php editor
On Thu, January 25, 2007 3:06 am, Sancar Saran wrote: On Wednesday 24 January 2007 15:41, Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-24 13:57:03 +0200: and also in these days I'm looking for 19 inch (or more) wide LCD sceerns to able to fit longer lines in my screen... Number of reading errors people make grows with line length, this has been known for as long as I remember. You're increasing the probability of bugs in the code, and get tired sooner because following long lines requires more energy. Yes and no, because these days I'm obsessed very very large arrays like $arr['this']['is']['what']['i']['m']['looking']['for']; And If I start to do if( ($arr['this']['is']['what']['i']['m']['looking']['for'] 5) ($arr['this']['is']['what']['i']['m']['looking']['for'] 10)) blah blah then problem begins :) Get back to us after you get over your array obsession... :-) I rarely find myself using more than 2-D, or occasionally, 3-D array lookups within any given section of code. I *might* have deeper arrays, but I'm either going to recurse through them, or break it down by what's actually in all those layers, and do something different as I descend. I would suggest that if one has data nested that deeply, perhaps the stat structure itself is a poor choice. :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] most powerful php editor
On Wed, January 24, 2007 8:07 pm, Robert Cummings wrote: On Wed, 2007-01-24 at 18:23 -0600, Richard Lynch wrote: On Wed, January 24, 2007 7:41 am, Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-24 13:57:03 +0200: and also in these days I'm looking for 19 inch (or more) wide LCD sceerns to able to fit longer lines in my screen... Number of reading errors people make grows with line length, this has been known for as long as I remember. You're increasing the probability of bugs in the code, and get tired sooner because following long lines requires more energy. I believe those results are specific to what is being read. Surely it's easier to read: SELECT blah, blah, blah, blah, blah, blah, blah, blah, blah if it's all on one line, no matter how many fields there are, while trying to read the code as a whole. Sure, it can be hard to find/read the individual field names, on the rare occasion that you need to do that... Dear Mr Lynch, normally I highly respect your commentary on the list, but today I think you've been-a-smoking the crackpipe a tad too much. There is no way in hell one long line of SQL is easier to read than formatted SQL that clearly delineates the clause structure. SELECT A.field1 AS afield1, A.field2 AS afield2, B.field1 AS bfield1, B.field2 AS bfield2, C.field1 AS cfield1, C.field2 AS cfield2, D.field1 AS dfield1, D.field2 AS dfield2 FROM tableA as A LEFT JOIN tableB AS B ON B.fee = A.foo LEFT JOIN tableC AS C ON C.fii = B.fee LEFT JOIN tableD AS D ON D.fuu = C.fii WHERE A.foo = 'someValue' ORDER BY afield1 ASC, cfield2 ASC The above line should be on one line, but my email client might autowrap it. Either way, the following is formatted and is much clearer. SELECT A.field1 AS afield1, A.field2 AS afield2, B.field1 AS bfield1, B.field2 AS bfield2, C.field1 AS cfield1, C.field2 AS cfield2, D.field1 AS dfield1, D.field2 AS dfield2 FROM tableA as A LEFT JOIN tableB AS B ON B.fee = A.foo LEFT JOIN tableC AS C ON C.fii = B.fee LEFT JOIN tableD AS D ON D.fuu = C.fii WHERE A.foo = 'someValue' ORDER BY afield1 ASC, cfield2 ASC While the above is contrived, most of us know such examples happen quite often in the wild. Not only is it easier to read, but the task of adding or removing selected fields is trivial. I meant ONLY the SELECT part on a single line. Only a moron would cram the FROM and all that into the same line. :-) $query = SELECT blah1, blah2, blah3, ... blah147 ; $query .= FROM table1 ; $query .= LEFT OUTER JOIN table2 ; $query .= ON blah7 = blah42 ; $query .= WHERE blah16 ; $query .=AND blah42 ; $query .= ORDER BY blah9, blah8 desc, blah6 ; is what I go for. The SELECT line is the only one that ever gets all that long, really... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] JPEG info needed
I *have* tried, Richard. It is not returning the state of the file. Files that Irfanview recognizes are prograssive, your example code does not. Looking at C code in gd-2.0.33/gd_jpeg.c downloaded from http://www.boutell.com/gd/ there is a comment: /* REMOVED by TBB 2/12/01. This field of the structure is documented as private, and sure enough it's gone in the latest libjpeg, replaced by something else. Unfortunately there is still no right way to find out if the file was progressive or not; just declare your intent before you write one by calling gdImageInterlace(im, 1) yourself. After all, we're not really supposed to rework JPEGs and write them out again anyway. Lossy compression, remember? */ The docs at http://www.boutell.com/gd/manual2.0.33.html#gdImageInterlace say gdImageInterlace is used to determine whether an image should be stored in a linear fashion, in which lines will appear on the display from first to last, or in an interlaced fashion, in which the image will fade in over several passes. By default, images are not interlaced. (When writing JPEG images, interlacing implies generating progressive JPEG files, which are represented as a series of scans of increasing quality. Noninterlaced gd images result in regular [sequential] JPEG data streams.) A nonzero value for the interlace argument turns on interlace; a zero value turns it off. Note that interlace has no effect on other functions, and has no meaning unless you save the image in PNG or JPEG format; the gd and xbm formats do not support interlace. When a PNG is loaded with gdImageCreateFromPng or a JPEG is loaded with gdImageCreateFromJpeg, interlace will be set according to the setting in the PNG or JPEG file. -- To me that means the code authors cannot determine what the state of the file is, and are not returning a state they cannot determine. Gerry On 1/25/07, Richard Lynch [EMAIL PROTECTED] wrote: Re-read the docs more carefully. The second arg is optional, and it returns the PRIOR state of the interlaced-ness (or progressive-ness for a JPEG). Standard computer-science function trick to return prior state when altering state, and to simply return state if the second arg is not passed in. So if you do not pass in a second arg, you should be getting the state of the JPEG. Try it. On Wed, January 24, 2007 7:20 pm, Gerry Danen wrote: Richard, imageinterlace() turns the interlace bit on or off. It only returns 1 if you set it to 1 as the second parameter... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing AJAX post data -- The Way
On 25-Jan-07, at 4:46 PM, Richard Lynch wrote: On Thu, January 25, 2007 12:41 am, M5 wrote: Just wondering what smart people do for parsing data sent by the Javascript XMLHTTP object--e.g., http.send(post,url,true)... In a normal form submit, the $_POST global nicely allocates form elements as array elements automatically. But with the AJAX way, the data get stuffed inside $HTTP_RAW_POST_DATA as a string, thereby making extraction more tedious. Call me crazy, but if AJAX is sending POST data correctly, your PHP code shouldn't have to do anything special... You're right in that *IF* AJAX is sending POST data correctly everything is okay--that is, will $_POST contain the posted data as array elements. POST data is POST data. The $HTTP_RAW_POST_DATA should be there as well, if you turned that on, but that doesn't make $_POST go away. Actually, that's not true. If the POST data is not set with the correct headers... http.setRequestHeader('Content-Type', 'application/x-www-form- urlencoded'); http.setRequestHeader(Content-length, payload.length); http.setRequestHeader(Connection, close); ...then $_POST will be empty and the data that is sent can only be accessed from $HTTP_RAW_POST_DATA (which incidentally is off by default). That was my problem--I wasn't sending those http headers. An earlier poster pointed it out to me, and that solved the problem. ...Rene -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validating a link in php
Frank Arensmeier wrote: Did you take a look at the error numbers / messages returned by fsockopen? What do they say? Actually, I only get warnings, not errors, but here's what they say: Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/html/je/jefflynnesongs.com/jlvids/jlvids.php on line 98 Warning: fsockopen(): unable to connect to www.youtube.com/v/JqO8ZevPJNk:80 in /var/www/html/je/jefflynnesongs.com/jlvids/jlvids.php on line 98 Another thing that poped up in my mind - curl. Tried that? Hmmm... I just did some experimenting and it looks promising. Here's the code that appears to work: $ch = curl_init(http://www.youtube.com/v/JqO8ZevPJNk;); if (curl_exec($ch)) //Do stuff for a valid URL else //Do stuff for an invalid URL Many thanks! I'm loving PHP, but I've got a lot to learn. Robert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validating a link in php
Try changing that url to www.youtube.com:80/v/JqO8ZevPJNk On 1/25/07, Robert Porter [EMAIL PROTECTED] wrote: Frank Arensmeier wrote: Did you take a look at the error numbers / messages returned by fsockopen? What do they say? Actually, I only get warnings, not errors, but here's what they say: Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/html/je/jefflynnesongs.com/jlvids/jlvids.php on line 98 Warning: fsockopen(): unable to connect to www.youtube.com/v/JqO8ZevPJNk:80 in /var/www/html/je/jefflynnesongs.com/jlvids/jlvids.php on line 98 Another thing that poped up in my mind - curl. Tried that? Hmmm... I just did some experimenting and it looks promising. Here's the code that appears to work: $ch = curl_init(http://www.youtube.com/v/JqO8ZevPJNk;); if (curl_exec($ch)) //Do stuff for a valid URL else //Do stuff for an invalid URL Many thanks! I'm loving PHP, but I've got a lot to learn. Robert -- 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