Re: [PHP] Type of form element
Marcus Bointon wrote: Given $myarray['a'] = NULL, isset($myarray[a']) returns false. Yes, I think we've established that. I'm sure Richard and I were both well aware of this fact, but just in case we weren't, I think we can safely assume we are by now. :-) You're saying that therefore, $myarray['a'] does not exist Well, I have the same opinion that isset() does - if a variable is set to NULL, it may as well not be set. I understand and appreciate the way PHP works and frequently rely upon its friendly behavior. If I really care to know whether something is NULL (which I rarely do), I can always use is_null(). Of course, none of this applies to the present topic, because NULL is not a string. In previous replies, I've provided methods that you can use to distinguish between NULL, the empty string, 0, etc. There's also a table at the top of this cheat sheet that you might find helpful: http://www.blueshoes.org/en/developer/php_cheat_sheet (Notice that is_null() and isset() are boolean opposites.) Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Type of form element
On 31 Oct 2005, at 21:11, Chris Shiflett wrote: I think this is where some (most?) of the misunderstanding originates. Testing to see whether something exists is exactly what isset() does. No. Given $myarray['a'] = NULL, isset($myarray[a']) returns false. You're saying that therefore, $myarray['a'] does not exist, which is clearly untrue. Testing to see whether something has a value is exactly what isset does, not whether it exists. In many cases it comes down to the same thing (because if it doesn't exist it can't have a value), but they are definitely not identical. Wouldn't it seem like a bug if a function intended to check whether a variable is set generates a notice when you test a variable that isn't? Since we're on such thin ice, you need to tread carefully - first you said it's for "testing to see whether something exists", but now you describe it as "a function intended to check whether a variable is set". Which is it? They are not the same thing. Here's an experiment to distinguish which it is - it may come as quite a surprise: var_dump(isset($bar)); echo $bar; $bar = NULL; var_dump(isset($bar)); echo $bar; bool(false) PHP Notice: Undefined variable: bar in /test.php on line 3 Notice: Undefined variable: bar in /test.php on line 3 bool(false) Holy Smoke! isset quite definitely CANNOT tell you if a variable does not exist - though PHP clearly knows as the second echo did not generate an error! If it returns true then it does definitely both exist and has a value (which is useful and why you can use isset as you do), but if it returns false you really have no idea if the var exists or not. So what can you use instead? Is there no direct equivalent of array_key_exists for variables? I did discover that array_key_exists('bar', get_defined_vars()) works, but though at least it's definitive, I don't think I could face using that everywhere ;^) To summarize, I see nothing wrong with your way of using array_key_exists(), but I don't think you can claim Richard's use of isset() is inappropriate. His method is "safer" in cases where the array itself is not set, and your method is "safer" when an element's value is NULL. Neither of these cases ever exist with $_GET, $_POST, etc., because they are always set, and they only contain strings. Therefore, there's no debate to be won here. :-) Of course isset has a valid place - array_key_exists cannot replicate what it does (it doesn't know about values), so they can play together nicely - for example I'd consider this pretty robust: if (isset($_SESSION) and is_array($_SESSION) and array_key_exists ('myvar', $_SESSION)) ... If you get past that you can be absolutely certain that $_SESSION ['myvar'] exists, regardless of its value, and there is no opportunity to trigger an error, whereas if you said: if (isset($_SESSION) and is_array($_SESSION) and isset($_SESSION ['myvar'])) ... you could still be wrong. The merest possibility of being wrong is a bad thing in code. Why not use marginally different syntax and be absolutely sure? Yesterday I encountered an error in a large commercial php script and it turned out that it was looking in $_SERVER['SERVER_NAME'] which was there but set to NULL for some reason, and their test with isset was failing. So it's not just academic and I'm not making it up - this problem does happen for real. All this over such a little thing - imagine if we had a whole language to worry about! Oh wait... Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture [EMAIL PROTECTED] | http://www.synchromedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with Regexp
Richard Heyes schrieb: Yannick Mortier wrote: Hello, I have the string: http://www.runescape.com/img/hiscores/attack.gif"; valign="bottom" width=16 height=16 /> href="hiscoreuser.cgi?username=zezima&category=1" class=c>Attack4align="right">9953,156,556 and I apply preg_match_all: preg_match_all("/(src=\"http:\/\/www.runescape.com\/img\/hiscores\/attack.gif\" valign=\"bottom\" width=16 height=16 \/><\/td> <\/td>href=\"hiscoreuser.cgi\?username=)([\w])+(&category=1\" class=c>Attack<\/a><\/td>)([1-9])+(<\/td>align=\"right\">)([1-9])+(<\/td>align=\"right\">)([1-9,])+(<\/td><\/tr>)/",$seite,$attack); ... But I would expect to get [2] => Array ( [0] => zezima ) [6] => Array ( [0] => 99 ) [8] => Array ( [0] => 53,156,556) Instead of the values above. Can you explain me how I can get those values? Try something like: preg_match_all('#username=([^&]+).+\d+align="right">(\d+)([\d, ]+)#i', $seite, $matches); print_r($matches); Not tested - might need tweaking. Now it works! I still use mine, but i put the + directly after the closing bracket: ([\d]+) instead of ([\d])+ Thanks a lot for your help! I looked at your reg exp and saw this. Yannick Mortier -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Anyone know where 5.1 RC1 has gone?
Hi, RC4 is available since last Friday. Take a look here http://downloads.php.net/ilia/ Richard Davey wrote: > Hi, > > PHP 5.1 RC1 was on the site two days ago, but has since been > removed. I can see it in Googles cache, and snapshots are in CVS, > but no Release Candidate. Does this mean an RC2 is imminent? :) > > Cheers, > > Rich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Anyone know where 5.1 RC1 has gone?
Hi, PHP 5.1 RC1 was on the site two days ago, but has since been removed. I can see it in Googles cache, and snapshots are in CVS, but no Release Candidate. Does this mean an RC2 is imminent? :) Cheers, Rich -- Zend Certified Engineer http://www.launchcode.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] LDAP Paged Search
Hi Folks! This is my first email to "php-general", and first of all I wish to thank the developers for their GREAT work! :-) Well, I don't mean to waste your time, so here follow my question. I've stared using PHP some months ago, and my last application is an "LDAP Administration Tool" for IBM ITDS server. It run on AIX and Linux, and I'm trying to extend it to manage Active Directory too. The problem is that A.D. only support "Paged search": it gives back the first N results (N=1000 in my case) each time. There is a particular way to perform searches that handles this kind of replies, it is usually based on a cookie that's exchanged between client and server so that the client can obtain a "cursor" of where the search is arrived, and continue it until the results are completed. I've tried to Google-search to see if someone else already had this problem and I found that, while PERL resolve it, PHP does not provide a solution. So I decided to subscribe this list, maybe someone here knows how to resolve this problem? Thanks in advance! Claudio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Type of form element
Marcus Bointon wrote: But that's not the question you're using isset to answer. You just want to know if something exists - you probably don't even care what its value is. I think this is where some (most?) of the misunderstanding originates. Testing to see whether something exists is exactly what isset() does. I don't find Richard's use of the function inappropriate. I would also fully expect to receive an undefined index notice as you have explicitly looked up an array index that does not exist. Wouldn't it seem like a bug if a function intended to check whether a variable is set generates a notice when you test a variable that isn't? Your example seems no different than this: $foo = isset($bar); If $bar is not set, this code is still fine, as it should be. $myarray = array(); print $myarray['a']; This is not the same case, else I could rewrite my above example as: echo $bar; If $bar is not set, then this does generate a notice, as it should. To summarize, I see nothing wrong with your way of using array_key_exists(), but I don't think you can claim Richard's use of isset() is inappropriate. His method is "safer" in cases where the array itself is not set, and your method is "safer" when an element's value is NULL. Neither of these cases ever exist with $_GET, $_POST, etc., because they are always set, and they only contain strings. Therefore, there's no debate to be won here. :-) As I mentioned earlier, your argument about the social aspects of this (such as the benefit of consistency gained by always using array_key_exists()) is perfectly valid. Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Type of form element
On 31 Oct 2005, at 17:55, Richard Lynch wrote: You're wrong. No. You're just missing what I'm on about. I'll agree it's very dull. isset() does not, under any circumstances, create an index nor a variable. Quite right; I never said it did. Its entire purpose *IS* to tell you if something has been set to a value. That's why it's CALLED "isSet" But that's not the question you're using isset to answer. You just want to know if something exists - you probably don't even care what its value is. Take apart this operation: $a = isset($myarray['a']); Implicit in this simple line is a 'hidden' step which is to look up the index 'a' in $myarray to get its value before testing if it is set or not. The issue I have is that that step's existence is being overlooked. That line could also be written: $a = !is_null($myarray['a']); Either way, if $myarray['a'] does not exist, its value will be regarded as null (and as such, isset and !is_null would give correct results as a consequence of this convenient side-effect), but I would also fully expect to receive an undefined index notice as you have explicitly looked up an array index that does not exist. If you used other functions the same way you're using isset, you would see nothing wrong with this: $myarray = array(); print $myarray['a']; but I would hope that you would have a problem with that. Why treat isset differently? Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture [EMAIL PROTECTED] | http://www.synchromedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PDF permissions problems
[snip] I'm trying to write a FDF file into a directory outside of the webserver. I keep getting errors such as: Warning: fopen(/x/x/FDF/FLQual.fdf): failed to open stream: Permission denied in /Library/WebServer/Documents/x/x/FLCorpQual.php on line 36 Can someone give me a quick lesson in permissions? For example, as long as the director I want to write into has read permissions, I'm ok, right? But what if that director is inside another directory that doesn't have read permissions? And does it matter that I'm writing from a PHP page that's within the Web Directory out into a director that's not within the Web Directory? I'm using absolute paths. [/snip] I typed "lesson on directory permissions" in Google, and it was amazing. In the case that you are talking about the 'person' that the web server is running as must have write permissions to a directory where it is trying to write things. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PDF permissions problems
I'm trying to write a FDF file into a directory outside of the webserver. I keep getting errors such as: Warning: fopen(/x/x/FDF/FLQual.fdf): failed to open stream: Permission denied in /Library/WebServer/Documents/x/x/FLCorpQual.php on line 36 Can someone give me a quick lesson in permissions? For example, as long as the director I want to write into has read permissions, I'm ok, right? But what if that director is inside another directory that doesn't have read permissions? And does it matter that I'm writing from a PHP page that's within the Web Directory out into a director that's not within the Web Directory? I'm using absolute paths. Jeremy
Re: [PHP] php mail function vs smtp server
On Mon, October 31, 2005 5:22 am, Paul Waring wrote: > On Mon, Oct 31, 2005 at 12:56:01PM +0200, Clive wrote: >> Thanks I actually want to send 24 000 emails with 2 meg attachments. Woof. mail() is DEFINITELY the wrong answer! Firing up an SMTP connection and spewing 24,000 emails with 2 meg attachments at it is *ALSO* a wrong answer, almost for sure. You will probably have a very unhappy SysAdmin behind that SMTP server, and odds are really really really good they'll have a long line of VERY unhappy SysAdmins behind them. You can pretty much count on being labeled (hopefully mis-labeled) as a spammer almost immediately. 2 meg attachments are your first biggest problem. Lose them. Include a link to whatever it is for the user to download the 2 meg at their leisure. This is non-negotiable. You WILL regret the 2 meg attachment long before the 24,000th user gets it. Queue up the emails and send them out over a controlled time. If there's ANY question that somebody might not want this email, don't send it. Get them to opt-in first, if you haven't already. -- 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 mail function vs smtp server
On Mon, October 31, 2005 4:10 am, Clive wrote: > does anyone know whats better/uses less resource etc: > > If I run a loop to send a 1000 emails, should I use php's mail > fucntions > or send directly to the servers smtp server. SMTP PHP's mail() function was never designed for high-volume email. It fires up a different process of sendmail for EACH email. This is NOT cheap, nor efficient. mail() is convenient. It is not efficient. Use mail() for quickie one-off emails. Use something else for mass email. There are classes/packages you can use to make this painless. http://phpclasses.org has at least one that gets used/recommended a lot. -- 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] Type of form element
On Mon, October 31, 2005 10:33 am, Marcus Bointon wrote: > On 31 Oct 2005, at 14:54, Chris Shiflett wrote: > >> Hopefully it is also clear that your argument revolves around the >> idea that PHP would create $_POST['foo'] as NULL if the checkbox is >> not checked. This is wrong for two reasons: > > No, no, that's not what I said - I wouldn't contemplate such > silliness! The thing I was wrong on is that PHP converts unset > parameters (as opposed to nonexistent ones which it obviously can't > do anything about) to an empty string, e.g. given ?a=&b=1, $_REQUEST > ['a'] is "", not NULL. However, it still serves to underline my other > point that using isset without actually knowing that is a potentially > dangerous thing. Getting into the habit of using it for looking in > the likes of $_REQUEST means you're likely to use it other places > where you have no such guarantee, and you'll have a bug to track > down. Using array_key_exists means you will never be exposed to this > possibility, no matter where your data comes from. Once again: HTTP and HTML have no NULL. It would be INSANE for PHP to interpret any HTTP data, which, by definition, is all TEXT as NULL. In the better part of a decade, I've never had a bug from using isset() and having NULL as a value in an array. I'm not really concerned about it happening tomorrow. -- 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] Type of form element
On Mon, October 31, 2005 4:38 am, Marcus Bointon wrote: > On 31 Oct 2005, at 06:18, Richard Lynch wrote: > >> But I really do believe isset($_POST['checkbox_name']) is a "good" >> coding practice. > > OK, so PHP may not pass through unset params as NULL (it's not up to > the browser), but if you don't select any checkboxes at all, the > param won't exist, and asking for an index of something that doesn't > exist is normally a good way to generate notices. isset's job is not > to tell you if an array key exists, so why use it for that purpose? You're wrong. isset() does not, under any circumstances, create an index nor a variable. Its entire purpose *IS* to tell you if something has been set to a value. That's why it's CALLED "isSet" > This is the difference I'm on about: > > $z = array('a' => 1, 'b' => NULL); > echo array_key_exists('a', $z)?"yes\n":"no\n"; > echo isset($z['a'])?"yes\n":"no\n"; > echo array_key_exists('b', $z)?"yes\n":"no\n"; > echo isset($z['b'])?"yes\n":"no\n"; > > This prints: > > yes > yes > yes > no > > That last 'no' has huge bug potential. I really don't want to argue with you about the semantics of NULL, but, as far as I'm concerned, the number of places where a NULL value existing in an array should have meaning are essentially... NULL If your code relies on NULL as a value in an array and the key thereof, I'd guess that you're probably using the wrong data structure, algorithm, or query in the first place. But that's just me. [shrug] -- 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] Problem with Regexp
On Mon, October 31, 2005 9:27 am, Yannick Mortier wrote: > http://www.runescape.com/img/hiscores/attack.gif"; > valign="bottom" width=16 height=16 /> href="hiscoreuser.cgi?username=zezima&category=1" > class=c>Attack4 align="right">9953,156,556 > > > and I apply preg_match_all: > > preg_match_all("/( src=\"http:\/\/www.runescape.com\/img\/hiscores\/attack.gif\" > valign=\"bottom\" width=16 height=16 \/><\/td> <\/td> href=\"hiscoreuser.cgi\?username=)([\w])+(&category=1\" > class=c>Attack<\/a><\/td>)([1-9])+(<\/td> align=\"right\">)([1-9])+(<\/td> align=\"right\">)([1-9,])+(<\/td><\/tr>)/",$seite,$attack); > > ($seite is the string) When trying to web-scrape data like this, I would recommend that you try to focus on things that are NOT likely to change, rather than the HTML bits that probably will change. When you HAVE to use the HTML, focus on the smallest elements of HTML that you can to identify what you want, so your odds of an altered HTML page will be less likely to affect you. I would try this: '/username=(.*)\\&.*"right">([0-9]*).*"right>([0-9]*).*"right>([0-9,]*)/' PS FOR SURE, you need 0-9 and not 1-9 for your numbers: Rank: 10 Score: 45,067,13 etc > Can you explain me how I can get those values? < and > are probably being interpreted as special characters or something. -- 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] getting rid of bad characters
On Mon, October 31, 2005 9:30 am, Dan McCullough wrote: > I having been looking for some snippet to help me with changing MS > Word double, quotes, single quotes and other characters to acceptable > HTML safe characters. The problem comes about when the people using > the forms paste large articles from Word into the form, I do a normal > check and add slashes but lately they have been getting lazy and using > the special characters from Word. There are several functions at http://php.net/htmlentities in the User-Contributed notes for this. Pick the one you like. PS ALWAYS read the User-Contributed notes of related functions when looking for this kind of stuff. They're a Gold Mine. -- 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] Type of form element
Marcus Bointon wrote: The thing I was wrong on is that PHP converts unset parameters (as opposed to nonexistent ones which it obviously can't do anything about) to an empty string, e.g. given ?a=&b=1, $_REQUEST ['a'] is "", not NULL. That's right, except we seem to have a vocabulary discrepancy: 1. To me, "unset" and "not set" are not the same thing (sort of like how "untie" and "not tied" are also not the same). I'm assuming you always mean "not set" in your comments. Otherwise, it sounds like you're describing some sort of conversion from one state to another. PHP is just taking what it is given. 2. Given the above assumption, there is no difference between something not being set and something not existing. If you want to distinguish between $_GET['a'] and $_GET['b'] in your example above, empty() does the trick. Some people use strlen() if they want to also distinguish between the string 0 and the empty string, and you can always just compare something to the empty string. However, it still serves to underline my other point that using isset without actually knowing that is a potentially dangerous thing. I think Richard knew what he was doing. :-) If his approach is wrong, then so is mine, because I also use isset() to see whether a checkbox was checked. If you go back to my previous example, you'll see that array Getting into the habit of using it for looking in the likes of $_REQUEST means you're likely to use it other places where you have no such guarantee, and you'll have a bug to track down. Using array_key_exists means you will never be exposed to this possibility, no matter where your data comes from. I understand and appreciate your argument. However, you're now describing a social issue, not a technical one. These issues tend to be more subjective, so "right" answers are difficult to find. :-) In this case, the only concern would be that PHP considers something set to NULL to be the same as not being set at all (as far as isset() is concerned). This situation can never exist with things like $_GET and $_POST, because everything in those arrays is a string. Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] pls suggest a good and tested B2B software
On Mon, 2005-10-31 at 12:04, Denis L. Menezes wrote: > Hi. > > I am looking for a good tried and tested B2B software like Alibaba. There was this one... but 40 thieves ran off with it :p 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] pls suggest a good and tested B2B software
Hi. I am looking for a good tried and tested B2B software like Alibaba. Can anyone please suggest if they have tried and running any? Thanks Denis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Type of form element
On Mon, 2005-10-31 at 11:33, Marcus Bointon wrote: > On 31 Oct 2005, at 14:54, Chris Shiflett wrote: > > > Hopefully it is also clear that your argument revolves around the > > idea that PHP would create $_POST['foo'] as NULL if the checkbox is > > not checked. This is wrong for two reasons: > > No, no, that's not what I said - I wouldn't contemplate such > silliness! The thing I was wrong on is that PHP converts unset > parameters (as opposed to nonexistent ones which it obviously can't > do anything about) to an empty string, e.g. given ?a=&b=1, $_REQUEST > ['a'] is "", not NULL. Ummm that's not a conversion, the 'a' parameter is there with exactly 0 characters, thus it is a 0 length string. That's not a PHP idiosyncrasy, I'm pretty sure that's the standard. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using Ajax to spit out a php-generated embed tag
I actually got it pretty quickly after reading the Rasmus AJAX tutorial It was simple and easy to understand. Thank you, Rasmus :) I just needed to seemlessly launch the QuickTime player from a Flash page. Seems like Ajax is going to do this quite nicely. g On Oct 30, 2005, at 10:06 PM, Richard Lynch wrote: You probably should be asking in an Ajax forum... That said: Ajax just goes and gets whatever is at a URL. You can have the biggest, baddest PHP script at that URL that spits out whatever you want. Or it can always just spit out "42" Ajax don't really care either way. And PHP doesn't really care if Ajax is asking for AppleJacks is asking. Somebody asks, PHP spits out the data. So, YES, your Ajax can request a PHP URL and get back any HTML you feel like. For that matter, you *could* use Ajax to request the actual ".mov" file, if you can get some kind of .mov player to run Ajax. And you could have PHP spitting out the QT movie from a http://php.net/readfile or similar. Hell, you could write a PHP script to GENERATE a QuickTime movie on the fly, if you knew QT internals enough to do it. On Sun, October 30, 2005 6:34 pm, Graham Anderson wrote: Can you use AJAX to output an entire php-generated embed tag into a web page? something like: http://www.apple.com/qtactivex/ qtplugin.cab"> EOB; header('Content-Type: text/xml'); // ajax only seems to like text/xml header('Content-Length: '.strlen($qtembed)); echo $qtembed; ?> I am a bit new to Ajax stuff, but thankfully, have been able to make simple examples work. From the examples I have tried thus far , it 'appears' that Ajax only supports sending/receiving elements like zip codenot entire tags Is there a way to 'curl' the html to see what 'xmlhttprequest' is sending and receiving ? Maybe I am going about this the wrong way and there is a better solution? I wanted to avoid pop-up windows, launching new html pages, and iframes if possible. Ultimately, I want to dynamically write an invisible movie embed tag into an html document when called by some 'geturl' actionscript. Basically, click a button in a flash movie, and the quicktime player launches. Instead, should I write a 'empty" quicktime movie tag into the html document with the element, moviename, for Ajax to target ? many thanks in advance :) g this is the script I was attempting to modify: http://developer.apple.com/internet/webcontent/XMLHttpRequestExample/ example.html these are the two javascript functions where loadDoc is called by a form from the above html function loadDoc(evt) { // equalize W3C/IE event models to get event object evt = (evt) ? evt : ((window.event) ? window.event : null); if (evt) { // equalize W3C/IE models to get event target reference var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); if (elem) { try { if (elem.selectedIndex > 0) { loadXMLDoc(elem.options [elem.selectedIndex].value); } } catch(e) { var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error"); alert("Unable to get XML data:\n" + msg); return; } } } } // retrieve text of an XML document element, including // elements using namespaces function getElementTextNS(prefix, local, parentElem, index) { var result = ""; if (prefix && isIE) { // IE/Windows way of handling namespaces result = parentElem.getElementsByTagName(prefix + ":" + local)[index]; } else { // the namespace versions of this method // (getElementsByTagNameNS()) operate // differently in Safari and Mozilla, but both // return value with just local name, provided // there aren't conflicts with non-namespace element // names result = parentElem.getElementsByTagName(local)[index]; } if (result) { // get text, accounting for possible // whitespace (carriage return) text nodes if (result.childNodes.length > 1) { return result.childNodes[1].nodeValue; } else { return result.firstChild.nodeValue; } } else { return "n/a"; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- 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] Type of form element
On 31 Oct 2005, at 14:54, Chris Shiflett wrote: Hopefully it is also clear that your argument revolves around the idea that PHP would create $_POST['foo'] as NULL if the checkbox is not checked. This is wrong for two reasons: No, no, that's not what I said - I wouldn't contemplate such silliness! The thing I was wrong on is that PHP converts unset parameters (as opposed to nonexistent ones which it obviously can't do anything about) to an empty string, e.g. given ?a=&b=1, $_REQUEST ['a'] is "", not NULL. However, it still serves to underline my other point that using isset without actually knowing that is a potentially dangerous thing. Getting into the habit of using it for looking in the likes of $_REQUEST means you're likely to use it other places where you have no such guarantee, and you'll have a bug to track down. Using array_key_exists means you will never be exposed to this possibility, no matter where your data comes from. Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture [EMAIL PROTECTED] | http://www.synchromedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting rid of bad characters
Dan McCullough wrote: I having been looking for some snippet to help me with changing MS Word double, quotes, single quotes and other characters to acceptable HTML safe characters. This seems to work: $search = array('/[\x07\x95]/', '/\x85/', '/[\x91\x92]/', '/[\x93\x94]/'); $replace = array('-', '...', "'", '"'); $string = preg_replace($search, $replace, $string); Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with Regexp
Yannick Mortier wrote: Hello, I have the string: http://www.runescape.com/img/hiscores/attack.gif"; valign="bottom" width=16 height=16 /> href="hiscoreuser.cgi?username=zezima&category=1" class=c>Attack4align="right">9953,156,556 and I apply preg_match_all: preg_match_all("/(src=\"http:\/\/www.runescape.com\/img\/hiscores\/attack.gif\" valign=\"bottom\" width=16 height=16 \/><\/td> <\/td>href=\"hiscoreuser.cgi\?username=)([\w])+(&category=1\" class=c>Attack<\/a><\/td>)([1-9])+(<\/td>align=\"right\">)([1-9])+(<\/td>align=\"right\">)([1-9,])+(<\/td><\/tr>)/",$seite,$attack); ... But I would expect to get [2] => Array ( [0] => zezima ) [6] => Array ( [0] => 99 ) [8] => Array ( [0] => 53,156,556) Instead of the values above. Can you explain me how I can get those values? Try something like: preg_match_all('#username=([^&]+).+\d+align="right">(\d+)([\d, ]+)#i', $seite, $matches); print_r($matches); Not tested - might need tweaking. -- Richard Heyes http://www.phpguru.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: getting rid of bad characters
Check in the comments section of ths page: http://us3.php.net/htmlentities . You're not the first person to have this problem. Ben On Mon, 31 Oct 2005 10:30:49 -0500, Dan McCullough <[EMAIL PROTECTED]> wrote: I having been looking for some snippet to help me with changing MS Word double, quotes, single quotes and other characters to acceptable HTML safe characters. The problem comes about when the people using the forms paste large articles from Word into the form, I do a normal check and add slashes but lately they have been getting lazy and using the special characters from Word. -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting rid of bad characters
Have you tried using htmlentities()? It should convert stuff like double-quotes (") to it's associated HTML entity which, when echo'd to the browser, will be displayed as " again. Good for safe output. Not so good for storing in a database (which you'd probably want to use whatever your database's "escape_string" function is). -TG = = = Original message = = = I having been looking for some snippet to help me with changing MS Word double, quotes, single quotes and other characters to acceptable HTML safe characters. The problem comes about when the people using the forms paste large articles from Word into the form, I do a normal check and add slashes but lately they have been getting lazy and using the special characters from Word. ___ 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
[PHP] getting rid of bad characters
I having been looking for some snippet to help me with changing MS Word double, quotes, single quotes and other characters to acceptable HTML safe characters. The problem comes about when the people using the forms paste large articles from Word into the form, I do a normal check and add slashes but lately they have been getting lazy and using the special characters from Word. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with Regexp
Hello, I have the string: http://www.runescape.com/img/hiscores/attack.gif"; valign="bottom" width=16 height=16 /> Attack49953,156,556 and I apply preg_match_all: preg_match_all("/(src=\"http:\/\/www.runescape.com\/img\/hiscores\/attack.gif\" valign=\"bottom\" width=16 height=16 \/><\/td> <\/td>href=\"hiscoreuser.cgi\?username=)([\w])+(&category=1\" class=c>Attack<\/a><\/td>)([1-9])+(<\/td>align=\"right\">)([1-9])+(<\/td>align=\"right\">)([1-9,])+(<\/td><\/tr>)/",$seite,$attack); ($seite is the string) If i make print_r($attack); then I get: Array ( [0] => Array ( [0] => http://www.runescape.com/img/hiscores/attack.gif"; valign="bottom" width=16 height=16 /> Attack49953,156,556 ) [1] => Array ( [0] => http://www.runescape.com/img/hiscores/attack.gif"; valign="bottom" width=16 height=16 /> Attack ) [4] => Array ( [0] => 4 ) [5] => Array ( [0] => ) [6] => Array ( [0] => 9 ) [7] => Array ( [0] => ) [8] => Array ( [0] => 6 ) [9] => Array ( [0] => ) ) But I would expect to get [2] => Array ( [0] => zezima ) [6] => Array ( [0] => 99 ) [8] => Array ( [0] => 53,156,556 ) Instead of the values above. Can you explain me how I can get those values? Yannick Mortier -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Type of form element
Marcus Bointon wrote: OK, so PHP may not pass through unset params as NULL (it's not up to the browser) Well, it's certainly not up to PHP. Think about it. Let me give you an example to try: If you don't check the checkbox, the HTTP request sent by the browser looks something like this: POST /test.php HTTP/1.1 Host: example.org Referer: http://example.org/test.php Content-Type: application/x-www-form-urlencoded Content-Length: 0 If you do check it, the request looks like this: POST /test.php HTTP/1.1 Host: example.org Referer: http://example.org/test.php Content-Type: application/x-www-form-urlencoded Content-Length: 4 foo= Given this, it should come as no surprise that $_POST['foo'] does not exist when you do not check the checkbox, but it does exist when you do. Hopefully it is also clear that your argument revolves around the idea that PHP would create $_POST['foo'] as NULL if the checkbox is not checked. This is wrong for two reasons: 1. How would PHP know what to name it? :-) 2. NULL is not a string, and everything in $_POST is a string. Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP 4.4.1 has been released
Hello! PHP 4.4.1 is now available for download [1]. This version is a maintenance release, that contains numerous bug fixes, including a number of security fixes related to the overwriting of the GLOBALS array. All users of PHP 4.3 and 4.4 are encouraged to upgrade to this version. The full list of changes in PHP 4.4.1 is available in the PHP 4 ChangeLog [2] and a list with the most important changes is available through the release announcement [3]. [1] http://php.net/downloads.php#v4 [2] http://php.net/ChangeLog-4.php#4.1.1 [3] http://php.net/release_4_4_1.php regards, Derick -- http://derickrethans.nl | http://ez.no | http://xdebug.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Substr by words
Hello, Marcus. No, you are right. Your script is better. I just forgot something I learned about REGEXES: The REGEX engine is eager. Thus, in this case, It's not necessary to use the caret. The REGEX engine will start from the first word It finds. I would use yours ;-). Best regards, Gustavo Narea. PHP Documentation - Spanish Translation Team. Valencia, Venezuela. Marcus Bointon wrote: On 31 Oct 2005, at 03:29, Gustavo Narea wrote: I think It is OK what I said about the caret, but what we need to change is the position of \W*: Your suggestion: /(\b\w+\b\W*){1,$MaxWords}/ My suggestion: /^(\W*\b\w+\b){1,$MaxWords}/ We need the *first* ($MaxWords)th words. I makes no difference - they will both work. Mine doesn't care where the first word starts because it doesn't use ^, and yours doesn't care where the first word starts because it's got ^ followed by \W*. Your overall match will end up with leading spaces, mine will end up with trailing spaces - the subsequent trim fixes them both. I like mine because it has 1 less char ;^) Ultimately, if it works for you, great! Marcus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php mail function vs smtp server
On Mon, Oct 31, 2005 at 12:56:01PM +0200, Clive wrote: > Thanks I actually want to send 24 000 emails with 2 meg attachments. Oh. You definitely don't want to be using an external SMTP server if you can help it then, and you should really be splitting those up into chunks (no more than 1,000 at a time really) using something like PEAR Queue as has already been suggested. > There also another option with the class: using the sendmail program, > but won't the php mail function use sendmail anyway As far as I know, mail() just sends stuff to whatever the sendmail binary is on your system, although I haven't really looked into it. Of course you don't have to be running sendmail as most MTA will install binaries such as /usr/sbin/sendmail which actually point to postfix or qmail or whatever you're running. Paul -- Rogue Tory http://www.roguetory.org.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php mail function vs smtp server
On 31 Oct 2005, at 10:34, Richard Heyes wrote: Depends on your setup. If you're on Linux/Unix you could use the mail() function along with the "-odq" option to Sendmail/Postfix/ Exim etc (fifth argument to the mail() function) which will dump all the mails into the MTAs queue. After this, the MTA will handle delivery. This is probably the quickest for this platform. I agree. Sending directly is usually reserved for Windows machines with no local MTA and is usually way slower and doesn't handle queuing. I'd advise anyone to use PHPMailer for mail anyway as it makes it much more reliable to deal with all the other stuff like MIME encoding, plus it has support for all these sending methods without having to change much code. I use it with qmail. Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture [EMAIL PROTECTED] | http://www.synchromedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php mail function vs smtp server
On Mon, Oct 31, 2005 at 12:38:09PM +0200, Clive wrote: > what I mean is: im using a class called phpmailer and it has the option > to sent to a smtp server, I suppose this means that they do open a > socket to the smtp server. All that means is that you can specify an external SMTP server (e.g. mail.myisp.com), whereas mail() will use localhost instead. In this case mail() would probably be quite a bit faster (though only if you're sending thousands and thousands of emails) because it won't have to send stuff out beyond the local machine. Depending on what you want to do and how much control you have over the machine your PHP scripts are running on, you might want to run a local mail server that just relays everything to an external source (whatever SMTP server you're currently using) - that way you can send everything to that and your PHP script should return control a bit faster. Paul -- Rogue Tory http://www.roguetory.org.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Substr by words
On 31 Oct 2005, at 03:29, Gustavo Narea wrote: I think It is OK what I said about the caret, but what we need to change is the position of \W*: Your suggestion: /(\b\w+\b\W*){1,$MaxWords}/ My suggestion: /^(\W*\b\w+\b){1,$MaxWords}/ We need the *first* ($MaxWords)th words. I makes no difference - they will both work. Mine doesn't care where the first word starts because it doesn't use ^, and yours doesn't care where the first word starts because it's got ^ followed by \W*. Your overall match will end up with leading spaces, mine will end up with trailing spaces - the subsequent trim fixes them both. I like mine because it has 1 less char ;^) Ultimately, if it works for you, great! Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture [EMAIL PROTECTED] | http://www.synchromedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Type of form element
On 31 Oct 2005, at 06:18, Richard Lynch wrote: But I really do believe isset($_POST['checkbox_name']) is a "good" coding practice. OK, so PHP may not pass through unset params as NULL (it's not up to the browser), but if you don't select any checkboxes at all, the param won't exist, and asking for an index of something that doesn't exist is normally a good way to generate notices. isset's job is not to tell you if an array key exists, so why use it for that purpose? This is the difference I'm on about: $z = array('a' => 1, 'b' => NULL); echo array_key_exists('a', $z)?"yes\n":"no\n"; echo isset($z['a'])?"yes\n":"no\n"; echo array_key_exists('b', $z)?"yes\n":"no\n"; echo isset($z['b'])?"yes\n":"no\n"; This prints: yes yes yes no That last 'no' has huge bug potential. I'm not saying it doesn't have practical use, but I wouldn't call it good practice, and I wouldn't advise people to do it that way in new code. As it happens, isset _will_ usually work for things that come through the web-driven superglobals, but not all arrays come from there - if you use the same syntax for dealing with databases or your own objects you could be creating some very entertaining bugs. I don't know about you but I often deal with arrays containing NULL values where using isset would be very wrong. Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture [EMAIL PROTECTED] | http://www.synchromedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php mail function vs smtp server
Clive wrote: Hi does anyone know whats better/uses less resource etc: If I run a loop to send a 1000 emails, should I use php's mail fucntions or send directly to the servers smtp server. Depends on your setup. If you're on Linux/Unix you could use the mail() function along with the "-odq" option to Sendmail/Postfix/Exim etc (fifth argument to the mail() function) which will dump all the mails into the MTAs queue. After this, the MTA will handle delivery. This is probably the quickest for this platform. -- Richard Heyes http://www.phpguru.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php mail function vs smtp server
Hi Clive, Monday, October 31, 2005, 10:10:02 AM, you wrote: > does anyone know whats better/uses less resource etc: > If I run a loop to send a 1000 emails, should I use php's mail fucntions > or send directly to the servers smtp server. Use PEAR Mail Queue. Cheers, Rich -- Zend Certified Engineer http://www.launchcode.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [DONE] Substr by words
On 31 Oct 2005, at 06:27, Richard Lynch wrote: There's a certain point where the Regex expression reaches a level of complexity that I'm just not willing to accept in my code and call it "maintainable" / */ is fine, of course. But there's lots of times when I know there must be a one-line regex to replace 10 lines of code, but I don't WANT to use it because I'll stumble over that one-line Regex every time I have to change it. I quite agree that many regexes are 'write only', but I don't think that that means that using substr and friends is necessarily any clearer. I sometimes find that a nested mass of string functions is even more confusing - at least a regex has a fixed grammar. I've just written a load of stuff that uses preg_replace_callback that I'm quite pleased with. Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture [EMAIL PROTECTED] | http://www.synchromedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php mail function vs smtp server
On Mon, Oct 31, 2005 at 12:10:02PM +0200, Clive wrote: > does anyone know whats better/uses less resource etc: > > If I run a loop to send a 1000 emails, should I use php's mail fucntions > or send directly to the servers smtp server. What do you mean by "send directly"? Are you thinking of sending mail manually through making a socket connection or something? Paul -- Rogue Tory http://www.roguetory.org.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php mail function vs smtp server
Hi does anyone know whats better/uses less resource etc: If I run a loop to send a 1000 emails, should I use php's mail fucntions or send directly to the servers smtp server. clive -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php