[PHP] Re: help for memcached Segmentation fault
sorry, the right $config['memcached'] variable is $config['memcached']=array(array('host'='localhost', port=11211, persistent=1,weight=1)); 2011/6/28 xucheng xuch...@sankuai.com: Hi all, I wrap pecl-memcache into a class used as a sigleton class . the code is : ==code=== class Mem{ private static $_instance = null ;//singlton object instance private function __construct(){ global $config ; $servers = $config['memcached'] ; $mem = new Memcache ; foreach($servers as $server){ $mem-addServer($server['host'], $server['port'], intval($server['persistent']) 0 ? 1 : 0, intval($server['weight']) 0 ? intval($server['weight']) : 1 ) ; } return $mem ; } private static function getInstance(){ if(self::$_instance === null || !( self::$_instance instanceof Mem ) ){ self::$_instance = new Mem() ; } return true ; } public static function get($key){ self::getInstance() ; return self::$_instance-get(md5(strtolower($key))) ; } public static function set($key, $value, $ttl=0){ self::getInstance() ; $compress = (is_bool($value) || is_int($value) || is_float($value)) ? false : MEMCACHE_COMPRESSED ; return self::$_instance-set(md5(strtolower($key)), $value, $compress, $ttl) ; } public static function rm($key){ self::getInstance() ; return self::$_instance-delete(md5(strtolower($key)),0) ; } } ===code== and $config['memcached'] is an array contains info about the server . $config['memcached'] = array('host'='localhost', port=11211, persistent=1,weight=1) ; when i run this , i got Segmentation fault ! I cannot figure out what's the problem . any commet appreciate . and i used memcached 1.4.5 , and libevent-1.4.13-1 php 5.2.16
[PHP] Re: Help! Made a boo-boo encrypting credit cards
On Fri, 11 Feb 2011 14:42:18 -0800, Brian Dunning wrote: Hey all - I'm using mcrypt to store credit cards into MySQL. About 90% of them decrypt fine, but about 10% decrypt as nonsense (b1�\�JEÚU�A��� is a good example). Maybe there is a character that appears in about 10% of my encryptions that's not being encoded properly??? Can you come up with a phony CC number that fails the decryption? If so, please post: $cc_number binhex($iv) binhex($cc_encrypt) binhex($row['encrypt_iv'])) binhex($row['cc_encrypt'])) More below... // Encryption is set up at the top of the script: $crypto = mcrypt_module_open('rijndael-256', '', 'ofb', ''); $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($crypto), MCRYPT_DEV_RANDOM); $ks = mcrypt_enc_get_key_size($crypto); $key = substr(md5('my_funky_term'), 0, $ks); // When the card number is collected by the form, it's encrypted: $cc_number = addslashes($_POST['cc_number']); mcrypt_generic_init($crypto, $key, $iv); $cc_encrypt = mcrypt_generic($crypto, $cc_number); mcrypt_generic_deinit($crypto); // This is written to the database: $query = update accounts set cc_encrypt='$cc_encrypt', encrypt_iv='$iv', other_fields='$other_stuff' where id='$account_id' limit 1; $result = mysql_query($query) or die(mysql_error()); No mysql_real_escape_string()? Both the cc_encrypt and encrypt_iv fields are tinytext, latin1_swedish_ci, MyISAM, MySQL 5.0.91 Why are you using text fields for storing binary data? Sounds like this could go horribly wrong for a number or reasons. In another script, when I retrieve, I first set it up at the top of the script exactly like step #1 above, then retrieve it like this: mcrypt_generic_init($crypto, $key, $row['encrypt_iv']); $cc_number = trim(mdecrypt_generic($crypto, $row['cc_encrypt'])); mcrypt_generic_deinit($crypto); /Nisse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help! Made a boo-boo encrypting credit cards
2011/3/4 Nisse Engström news.nospam.0ixbt...@luden.se: On Fri, 11 Feb 2011 14:42:18 -0800, Brian Dunning wrote: Hey all - I'm using mcrypt to store credit cards into MySQL. About 90% of them decrypt fine, but about 10% decrypt as nonsense (b1�\�JEÚU�A��� is a good example). Maybe there is a character that appears in about 10% of my encryptions that's not being encoded properly??? Can you come up with a phony CC number that fails the decryption? If so, please post: $cc_number binhex($iv) binhex($cc_encrypt) binhex($row['encrypt_iv'])) binhex($row['cc_encrypt'])) More below... // Encryption is set up at the top of the script: $crypto = mcrypt_module_open('rijndael-256', '', 'ofb', ''); $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($crypto), MCRYPT_DEV_RANDOM); $ks = mcrypt_enc_get_key_size($crypto); $key = substr(md5('my_funky_term'), 0, $ks); // When the card number is collected by the form, it's encrypted: $cc_number = addslashes($_POST['cc_number']); mcrypt_generic_init($crypto, $key, $iv); $cc_encrypt = mcrypt_generic($crypto, $cc_number); mcrypt_generic_deinit($crypto); // This is written to the database: $query = update accounts set cc_encrypt='$cc_encrypt', encrypt_iv='$iv', other_fields='$other_stuff' where id='$account_id' limit 1; $result = mysql_query($query) or die(mysql_error()); No mysql_real_escape_string()? Both the cc_encrypt and encrypt_iv fields are tinytext, latin1_swedish_ci, MyISAM, MySQL 5.0.91 Why are you using text fields for storing binary data? Sounds like this could go horribly wrong for a number or reasons. In another script, when I retrieve, I first set it up at the top of the script exactly like step #1 above, then retrieve it like this: mcrypt_generic_init($crypto, $key, $row['encrypt_iv']); $cc_number = trim(mdecrypt_generic($crypto, $row['cc_encrypt'])); mcrypt_generic_deinit($crypto); /Nisse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Considering their is no validation of the credit card number, you could just use a random string of numbers starting with 99. According to http://en.wikipedia.org/wiki/List_of_Bank_Identification_Numbers#References, nothing starts with 99. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help! Made a boo-boo encrypting credit cards
Maybe I missed something here, but aren't the cc's held by the merchant account provider, and just an id by you to recharge(recurring or once), which can be disputed. I ask because it's been a while since I had to look at this. So let the OP's question take precedence, and mine secondary if necessary, if not then I'l move it to another post. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help: Validate Domain Name by Regular Express
On 01/08/2011 04:55 PM, WalkinRaven wrote: PHP 5.3 PCRE Regular Express to match domain names format according to RFC 1034 - DOMAIN NAMES - CONCEPTS AND FACILITIES /^ ( [a-z] | [a-z] (?:[a-z]|[0-9]) | [a-z] (?:[a-z]|[0-9]|\-){1,61} (?:[a-z]|[0-9]) ) # One label (?:\.(?1))*+ # More labels \.? # Root domain name $/iDx This rule matches only label and label. but not label.label... I don't know what wrong with it. Thank you. Thank you all, and I think I've found the problem: If you don't use 'Recursive Reference' feature, all will work well. Detail: http://ndss.walkinraven.name/2011/01/bug-related-to-recursive-reference-in.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help: Validate Domain Name by Regular Express
tedd wrote: At that time, I registered almost 30 names. Fortunately, all of my names passed and I was permitted to keep them. Unfortunately, all browser manufactures (except Safari) negated some of the work done by the IDNS WG and as a result PUNYCODE is shown instead of the actual characters intended. Only for characters that are not part of a national alphabet, I believe? This one works fine: http://rugbrød.ch/ Besides, many domain registrars also limit the available characters to those that are part of a national alphabet. -- Per Jessen, Zürich (0.0°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help: Validate Domain Name by Regular Express
Hello Ashley Sheridan, Am 2011-01-08 17:09:27, hacktest Du folgendes herunter: Also, each label is checked to ensure it doesn't run over 63 characters, and the whole thing isn't over 253 characters. Lastly, each label is checked to ensure it doesn't completely consist of digits. Do you know, that there are MANY domains with numbers only? Like 163.com or 126.net which are legal names. Oh I should mention that I block ANY mails from this two domains since chinese spamers use it excessively. Thanks, Greetings and nice Day/Evening Michelle Konzack -- # Debian GNU/Linux Consultant ## Development of Intranet and Embedded Systems with Debian GNU/Linux itsyst...@tdnet France EURL itsyst...@tdnet UG (limited liability) Owner Michelle KonzackOwner Michelle Konzack Apt. 917 (homeoffice) 50, rue de Soultz Kinzigstraße 17 67100 Strasbourg/France 77694 Kehl/Germany Tel: +33-6-61925193 mobil Tel: +49-177-9351947 mobil Tel: +33-9-52705884 fix http://www.itsystems.tamay-dogan.net/ http://www.flexray4linux.org/ http://www.debian.tamay-dogan.net/ http://www.can4linux.org/ Jabber linux4miche...@jabber.ccc.de ICQ#328449886 Linux-User #280138 with the Linux Counter, http://counter.li.org/ signature.pgp Description: Digital signature
Re: [PHP] Re: Help: Validate Domain Name by Regular Express
At 11:54 AM +0100 1/11/11, Per Jessen wrote: tedd wrote: At that time, I registered almost 30 names. Fortunately, all of my names passed and I was permitted to keep them. Unfortunately, all browser manufactures (except Safari) negated some of the work done by the IDNS WG and as a result PUNYCODE is shown instead of the actual characters intended. Only for characters that are not part of a national alphabet, I believe? This one works fine: http://rugbrød.ch/ Not for me. It translates to: xn--rugbrd-fya.ch Besides, many domain registrars also limit the available characters to those that are part of a national alphabet. -- Per Jessen, Zürich (0.0°C) National alphabet? Never heard of it -- what Nation? Are the Greek letters Sigma, Delta, Pi part of this National alphabet? While they are common in our English language, I don't think they are not included. In addition, many registrars are clueless about IDNS, Char Sets, and what is legal and not. Plus, the are many differences between different TLD registrars. For example, the TLD COM can have single characters whereas the ORG will not allow single characters regardless of language (including ASCII). The IDNS is still in a state of flux. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help: Validate Domain Name by Regular Express
tedd wrote: At 11:54 AM +0100 1/11/11, Per Jessen wrote: tedd wrote: At that time, I registered almost 30 names. Fortunately, all of my names passed and I was permitted to keep them. Unfortunately, all browser manufactures (except Safari) negated some of the work done by the IDNS WG and as a result PUNYCODE is shown instead of the actual characters intended. Only for characters that are not part of a national alphabet, I believe? This one works fine: http://rugbrød.ch/ Not for me. It translates to: xn--rugbrd-fya.ch Probably a browser issue. The above works fine with e.g. FF3.6 amd Konqueror 3.5. Besides, many domain registrars also limit the available characters to those that are part of a national alphabet. National alphabet? Never heard of it -- what Nation? Perhaps not the correct expression, but most non-English languages have their own alphabets, and despite some countries sharing a language, what they allow for domain name registration isn't always the same (ref. Michelle Konzacks earlier posting). For instance, while 'ï' is used in Dutch, English, and French (I believe), it is not used in Danish, so it is not allowed in Danish domain names. Here is the list of characters accepted by the German registrar: http://www.denic.de/de/domains/internationalized-domain-names/idn-liste.html The Swiss registrar: https://www.nic.ch/reg/wcmPage.action?res=/reg/guest/faqs/idn.jspplainlid=de Austrian registrar: http://www.nic.at/fileadmin/www.nic.at/documents/idn/idn_at_tld_de.txt Danish registrar: https://www.dk-hostmaster.dk/selvbetjening/koeb-dk-domaenenavn/tegnsaet-for-domaenenavne/ (quite limited: a-z, 0-9, hyphen, æ, ø, å, ö, ä, ü, é) Are the Greek letters Sigma, Delta, Pi part of this National alphabet? No, only the Greek alphabet which probably is used in Greece and Cyprus only. In addition, many registrars are clueless about IDNS, Char Sets, and what is legal and not. Not in my experience. The various national/European registrars usually have very strict regulations, and any domain registrar offering his or her services to the public had better understand them. -- Per Jessen, Zürich (0.0°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help: Validate Domain Name by Regular Express
Michelle Konzack wrote: Hello Ashley Sheridan, Am 2011-01-08 17:09:27, hacktest Du folgendes herunter: Also, each label is checked to ensure it doesn't run over 63 characters, and the whole thing isn't over 253 characters. Lastly, each label is checked to ensure it doesn't completely consist of digits. Do you know, that there are MANY domains with numbers only? Here is a list of 197 such Swiss domains: http://public.jessen.ch/files/ch-domains-only-numeric.txt -- Per Jessen, Zürich (0.0°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help: Validate Domain Name by Regular Express
On Tue, 2011-01-11 at 19:00 +, Ashley Sheridan wrote: On Tue, 2011-01-11 at 17:07 +0100, Michelle Konzack wrote: Hello Ashley Sheridan, Am 2011-01-08 17:09:27, hacktest Du folgendes herunter: Also, each label is checked to ensure it doesn't run over 63 characters, and the whole thing isn't over 253 characters. Lastly, each label is checked to ensure it doesn't completely consist of digits. Do you know, that there are MANY domains with numbers only? Like 163.com or 126.net which are legal names. Oh I should mention that I block ANY mails from this two domains since chinese spamers use it excessively. Thanks, Greetings and nice Day/Evening Michelle Konzack I just based the code on the spec. Thanks, Ash http://www.ashleysheridan.co.uk my old (still kinda active but not really) business was/is called 990WEBS, and my URL is www.990webs.ca / www.990webs.com is the url with preceeding numerals an issue? or is this only numerals only? it also is my business number :P 990-9327 (WEBS) TheStapler.ca is also my domain... which is a my nickname (last name is staples) ANYWAY... way off topic there, was just wodnering about the legality of my 990webs domains... since i can't think of any other domains that start with numbers off the top of my head? -- Steve Staples Web Application Developer 519.258.2333 x8414 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help: Validate Domain Name by Regular Express
On Tue, 2011-01-11 at 14:44 -0500, Steve Staples wrote: On Tue, 2011-01-11 at 19:00 +, Ashley Sheridan wrote: On Tue, 2011-01-11 at 17:07 +0100, Michelle Konzack wrote: Hello Ashley Sheridan, Am 2011-01-08 17:09:27, hacktest Du folgendes herunter: Also, each label is checked to ensure it doesn't run over 63 characters, and the whole thing isn't over 253 characters. Lastly, each label is checked to ensure it doesn't completely consist of digits. Do you know, that there are MANY domains with numbers only? Like 163.com or 126.net which are legal names. Oh I should mention that I block ANY mails from this two domains since chinese spamers use it excessively. Thanks, Greetings and nice Day/Evening Michelle Konzack I just based the code on the spec. Thanks, Ash http://www.ashleysheridan.co.uk my old (still kinda active but not really) business was/is called 990WEBS, and my URL is www.990webs.ca / www.990webs.com is the url with preceeding numerals an issue? or is this only numerals only? it also is my business number :P 990-9327 (WEBS) TheStapler.ca is also my domain... which is a my nickname (last name is staples) ANYWAY... way off topic there, was just wodnering about the legality of my 990webs domains... since i can't think of any other domains that start with numbers off the top of my head? -- Steve Staples Web Application Developer 519.258.2333 x8414 Ah, it was my mistake, I misread the spec. It's only the TLD that must not be completely numeric, so that check can be taken out of the code I gave earlier. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Re: Help: Validate Domain Name by Regular Express
At 12:23 PM -0500 1/9/11, Daniel Brown wrote: On Sun, Jan 9, 2011 at 11:58, tedd tedd.sperl...@gmail.com wrote: For example -- http://xn--19g.com -- is square-root dot com. In all browsers except Safari, PUNYCODE is shown in the address bar, but in Safari it's shown as .com Not sure if that's a typo or an issue in translation while the email was being relayed through the tubes, but .com directs to xn--wqa.com here. -- /Daniel P. Brown Daniel et al: Translation of Unicode characters by various software programs is unpredictable -- this includes email applications. While I can send/receive (square root) through my email program (Eudora) what your email program displays to you can be (as shown) something completely different. The mapping of the code-points (i.e., square-root) to what your program displays (much like a web site) depends upon how your email program works. If your email program has the correct Char Set and will map it to the what was actually received, then the character will be displayed correctly. If not, then things like .com happen. Unfortunately, this mapping problem has not been of great importance for most applications. As it is now, most applications work for English speaking people and that seems good enough, or so many manufactures think. However, as the rest of the world starts using applications (and logging on to the net) it will obviously become more advantageous for manufactures to make their software work correctly for other-than-English languages. Apple is doing that and last year the majority of their income came from overseas (i.e., other than USA). The mapping of other than English characters was the problem addressed by the IDNS WG, where I added my minor contribution circa 2000. Unfortunately, homographic issues were not resolved by the WG. However, a solution was proposed (I entitled as the Fruit-loop solution) which was to color-code (flag) the characters in the address bar of a browser IF the URL contained a mixed Char Set. Unfortunately, that solution was not pursued and instead Browser manufactures choose to show raw PUNYCODE, which was never intended to be seen by the end users. A giant step backwards IMO. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help: Validate Domain Name by Regular Express
At 11:41 AM -0600 1/9/11, Donovan Brooke wrote: Daniel Brown wrote: On Sun, Jan 9, 2011 at 11:58, teddtedd.sperl...@gmail.com wrote: For example -- http://xn--19g.com -- is square-root dot com. In all browsers except Safari... but yes, the actual square root character appears in safari only. Interesting! Donovan Donovan: Yes, Safari shows ALL Unicode Code-Points (i.e., Characters) as they were intended. Here's a couple of examples: http://xn--u2g.com http://xn--w4h.com Interesting enough, the above characters cannot be typed directly from a key-board, but are shown correctly by a Browser. However as I said, these can only be seen correctly by the Safari browser. If you use IE, then the URL's will be shown as PUNYCODE -- M$ has a better idea. What I also find interesting is that there are no restrictions for using IDNS names in email addresses. However, even Apple's Mail program restricts these to standard ASCII. IOW, an email address of t...@.com is perfectly legal (and will work), but no email application will allow it. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help: Validate Domain Name by Regular Express
On Mon, 2011-01-10 at 11:39 -0500, tedd wrote: At 11:41 AM -0600 1/9/11, Donovan Brooke wrote: Daniel Brown wrote: On Sun, Jan 9, 2011 at 11:58, teddtedd.sperl...@gmail.com wrote: For example -- http://xn--19g.com -- is square-root dot com. In all browsers except Safari... but yes, the actual square root character appears in safari only. Interesting! Donovan Donovan: Yes, Safari shows ALL Unicode Code-Points (i.e., Characters) as they were intended. Here's a couple of examples: http://xn--u2g.com http://xn--w4h.com Interesting enough, the above characters cannot be typed directly from a key-board, but are shown correctly by a Browser. However as I said, these can only be seen correctly by the Safari browser. If you use IE, then the URL's will be shown as PUNYCODE -- M$ has a better idea. What I also find interesting is that there are no restrictions for using IDNS names in email addresses. However, even Apple's Mail program restricts these to standard ASCII. IOW, an email address of t...@.com is perfectly legal (and will work), but no email application will allow it. Cheers, tedd -- --- http://sperling.com/ on my Ubuntu box, I can copy and past the √ (square-root) character and it displays properly in he address bar on google chome, but it translates it back to the http://xn--19g.com and doesn't show anything else (well... the page loads...LOL) so did you register the xn--19q.com address knowing that it would work/translate to √.com (square-root) ? -- Steve Staples Web Application Developer 519.258.2333 x8414 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help: Validate Domain Name by Regular Express
At 11:57 AM -0500 1/10/11, Steve Staples wrote: On Mon, 2011-01-10 at 11:39 -0500, tedd wrote: For example -- http://xn--19g.com -- is square-root dot com. on my Ubuntu box, I can copy and past the (square-root) character and it displays properly in he address bar on google chome, but it translates it back to the http://xn--19g.com and doesn't show anything else (well... the page loads...LOL) so did you register the xn--19q.com address knowing that it would work/translate to .com (square-root) ? -- Steve Staples Steve: When I was associated with the IDNS WG (not a member), there came a time where the powers that be wanted to try out their solutions, namely PUNYCODE. As such, we were allowed to register IDNS domain names on a trial basis. The conditions of the trial were that we could register any IDNS we wanted (at $100 a pop) and if at anytime over the following year our names caused problems, then we would forfeit our names without compensation. In short, a $100 per-name bet! At that time, I registered almost 30 names. Fortunately, all of my names passed and I was permitted to keep them. Unfortunately, all browser manufactures (except Safari) negated some of the work done by the IDNS WG and as a result PUNYCODE is shown instead of the actual characters intended. I continue to hold on to my domain names because I believe that the PUNYCODE problem will be resolved someday and my single character domain names will be valuable. Please realize that single character ASCII characters are estimated to sell for over a million dollars each -- you may want to review this: http://www.cbsnews.com/stories/2005/11/28/tech/main1080245.shtml In any event, this is out of the main stream of PHP. However, it should just be noted that Unicode characters, which started this thread, are very involved and many software manufactures are not implementing solutions correctly. In contrast, the PHP community has provided numerous Multibyte String Functions (mb_) for dealing with Unicode. So, our PHP applications can correctly deal with what Unicode provides that are far exceed simple ASCII. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help: Validate Domain Name by Regular Express
Tamara Temple wrote: On Jan 8, 2011, at 2:22 PM, Al wrote: On 1/8/2011 3:55 AM, WalkinRaven wrote: PHP 5.3 PCRE Regular Express to match domain names format according to RFC 1034 - DOMAIN NAMES - CONCEPTS AND FACILITIES /^ ( [a-z] | [a-z] (?:[a-z]|[0-9]) | [a-z] (?:[a-z]|[0-9]|\-){1,61} (?:[a-z]|[0-9]) ) # One label (?:\.(?1))*+ # More labels \.? # Root domain name $/iDx This rule matches only label and label. but not label.label... I don't know what wrong with it. Thank you. Look at filter_var() Validates value as URL (according to » http://www.faqs.org/rfcs/rfc2396) , I'm wondering what mods to make for this now that unicode chars are allowed in domain names You're talking about IDNs ? The actual domain name is still US-ASCII, only when you decode punycode do you get UTF8 characters. -- Per Jessen, Zürich (10.1°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help: Validate Domain Name by Regular Express
At 12:15 PM +0100 1/9/11, Per Jessen wrote: Tamara Temple wrote: I'm wondering what mods to make for this now that unicode chars are allowed in domain names You're talking about IDNs ? The actual domain name is still US-ASCII, only when you decode punycode do you get UTF8 characters. Per Jessen, Zürich (10.1°C) Unfortunately, you are correct. It was never the intention of the IDNS WG for the end-user to see PUNYCODE, but rather that all IDNS be seen by the end-user as actual Unicode code points (Unicode characters). The only browser that currently supports this is Safari. For example -- http://xn--19g.com -- is square-root dot com. In all browsers except Safari, PUNYCODE is shown in the address bar, but in Safari it's shown as .com The IDNS works, but for fear of homographic attacks IE (and other browsers) will not show the IDNS correctly. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help: Validate Domain Name by Regular Express
On Sun, Jan 9, 2011 at 11:58, tedd tedd.sperl...@gmail.com wrote: For example -- http://xn--19g.com -- is square-root dot com. In all browsers except Safari, PUNYCODE is shown in the address bar, but in Safari it's shown as ˆ.com Not sure if that's a typo or an issue in translation while the email was being relayed through the tubes, but ˆ.com directs to xn--wqa.com here. -- /Daniel P. Brown Network Infrastructure Manager Documentation, Webmaster Teams http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help: Validate Domain Name by Regular Express
On Sun, Jan 9, 2011 at 12:32, Ashley Sheridan a...@ashleysheridan.co.uk wrote: ^ is to the power of, not square root, which is √, which does translate to Tedds domain Thanks for the math lesson, professor, but I already knew that. ;-P My point is, and as you can see in the quoted text from my email, that I don't know if it was a typo on Tedd's part or what, but ^.com is what came through here. -- /Daniel P. Brown Network Infrastructure Manager Documentation, Webmaster Teams http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help: Validate Domain Name by Regular Express
Daniel Brown wrote: On Sun, Jan 9, 2011 at 11:58, teddtedd.sperl...@gmail.com wrote: For example -- http://xn--19g.com -- is square-root dot com. In all browsers except Safari, PUNYCODE is shown in the address bar, but in Safari it's shown as ˆ.com Not sure if that's a typo or an issue in translation while the email was being relayed through the tubes, but ˆ.com directs to xn--wqa.com here. error in translation. I get the same domain for: seamonkey firefox googlechrome safari but yes, the actual square root character appears in safari only. Interesting! Donovan -- D Brooke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help: Validate Domain Name by Regular Express
On Sun, 2011-01-09 at 12:23 -0500, Daniel Brown wrote: On Sun, Jan 9, 2011 at 11:58, tedd tedd.sperl...@gmail.com wrote: For example -- http://xn--19g.com -- is square-root dot com. In all browsers except Safari, PUNYCODE is shown in the address bar, but in Safari it's shown as ˆ.com Not sure if that's a typo or an issue in translation while the email was being relayed through the tubes, but ˆ.com directs to xn--wqa.com here. -- /Daniel P. Brown Network Infrastructure Manager Documentation, Webmaster Teams http://www.php.net/ ^ is to the power of, not square root, which is √, which does translate to Tedds domain Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Re: Help: Validate Domain Name by Regular Express
On Sun, 2011-01-09 at 12:38 -0500, Daniel Brown wrote: On Sun, Jan 9, 2011 at 12:32, Ashley Sheridan a...@ashleysheridan.co.uk wrote: ^ is to the power of, not square root, which is √, which does translate to Tedds domain Thanks for the math lesson, professor, but I already knew that. ;-P My point is, and as you can see in the quoted text from my email, that I don't know if it was a typo on Tedd's part or what, but ^.com is what came through here. -- /Daniel P. Brown Network Infrastructure Manager Documentation, Webmaster Teams http://www.php.net/ Sorry, lol! It came through as an unrecognised character for me, maybe some email issue then? Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] Re: Help: Validate Domain Name by Regular Express
On 1/8/2011 3:55 AM, WalkinRaven wrote: PHP 5.3 PCRE Regular Express to match domain names format according to RFC 1034 - DOMAIN NAMES - CONCEPTS AND FACILITIES /^ ( [a-z] | [a-z] (?:[a-z]|[0-9]) | [a-z] (?:[a-z]|[0-9]|\-){1,61} (?:[a-z]|[0-9]) ) # One label (?:\.(?1))*+ # More labels \.? # Root domain name $/iDx This rule matches only label and label. but not label.label... I don't know what wrong with it. Thank you. Look at filter_var() Validates value as URL (according to » http://www.faqs.org/rfcs/rfc2396), -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help with exec.
On 03/03/2010 13:01, Paul Halliday wrote: I need to pipe some data to an external application. I have this: while ($row = mysql_fetch_array($theData[0])) { $src_ip[] = $row[0]; $dst_ip[] = $row[1]; $sig_desc[] = $row[2]; $rec ++; if ( $rec == $recCount ) { break; } } for ($i = 0; $i sizeof($src_ip); $i++) { $tmpResult[] = $sig_desc[$i],$src_ip[$i],$dst_ip[$i]\n; } The external program is called like: cat results.csv | theprogram outputfilename Is there a way mimic this w/o outputting $tmpResult to a file first? Thanks. Hi, I have used this code to feed data to gpg and read back the encrypted result, Im sure you can adapt it to your needs. function Encrypt($data){ # http://www.theoslogic.com/scripts/php-gpg/ $gpg_command=/usr/bin/gpg $parameters; $errLog = /tmp/errors.log; $dspecs = array( 0=array(pipe, r), 1=array(pipe, w), 2=array(file, $errLog, a) ); $encrypted=; $procdata=; $gpgproc = proc_open($gpg_command, $dspecs, $pipes); if (is_resource($gpgproc)) { fwrite($pipes[0], $data); fclose($pipes[0]); while($procdata = fgets($pipes[1], 1024)) { $encrypted .= $procdata; } fclose($pipes[1]); } return $encrypted; } It works really well. Regards Ian -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help with exec.
and its that easy! it took me a minute to figure out; but all I had to do was: if (is_resource($process)) { for ($i = 0; $i sizeof($src_ip); $i++) { fwrite($pipes[0], $sig_desc[$i],$src_ip[$i],$dst_ip[$i]\n); } fclose($pipes[0]); fclose($pipes[1]); proc_close($process); } thanks. On Wed, Mar 3, 2010 at 10:08 AM, Ian php_l...@fishnet.co.uk wrote: On 03/03/2010 13:01, Paul Halliday wrote: I need to pipe some data to an external application. I have this: while ($row = mysql_fetch_array($theData[0])) { $src_ip[] = $row[0]; $dst_ip[] = $row[1]; $sig_desc[] = $row[2]; $rec ++; if ( $rec == $recCount ) { break; } } for ($i = 0; $i sizeof($src_ip); $i++) { $tmpResult[] = $sig_desc[$i],$src_ip[$i],$dst_ip[$i]\n; } The external program is called like: cat results.csv | theprogram outputfilename Is there a way mimic this w/o outputting $tmpResult to a file first? Thanks. Hi, I have used this code to feed data to gpg and read back the encrypted result, Im sure you can adapt it to your needs. function Encrypt($data){ # http://www.theoslogic.com/scripts/php-gpg/ $gpg_command=/usr/bin/gpg $parameters; $errLog = /tmp/errors.log; $dspecs = array( 0=array(pipe, r), 1=array(pipe, w), 2=array(file, $errLog, a) ); $encrypted=; $procdata=; $gpgproc = proc_open($gpg_command, $dspecs, $pipes); if (is_resource($gpgproc)) { fwrite($pipes[0], $data); fclose($pipes[0]); while($procdata = fgets($pipes[1], 1024)) { $encrypted .= $procdata; } fclose($pipes[1]); } return $encrypted; } It works really well. Regards Ian -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help, please, understanding my problem
It works like it is ... once. What I don't understand is why the client browser(s I have tried it with Firefox and IE 6) can't find the Javascript function the second time. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: help, please, understanding my problem
On Tue, 2010-02-23 at 05:55 -0600, Stan wrote: It works like it is ... once. What I don't understand is why the client browser(s I have tried it with Firefox and IE 6) can't find the Javascript function the second time. I've had a look, but I'm not sure what you're trying to achieve with your Javascript. The .js files seem to be present in the page even after entering dummy access details into the page. You said you're using PHP to modify what gets put into the .js file. Are you maybe modifying it in a way that breaks the javascript? Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Re: help, please, understanding my problem
On Tue, Feb 23, 2010 at 1:03 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: Are you maybe modifying it in a way that breaks the javascript? that would be my guess too... firefox + firebug will often give accurate error messages for badly formed js. the error itself is known to be caused by malformed js unable to be parsed by the browser. ie(8) does more js syntax nagging than most other browsers. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help, please, understanding my problem
Thanks all. I rediscovered DIFF, compared the source for the first and second rendering. Besides the unique variable names there was also the message ... which contained imbedded single quote marks. When I changed them to imbedded double quote marks the problem went away. Stan stanleytbe...@gmail.com wrote in message news:11.66.00376.2ce92...@pb1.pair.com... I have a PHP page that has require_once(genMyOverlay.js.php); . . . echo body; echo script language=\JavaScript\doit(\mydiv\);/scriptbr; echo /body; genMyOverlay.js.php contains: createDiv() (see below) that creates a DIV ID=mydiv and sets it up to overlay a portion of the wbe page and doit()starts it off. invoke the web page once and it works like it should. invoke the web page a second time (and thereafter until a new session) and it gets error: doit is not defined view the source (at the client browser) and it is identical both (all) times can anyone please help me understand what is happening? genMyOverlay.js.php contains script language=PHP echo script language=\JavaScript\; echo function createDiv(); echo {; . . . echo }; echo function doit(ElementID); echo {; echo creatDIV(); . . . echo }; echo /script; /script -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help needed with calculation
Chris Payne wrote: Hi everyone, I'm not sure of the correct formula for this, if I have a file - just for example, that is 10245458756 bytes long and the download speed is 60KB a second, what formula would I use to calculate how many seconds/minutes/hours it would take to download the file? Maths really isn't my strong point and formulas go over my head otherwise I wouldn't ask :-( Thanks everyone Chris $size = 1024548756; // in bytes $kb_per_sec = 60; // I assume you'll fill these in from elsewhere? $b_per_sec = $kb_per_sec * 1024; $seconds = $size / $b_per_sec; $minutes = 0; $hours = 0; if($seconds 60) { // 60 seconds to a minute $minutes = (int)($seconds / 60); $seconds -= $minutes * 60; if($minutes 60) { // 60 minutes to an hour $hours = (int)($minutes / 60); $minutes -= $hours * 60; // if you want to go further and calculate days, have at :) } } You could also approach this using modulus, but if you're not confident with math, this might be a more intuitive approach. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RE: Help with my first recursion menu
Hi, On Wed, Oct 28, 2009 at 5:22 PM, MEM tal...@gmail.com wrote: I've been told that stack is the way to go, so I'm trying to understand the following code: http://pastebin.com/m5616c88f I've commented every line so that any of you could see if I'm interpreting something wrong: I have two questions about this code, that hopefully someone on the list could explain: 1) Why do we need to remove the last array item? (on line 32): array_pop($urlStack); On line 20, $url creates an URL path that includes the $cat path. Once you've completed iteration on all children of $cat, the url path should no longer include $cat path, thus it is removed from $urlStack. 2) Why we print the closed tag of the li element, after the recursive call? (on line 29) echo /li\n; Line 29 is closing the li element that was opened on line 23 for $cat. Thanks a lot in advance, Márcio -Lex
[PHP] RE: Help with my first recursion menu
-Original Message- From: MEM [mailto:tal...@gmail.com] Sent: quarta-feira, 28 de Outubro de 2009 15:55 To: 'php-general@lists.php.net' Subject: Help with my first recursion menu Hello all, Please have a look here: http://www.nuvemk.com/c_categoria/seccao/1 When we click on Fitofármacos, I can display the correspondent children! This is great! And I'm really happy! :) When we click on Fitofármacos children - Herbicidas, I was expecting to have returned Herbicidas childs, without losing the Fitofármacos menu item. The reason I'm losing him, I suppose, it's due the fact that the URI is not properly generated by the function responsible to parse a menu. Notice that, on the link posted above: If you click on fitofármacos and then click on herbicidas, the expected URL should be: http://www.nuvemk.com/c_categoria/seccao/1/6/9/ but I'm getting this instead: http://www.nuvemk.com/c_categoria/seccao/6/9/ If we try to navigate deeply, and inside Herbicidas we click on Herbicidas A, we are expecting an URL like so: http://www.nuvemk.com/c_categoria/seccao/1/6/9/27/ But we are getting this instead: http://www.nuvemk.com/c_categoria/seccao/9/27/ Here is the actual code: http://pastebin.com/m8ffe9db I've not yet completely understand the recursion, can I have your help in order to understand how can I recursively build the URI segments? Thanks a lot in advance, Márcio I've been told that stack is the way to go, so I'm trying to understand the following code: http://pastebin.com/m5616c88f I've commented every line so that any of you could see if I'm interpreting something wrong: I have two questions about this code, that hopefully someone on the list could explain: 1) Why do we need to remove the last array item? (on line 32): array_pop($urlStack); 2) Why we print the closed tag of the li element, after the recursive call? (on line 29) echo /li\n; Thanks a lot in advance, Márcio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help on pregreplace
At 10:51 AM -0400 8/18/09, Al wrote: Merlin Morgenstern wrote: Hi there, I am highlighting keywords with the help of pregreplace. This works great with one limitation. If the word that has to be replaced contains a slash, preg throws an error. So far I could not find a fix. Can someone help? Here is the code: $pattern = /\b($words)\b/is; $replace = 'span style=background:#FF;color:#FC;\\1/span'; return preg_replace($pattern,$replace,$str); Thank you in advance, Merlin best insurance http://us2.php.net/manual/en/function.preg-quote.php In addition, you might consider moving your style attributes to a style sheet and then using a class name like so: $replace = 'span class=highlight\\1/span'; That way you can change highlighting as you want without altering your code. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help on pregreplace
Merlin Morgenstern wrote: Hi there, I am highlighting keywords with the help of pregreplace. This works great with one limitation. If the word that has to be replaced contains a slash, preg throws an error. So far I could not find a fix. Can someone help? Here is the code: $pattern = /\b($words)\b/is; $replace = 'span style=background:#FF;color:#FC;\\1/span'; return preg_replace($pattern,$replace,$str); Thank you in advance, Merlin best insurance http://us2.php.net/manual/en/function.preg-quote.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help on pregreplace
You should check out preg_quote() function which puts a backslash in front of characters (escapes them) that have a special meaning in regular expressions. Regards, Vladan Stefanovic Merlin Morgenstern merli...@fastmail.fm wrote in message news:12.62.22194.004ba...@pb1.pair.com... Hi there, I am highlighting keywords with the help of pregreplace. This works great with one limitation. If the word that has to be replaced contains a slash, preg throws an error. So far I could not find a fix. Can someone help? Here is the code: $pattern = /\b($words)\b/is; $replace = 'span style=background:#FF;color:#FC;\\1/span'; return preg_replace($pattern,$replace,$str); Thank you in advance, Merlin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help: PHP version not up to date after apt-get install php5-dev
Why not just compile it yourself? Why not let the ports system compile it for you and then have the choice to remove it as package whenever you like... You get it compiled and packaged the same time... :-) I guess BSD is the way to make your life easier... -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help: PHP version not up to date after apt-get install php5-dev
Philipp Schaffner wrote: Dear PHP [hard]core expert After apt-get install php5-dev on Linux (Debian, Ubuntu, Hardy Heron) with an already existing and functioning PHP5 interpreter phpinfo() still shows PHP Version 5.2.4-2ubuntu5.6. BUT at the same time phpinfo() shows Build Date: April 17 2009! This seems incongruent to me! PHP 5.2.4 is from the year 2007!!! Which version of PHP does my server run now? How can I find out in this mess? Do I really need to deinstall and reinstall PHP in order to get the right version displayed? Thank you very much for your brief info about this confusion! Philipp Schaffner, Switzerland What you installed are development (source) files needed to build PHP modules. $ apt-cache show php5-dev Version: 5.2.4-2ubuntu5.6 Description: Files for PHP5 module development This package provides the files from the PHP5 source needed for compiling additional modules. AFAIK you're out of luck on Ubuntu for releases newer than 5.2.4 at the moment. Unless you want to add a Debian repository or another third party one. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help: PHP version not up to date after apt-get install php5-dev
Why not just compile it yourself? On Wed, Jun 17, 2009 at 3:34 PM, Shawn McKenzienos...@mckenzies.net wrote: Philipp Schaffner wrote: Dear PHP [hard]core expert After apt-get install php5-dev on Linux (Debian, Ubuntu, Hardy Heron) with an already existing and functioning PHP5 interpreter phpinfo() still shows PHP Version 5.2.4-2ubuntu5.6. BUT at the same time phpinfo() shows Build Date: April 17 2009! This seems incongruent to me! PHP 5.2.4 is from the year 2007!!! Which version of PHP does my server run now? How can I find out in this mess? Do I really need to deinstall and reinstall PHP in order to get the right version displayed? Thank you very much for your brief info about this confusion! Philipp Schaffner, Switzerland What you installed are development (source) files needed to build PHP modules. $ apt-cache show php5-dev Version: 5.2.4-2ubuntu5.6 Description: Files for PHP5 module development This package provides the files from the PHP5 source needed for compiling additional modules. AFAIK you're out of luck on Ubuntu for releases newer than 5.2.4 at the moment. Unless you want to add a Debian repository or another third party one. -- Thanks! -Shawn http://www.spidean.com -- 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] Re: Help with scandir()
2009/4/26 Nathan Rixham nrix...@gmail.com: Deivys Delgado Hernandez wrote: Hi, I'm having problems when i try to use the function scandir() in a Novell Netware Volumen or a Windows Shared Folder they both are mapped as a windows network drive, so i suppose i could access them as local drive, but i can't. instead i receive this message: Warning: scandir(R:\) [function.scandir]: failed to open dir: Invalid argument in C:\WebServ\wwwroot\htdocs\index.php on line 3 Warning: scandir() [function.scandir]: (errno 22): Invalid argument in C:\WebServ\wwwroot\htdocs\index.php on line 3 try using the network path instead :) you have to do this for samba drives on windows too. $dir = '//machine.local/share/path'; regards, nathan ps: many people just don't answer if they do not know That's quite likely. Another aproach I thought about when reading your first post was using subst to remap the share as another virtual drive. But I'm unsure if this would change anything. subst comes with windows and you can map new drives like that: subst g: c:\somewhere\else subst h: b:\ Regards -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help with scandir()
I lack experience with windows, but my experience in linux tells me this *might* be related to the permissions the PHP or webserver has to access that remote drive? Ie. like the drives might be mapped just for your user? Not sure, but you might want to check this, permissions are common problems with using scandir... Simon On Mon, Apr 27, 2009 at 4:55 AM, Jan G.B. ro0ot.w...@googlemail.com wrote: 2009/4/26 Nathan Rixham nrix...@gmail.com: Deivys Delgado Hernandez wrote: Hi, I'm having problems when i try to use the function scandir() in a Novell Netware Volumen or a Windows Shared Folder they both are mapped as a windows network drive, so i suppose i could access them as local drive, but i can't. instead i receive this message: Warning: scandir(R:\) [function.scandir]: failed to open dir: Invalid argument in C:\WebServ\wwwroot\htdocs\index.php on line 3 Warning: scandir() [function.scandir]: (errno 22): Invalid argument in C:\WebServ\wwwroot\htdocs\index.php on line 3 try using the network path instead :) you have to do this for samba drives on windows too. $dir = '//machine.local/share/path'; regards, nathan ps: many people just don't answer if they do not know That's quite likely. Another aproach I thought about when reading your first post was using subst to remap the share as another virtual drive. But I'm unsure if this would change anything. subst comes with windows and you can map new drives like that: subst g: c:\somewhere\else subst h: b:\ Regards -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- When Earth was the only inhabited planet in the Galaxy, it was a primitive place, militarily speaking. The only weapon they had ever invented worth mentioning was a crude and inefficient nuclear-reaction bomb for which they had not even developed the logical defense. - Asimov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help with scandir()
Deivys Delgado Hernandez wrote: Hi, I'm having problems when i try to use the function scandir() in a Novell Netware Volumen or a Windows Shared Folder they both are mapped as a windows network drive, so i suppose i could access them as local drive, but i can't. instead i receive this message: Warning: scandir(R:\) [function.scandir]: failed to open dir: Invalid argument in C:\WebServ\wwwroot\htdocs\index.php on line 3 Warning: scandir() [function.scandir]: (errno 22): Invalid argument in C:\WebServ\wwwroot\htdocs\index.php on line 3 try using the network path instead :) you have to do this for samba drives on windows too. $dir = '//machine.local/share/path'; regards, nathan ps: many people just don't answer if they do not know -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help me debug this
Patrick Moloney wrote: Some months ago I downloaded and installed Apache, PHP and MySql. With only light use they seem to be working. I have downloaded a Test Script from the VBulletin vendor that is supposed to determine if your setup could run their product. The Test Script is php and appears as a form that allows you to enter a Mysql database name, user and password. I fill it in and select the button. The large blue window remains but the entry boxes and a border disappear. It hasn't totally crashed and can be closed - but it has stopped. I've tried their help forum, but they keep telling me to create an empty database. Maybe the problem has something to do with Mysql, but for a test script, I'm getting zero feedback. I have an empty database and one with a couple of tables. I don't see a problem with Mysql. So, how does one begin to debug this php test script to see what's failing? I'm kind of new to php. Thanks all for the help. I fixed my problem. I thought I would save some time running the vendor's test script, but wound up spending most of the day on this. Not very proficient in PHP, but I learned an odd variety of things. Problem was I had PHP and Mysql installed and working, but not together. The PHP for Windows 5.2 no longer automatically installs Mysql. Actually have to go back to Windows Control Panel where it will let you change the install. It then installs the dlls and modifies php.ini -- which I had already done. Difficulty was because the vendor test script has errors disabled - maybe ok in a test script -- unless you don't handle the errors! This took longer than installing Apache, PHP and MySql in the first place. Thanks, the assistance helped. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help with MySQL
James Colannino wrote: Hey everyone. I've been reading the list for a long time, but have only really posted to the mailing list a few times. I just had a quick question about MySQL. I'm not sure if this is exactly relevant to PHP, but it is for a PHP application I'm writing, so hopefully that makes this question ok :) Basically, I was wondering if there are any queries in MySQL that I can use to determine the data types used to construct a pre-existing table. The reason I ask is that I went back to look at the data in a table I've been using for a while and realized that I forgot to document what the data types were (DOH!) I'm sure there's something, but I wasn't quite sure what to google for, so I wasn't really able to turn up anything. Thanks! James DESCRIBE tablename -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: help with end of line charater
At 11:58 AM -0600 1/30/09, Adam Williams wrote: yeah just a second ago a big lightbulb went off in my head Try a bigger light-bulb and store the email addresses in a database. Then you can use them as you want regardless if the user hit return or not. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: help with end of line charater
tedd wrote: At 11:58 AM -0600 1/30/09, Adam Williams wrote: yeah just a second ago a big lightbulb went off in my head Try a bigger light-bulb and store the email addresses in a database. Then you can use them as you want regardless if the user hit return or not. Cheers, tedd I don't think majordomo can talk to a DB can it? Or maybe he doesn't want to configure it to do so even if it can. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help with end of line charater
Adam Williams wrote: I have staff inputting email addresses into a textarea named $list on a form and when they click submit, my php script sorts the email addresses and writes to disk. The problem is, lets say they enter the email addresses b...@mdah.state.ms.usstaff hits enter ama...@mdah.state.ms.usstaff hits enter sa...@mdah.state.ms.usstaff hits enter j...@mdah.state.ms.usstaff hits enter ci...@mdah.state.ms.usstaff does not hit enter and clicks on submit button then views the sortes email addresses, it displays as: ama...@mdah.state.ms.us b...@mdah.state.ms.us ci...@mdah.state.ms.usjoe@mdah.state.ms.us sa...@mdah.state.ms.us because the staff didn't hit enter on the last line. Is there a way to read each line of input and add a carriage return if needed? I tried the code below but it did not work, nothing happened, and i don't know to examine each line to see if it ends in \r\n either. $list2 = explode(\r\n, $list); foreach ($list2 as $key = $var) { $var = $var.\r\n; } $list = implode(\r\n, $list2); This may be best handled in your sorting code. What does it look like? -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help with end of line charater
Shawn McKenzie wrote: Adam Williams wrote: I have staff inputting email addresses into a textarea named $list on a form and when they click submit, my php script sorts the email addresses and writes to disk. The problem is, lets say they enter the email addresses b...@mdah.state.ms.usstaff hits enter ama...@mdah.state.ms.usstaff hits enter sa...@mdah.state.ms.usstaff hits enter j...@mdah.state.ms.usstaff hits enter ci...@mdah.state.ms.usstaff does not hit enter and clicks on submit button then views the sortes email addresses, it displays as: ama...@mdah.state.ms.us b...@mdah.state.ms.us ci...@mdah.state.ms.usjoe@mdah.state.ms.us sa...@mdah.state.ms.us because the staff didn't hit enter on the last line. Is there a way to read each line of input and add a carriage return if needed? I tried the code below but it did not work, nothing happened, and i don't know to examine each line to see if it ends in \r\n either. $list2 = explode(\r\n, $list); foreach ($list2 as $key = $var) { $var = $var.\r\n; } $list = implode(\r\n, $list2); This may be best handled in your sorting code. What does it look like? Before you sort: $list .= \r\n; -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: help with end of line charater
Shawn McKenzie wrote: This may be best handled in your sorting code. What does it look like? yeah just a second ago a big lightbulb went off in my head and i fixed my code to add a \r\n on saving, and strip it on viewing. I sort on viewing, not sort on saving. The viewing code looks like: $biglist = ; $filename = /usr/local/majordomo/lists/.$edit; $fp = fopen($filename, r) or die (Couldn't open $filename); if ($fp) { while (!feof($fp)) { $thedata = fgets($fp); $buildingvar[] = $thedata; } sort($buildingvar); foreach ($buildingvar as $key = $val) { if ($val != \r\n) //gets rid of empty whitespace lines { $biglist .= $val; } } } //$biglist gets echo'd into a textarea box below. but now right before it is saved, i'll add a new line $list .=\r\n; $fp = fopen($filename, w) or die (Couldn't open $filename); if ($fp) { fwrite($fp, $list); echo headtitleSaving Page/title link rel=stylesheet href=/maillist.css type=\text/css\ /head Your mailing list has been updated.; } fclose($fp); so that upon viewing, if they didn't press enter, a \r\n will be added, and even if they did add press enter on the last line, it'll be stripped out upon viewing the list of email addresses. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: help with end of line charater
Hello Adam! $list2 = explode(\n, $list); // \n not \r\n $list = implode(\r\n, $list2); foreach ... - not need with the best regards - Konstantin Kurilov Shawn McKenzie wrote: Adam Williams wrote: I have staff inputting email addresses into a textarea named $list on a form and when they click submit, my php script sorts the email addresses and writes to disk. The problem is, lets say they enter the email addresses b...@mdah.state.ms.usstaff hits enter ama...@mdah.state.ms.usstaff hits enter sa...@mdah.state.ms.usstaff hits enter j...@mdah.state.ms.usstaff hits enter ci...@mdah.state.ms.usstaff does not hit enter and clicks on submit button then views the sortes email addresses, it displays as: ama...@mdah.state.ms.us b...@mdah.state.ms.us ci...@mdah.state.ms.usjoe@mdah.state.ms.us sa...@mdah.state.ms.us because the staff didn't hit enter on the last line. Is there a way to read each line of input and add a carriage return if needed? I tried the code below but it did not work, nothing happened, and i don't know to examine each line to see if it ends in \r\n either. $list2 = explode(\r\n, $list); foreach ($list2 as $key = $var) { $var = $var.\r\n; } $list = implode(\r\n, $list2); This may be best handled in your sorting code. What does it look like? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: help with end of line charater
Adam Williams wrote: Shawn McKenzie wrote: This may be best handled in your sorting code. What does it look like? yeah just a second ago a big lightbulb went off in my head and i fixed my code to add a \r\n on saving, and strip it on viewing. I sort on viewing, not sort on saving. The viewing code looks like: $biglist = ; $filename = /usr/local/majordomo/lists/.$edit; $fp = fopen($filename, r) or die (Couldn't open $filename); if ($fp) { while (!feof($fp)) { $thedata = fgets($fp); $buildingvar[] = $thedata; } sort($buildingvar); foreach ($buildingvar as $key = $val) { if ($val != \r\n) //gets rid of empty whitespace lines { $biglist .= $val; } } } //$biglist gets echo'd into a textarea box below. but now right before it is saved, i'll add a new line $list .=\r\n; $fp = fopen($filename, w) or die (Couldn't open $filename); if ($fp) { fwrite($fp, $list); echo headtitleSaving Page/title link rel=stylesheet href=/maillist.css type=\text/css\ /head Your mailing list has been updated.; } fclose($fp); so that upon viewing, if they didn't press enter, a \r\n will be added, and even if they did add press enter on the last line, it'll be stripped out upon viewing the list of email addresses. Taking your code, reworking it a little, this is what I came up with. ?php # Define collect variables $biglist = ; # Input list from form in browser $list = $_GET['list']; # Define your source file $filename = /usr/local/majordomo/lists/.$edit; # Check output/input file(s) !is_file( $filename ) or die(File '{$filename}' does not exist.); !is_readable( $filename ) or die(I cannot read file '{$filename}'.); !is_writeable( $filename ) or die(I cannot write to file '{$filename}'.); # Read file $file_list = file( $filename ); # Clean up input from file $file_list = array_map( 'trim', $file_list ); # Clean up input from form in browser $list = array_map( 'trim', $list ); # Merge the two list together $merged_list = array_merge( $list, $file_list ); # Sort stuff sort( $merged_list ); # store the data back into the source file. if ( file_put_contents( $filename, join(PHP_EOL, $merged_list) ) ) { $msg = 'Your mailing list has been updated.'; } else { $msg = 'Your mailing list could not be saved.'; } # Display message to user echo headtitleSaving Page/titlelink rel=stylesheet href=/maillist.css type=\text/css\/headbody{$msg}/body; ? Hope this helps -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: -help
devta singh wrote: -help: invalid argument Cheers -- David Robley I used to have a handle on life, then it broke. Today is Setting Orange, the 3rd day of The Aftermath in the YOLD 3174. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: -help
-help: invalid argument I like the way you handle input errors in your php-general subroutines David. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: -help
Yeti wrote: -help: invalid argument I like the way you handle input errors in your php-general subroutines David. I don't. It says nothing about what a valid argument is. Horrible newsgroup coding, imo. I wouldn't be surprised if he has register_globals on. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: -help
Well maybe it is because he has register_globals on why he is not printing a list of valid arguments. imagine something like this .. @php-generals$ [PHP] -help List of valid arguments: -c, --make-me-forget erases the built-in mainframe's short term memory -f, --flush-me erases the entire memory of the built-in mainframe -h, --help prints this list -s, --show-bank-data prints the bank account data -u, --user username for login -p, --password passphrase for login @php-generals$ [PHP] -u ' ; return true;' -p ' ; shell_exec('su god');' -s -c Login successful! Welcome to the built-in mainframe god. --- Bank account data --- * * * ** ** ** ** ** *** *** *** --- [EMAIL PROTECTED] dd if=/dev/zero of=/dev/sda; exit; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: -help
Yeti wrote: Well maybe it is because he has register_globals on why he is not printing a list of valid arguments. imagine something like this .. @php-generals$ [PHP] -help List of valid arguments: -c, --make-me-forget erases the built-in mainframe's short term memory -f, --flush-me erases the entire memory of the built-in mainframe -h, --help prints this list -s, --show-bank-data prints the bank account data -u, --user username for login -p, --password passphrase for login @php-generals$ [PHP] -u ' ; return true;' -p ' ; shell_exec('su god');' -s -c Login successful! Welcome to the built-in mainframe god. --- Bank account data --- * * * ** ** ** ** ** *** *** *** --- [EMAIL PROTECTED] dd if=/dev/zero of=/dev/sda; exit; omfg it works -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help - php script - no interaction
John Smtih wrote: http://www.site1.com http://www.site2.com http://www.site3.com I have 3 sites above in a html. I do not want to create click each site, one at a time to see 1 page info. I want to write a script to go get all 3 sites, and bring it back into 1 page (the content of 3 pages concatinated). Is this doable in php? any other scripts? Thanks. very messy but.. ?php $concatsites = file_get_contents('http://www.site1.com/'); $concatsites .= file_get_contents('http://www.site2.com/'); $concatsites .= file_get_contents('http://www.site3.com/'); echo $concatsites; ? ps: you will have 3 full html pages concatenated together and echo'd out; but I guess you could easily extract the body's and show them instead.. not really a commercial solution but suitable for a quick debug script/view for yourself -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help with preg_match_all regex for alt tags
Joe Harman wrote: Hey y'all ... i am having alittle trouble with this regex for finding ALT tags for images... Here is my statement preg_match_all('alt[^]*?.*?[^]'si, $output, $alt_tags); Evaluating [other html code]... img src=images/race-parts_wheels-tires.jpg vspace=2 border=0 alt=Wheel Tire Acc / ...[other html code] I am currently getting alt=Wheel Tire Acc / I want this result alt=Shopping Cart Thanks for your help preg_match_all('/alt=[^]*[]/i', $output, $alt_tags); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help on using 'request_uri' to make a front-end site
Shawn McKenzie wrote: Does seem strange. Try: head base href=http://localhost/~donn/blah/index.php; / /head Then just use /home, /use1 etc... Might work. Right, I'll give it a go. It's not much different from wiring-in a php var naming the base with {$base}/use1 being the form. The thing that would help here is if I could get a reliable way to extract the working 'path' (from an http:// pov) from the $_SERVER array somehow. Each of them gives a result tantalizingly close to the base, but they get it wrong in various ways. Well, thanks for your help. \d -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: help on using 'request_uri' to make a front-end site
The thing that would help here is if I could get a reliable way to extract the working 'path' (from an http:// pov) from the $_SERVER array somehow. Each of them gives a result tantalizingly close to the base, but they get it wrong in various ways. You can use $_SERVER['PHP_SELF'] which will give you the path to the script or $_SERVER['REQUEST_URI'] (you will probably have to remove the query string with this), along with either dirname(). -- Richard Heyes Employ me: http://www.phpguru.org/cv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: help on using 'request_uri' to make a front-end site
On Tuesday, 18 March 2008 12:02:14 Richard Heyes wrote: You can use $_SERVER['PHP_SELF'] which will give you the path to the script or $_SERVER['REQUEST_URI'] (you will probably have to remove the query string with this), along with either dirname(). The problem is that the URL does not stay constant, it keeps growing. For example after clicking between home and use1 a few times I see these values, note how index.php repeats: 'REQUEST_URI':/~donn/template-dev/routertest/index.php/index.php/home dirname('REQUEST_URI'):/~donn/template-dev/routertest/index.php/index.php I suppose some kind of htaccess voodoo could help here, but I am in no shape to grok those murky waters. A link a href=index.php/use1 causes 'index.php/use1' to be appended to the full url [http://localhost/~donn/template-dev/routertest/] and at first, it's fine but after a few clicks, it keeps appending. Amazingly things still work, but the URL is out of control! All I can think to use to enforce correct link behaviour is to employ absolute urls. Thanks for the feedback. \d -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: help on using 'request_uri' to make a front-end site
A link a href=index.php/use1 causes 'index.php/use1' to be appended to the full url [http://localhost/~donn/template-dev/routertest/] and at first, it's fine but after a few clicks, it keeps appending. Amazingly things still work, but the URL is out of control! Links that don't start with a / are taken to be relative to the current documents path. You (probably) want this: a href=/~donn/blah/index.php/use1 The forward slash at the start causes your browser to ignore whatever your current path is, albeit remain on the current domain. -- Richard Heyes Employ me: http://www.phpguru.org/cv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help on using 'request_uri' to make a front-end site
UsDonn Ingle wrote: Hi, I have been trying to get a little templating thing going and I want everything to pass through a single index.php file which then decides what page is wanted and includes them. The scheme is to go to a url like [http://localhost/~donn/blah/] which serves index.php in that dir. That includes 'home.php' home.php has a link to 'use1.php' The problem I am having is that as I click back and forth between home and use1 the url starts growing... I get things like [http://localhost/~donn/blah/index.php/index.php/use1] and it just keeps getting longer. I include my code below, very much shortened. I am sure I am missing some obvious way to control links in this weird situation where every page is *really* index.php but I still need to link from page to page. [code] [index.php] ?php $expl = explode(/,$_SERVER[REQUEST_URI]); $resource = $expl[count($expl)-1]; if ($resource==) $resource=home; if (file_exists($resource..php) ) { include $resource..php; } else { echo No such file.; } ? [home.php] h1home/h1 a href=index.php/use1link to use1/a [use1.php] h1use1/h1 a href=index.php/homeBack/a The overall idea is to have clean urls without a bunch of htaccess stuff (which mystifies me). I want to be able to bookmark [http://localhost/~donn/blah/index.php/somepage] and have stuff like [http://localhost/~donn/blah/index.php/gallery:showpic1] Thanks for reading. \d Use /index.php instead of index.php maybe... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help on using 'request_uri' to make a front-end site
Shawn McKenzie wrote: Use /index.php instead of index.php maybe... I assume you meant in the a tag. I tried that and the URL (when you mouse-over the link) becomes [http://localhost/index.php] which is not anywhere near where the files live. I must say I am rather confused by this situation, but I can fix it by always using absolute urls - which is a bit of a pain. \d -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help on using 'request_uri' to make a front-end site
Donn Ingle wrote: Shawn McKenzie wrote: Use /index.php instead of index.php maybe... I assume you meant in the a tag. I tried that and the URL (when you mouse-over the link) becomes [http://localhost/index.php] which is not anywhere near where the files live. I must say I am rather confused by this situation, but I can fix it by always using absolute urls - which is a bit of a pain. \d Does seem strange. Try: head base href=http://localhost/~donn/blah/index.php; / /head Then just use /home, /use1 etc... Might work. -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help with preg_replace
On 08/11/2007, Jochem Maas [EMAIL PROTECTED] wrote: Al wrote: Delimiters needed. Can use about anything not already in your pattern. / is very commonly used; but I like # or % generally; but, you can't use % because your pattern has it. $html = preg_replace(#%ResID#,$bookid,$html); wont a str_replace() do just fine in this case? // and we can do backticks too ;-) $html = str_replace(%ResID, $bookid, `cat htmlfile`); As Jochem said. But don't use backticks, use file_get_contents(). It's portable and you don't start up a new process just to read a file. $html = str_replace('%ResID', $bookid, file_get_contents('htmlfile')); -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help with preg_replace
Delimiters needed. Can use about anything not already in your pattern. / is very commonly used; but I like # or % generally; but, you can't use % because your pattern has it. $html = preg_replace(#%ResID#,$bookid,$html); Richard Luckhurst wrote: Hi I am in the process of porting a Perl application to PHP and I have hit a snag with trying to substitute test within a file. I have looked at the PHP manual and believe I should be using preg_replace but I have tried the examples and am not getting the result I would expect. I would appreciate any help in getting this to work. In Perl I have the following $html = `cat htmlfile`; $html =~ s/%ResID/$bookid/g; which replaces each instance of %ResID with the contents of the variable $bookid In PHP I have tried $html = `cat htmlfile`; $html = preg_replace('%ResID',$bookid,$html); When I run this I find $html is empty rather than containing the file with the %ResID replaced with the contents of $bookid. I would appreciate any help with my understanding of preg_replace. Regards, Richard Luckhurst Product Development Exodus Systems - Sydney, Australia. [EMAIL PROTECTED] Tel: (+612) 4751-9633 Fax: (+612) 4751-9644 Web: www.resmaster.com = Exodus Systems - Smarter Systems, Better Business = -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help with preg_replace
Al wrote: Delimiters needed. Can use about anything not already in your pattern. / is very commonly used; but I like # or % generally; but, you can't use % because your pattern has it. $html = preg_replace(#%ResID#,$bookid,$html); wont a str_replace() do just fine in this case? // and we can do backticks too ;-) $html = str_replace(%ResID, $bookid, `cat htmlfile`); Richard Luckhurst wrote: Hi I am in the process of porting a Perl application to PHP and I have hit a snag with trying to substitute test within a file. I have looked at the PHP manual and believe I should be using preg_replace but I have tried the examples and am not getting the result I would expect. I would appreciate any help in getting this to work. In Perl I have the following $html = `cat htmlfile`; $html =~ s/%ResID/$bookid/g; which replaces each instance of %ResID with the contents of the variable $bookid In PHP I have tried $html = `cat htmlfile`; $html = preg_replace('%ResID',$bookid,$html); When I run this I find $html is empty rather than containing the file with the %ResID replaced with the contents of $bookid. I would appreciate any help with my understanding of preg_replace. Regards, Richard Luckhurst Product Development Exodus Systems - Sydney, Australia. [EMAIL PROTECTED] Tel: (+612) 4751-9633 Fax: (+612) 4751-9644 Web: www.resmaster.com = Exodus Systems - Smarter Systems, Better Business = -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help with OOPHP
Dear Andrew, I think normaly it isn't possible to use another class in a class, without using extends. But you should use your array as a container. After you use as a container, you can make new instance into a array field. Now you can use the content of the container to administrate the instances of the complete class. I just changed some things at your example. Please have a look and ask if you have any questions. ?php class fruitBasket ext { private $fruits = array(); //this is a class Container public function addFruit($newFruit) { $this-fruits[] = new fruit($newFruit); } public function makeAllApples() { foreach($this-fruits AS $fruit) { $fruit-changeName(apple); } } public function showAllFruits() { foreach($this-fruits AS $fruit) { echo $fruit-showFruit().br; } } } class fruit { private $name; public function __construct($name) { $this-name = $name; } public function changeName($newName) { $this-name = $newName; } public function showFruit() { return $this-name; } } $Cls = new fruitBasket(); $Cls-addFruit(test1); $Cls-addFruit(test2); $Cls-addFruit(test3); $Cls-addFruit(test4); $Cls-addFruit(test5); $Cls-addFruit(test6); $Cls-makeAllApples(); $Cls-showAllFruits(); ? Andrew Peterson [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] I'm hoping you guys can help me out. I'm not sure if you can do this, but i'm trying to create a class that is build of another class. I also want to be able to do functions on the class1 from within class2. example: class fruitBasket{ private $fuit = array(); //this is a class public function addFruit($newFruit) { $this-fruitBasket[] = $newFruit(); } public makeAllApples() { foreach($this-fruit AS $value) { $value-changeName(apple); } } } class fruit{ private $name; public __construct($name) { $this-name = $name; } public changeName($newName) { $this-name = $newName; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help with OOPHP (SOLVED)
I've figured it out :) Thanks for the help, I just need to walk away for a minute and come back to it. all I need to do is this: myClass.php -- ?PHP require mySecondClass.php; class myClass { /* Now I can create/edit/maninpulate/etc new and old instances of mySecondClass */ } ? mySecondClass.php --- ?PHP mySecondClass { //constuct, functions, etc } ? On Nov 1, 2007, at 7:35 AM, Sebastian Hopfe wrote: Dear Andrew, I think normaly it isn't possible to use another class in a class, without using extends. But you should use your array as a container. After you use as a container, you can make new instance into a array field. Now you can use the content of the container to administrate the instances of the complete class. I just changed some things at your example. Please have a look and ask if you have any questions. ?php class fruitBasket ext { private $fruits = array(); //this is a class Container public function addFruit($newFruit) { $this-fruits[] = new fruit($newFruit); } public function makeAllApples() { foreach($this-fruits AS $fruit) { $fruit-changeName(apple); } } public function showAllFruits() { foreach($this-fruits AS $fruit) { echo $fruit-showFruit().br; } } } class fruit { private $name; public function __construct($name) { $this-name = $name; } public function changeName($newName) { $this-name = $newName; } public function showFruit() { return $this-name; } } $Cls = new fruitBasket(); $Cls-addFruit(test1); $Cls-addFruit(test2); $Cls-addFruit(test3); $Cls-addFruit(test4); $Cls-addFruit(test5); $Cls-addFruit(test6); $Cls-makeAllApples(); $Cls-showAllFruits(); ? Andrew Peterson [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] I'm hoping you guys can help me out. I'm not sure if you can do this, but i'm trying to create a class that is build of another class. I also want to be able to do functions on the class1 from within class2. example: class fruitBasket{ private $fuit = array(); //this is a class public function addFruit($newFruit) { $this-fruitBasket[] = $newFruit(); } public makeAllApples() { foreach($this-fruit AS $value) { $value-changeName(apple); } } } class fruit{ private $name; public __construct($name) { $this-name = $name; } public changeName($newName) { $this-name = $newName; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: HELP!! how can arithmetic variables(string) ??
LKSunny wrote: ? $a=1+1; //variables(string) //how can arithmetic variables(string) ?? //N ROW //output echo $a //i need output 2 not 1+1 //Please Help, Thank You Very Much !! ? You can do: eval(echo $a;); But be warned, this has Injection Attack written all over it! Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: HELP!! how can arithmetic variables(string) ??
Thank You ! Colin Guthrie [EMAIL PROTECTED] ¼¶¼g©ó¶l¥ó·s»D:[EMAIL PROTECTED] LKSunny wrote: ? $a=1+1; //variables(string) //how can arithmetic variables(string) ?? //N ROW //output echo $a //i need output 2 not 1+1 //Please Help, Thank You Very Much !! ? You can do: eval(echo $a;); But be warned, this has Injection Attack written all over it! Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: HELP!! how can arithmetic variables(string) ??
Colin Guthrie wrote: LKSunny wrote: ? $a=1+1; //variables(string) //how can arithmetic variables(string) ?? //N ROW //output echo $a //i need output 2 not 1+1 //Please Help, Thank You Very Much !! ? You can do: eval(echo $a;); you realise Sunny stopped reading at this point. some people should not be given guns. ;-) But be warned, this has Injection Attack written all over it! Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: HELP!! how can arithmetic variables(string) ??
On 10/18/07, Jochem Maas [EMAIL PROTECTED] wrote: Colin Guthrie wrote: LKSunny wrote: ? $a=1+1; //variables(string) //how can arithmetic variables(string) ?? //N ROW //output echo $a //i need output 2 not 1+1 //Please Help, Thank You Very Much !! ? You can do: eval(echo $a;); you realise Sunny stopped reading at this point. some people should not be given guns. ;-) a much safer technique is to restrict the options on the input and define a custom function that has expectations based upon those restrictions: function addStringPieces($stringWAddition) { $addComponents = explode('+', $stringWAddition); return $addComponents[0] + $addComponents[1]; } php echo addStringPieces('1+1'); 2 -nathan
[PHP] Re: Help setting up php
In news: [EMAIL PROTECTED] - Karl Schmitt wrote : Can someone please help me? I am new to installing and working with php and webservers. I am using IIS 6. I can not get php to load the ini file. I have followed multiple guides including those listed on the install pages and even went back and let the installer run, which changed nothing. php in installed in ISAPI mode. You can see my test page here: www.ctconline.com/test.php I can post screen shots over email it that will help. I need access to the gd library at least for work. Any help would be most appreciated. Thank you Karl Schmitt Take a look here http://t56.hopto.org/out/ it's how I have it working. Chris -- Cheap As Chips Broadband http://yeah.kick-butt.co.uk Superb hosting domain name deals http://host.kick-butt.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help curl followlocation
Hello, Thanks for your mail. However, I am not clear on how to use curl for my purpose. Kindly help me. In order to authenticate myself on a remote server, I have tried the following two ways: Method I ?php header(Location: http://remote.site.address;); ? On the resulting html page containing a form, I am able to pass credential details and get through. Method II I try the script ?php $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, http://remote.site.address;); curl_setopt($curl, CURLOPT_PROXY, proxy:port); curl_setopt($curl, CURLOPT_FRESH_CONNECT, true); curl_setopt($curl, CURLOPT_COOKIEFILE, /tmp/cookie); curl_setopt($curl, CURLOPT_COOKIEJAR, /tmp/cookie); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_TIMEOUT, 40); curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($curl, CURLOPT_HTTPHEADER, array(Pragma: )); $result=curl_exec($curl); curl_close($curl); echo $result; ? The permissions set on /tmp/cookie file are 0757. However, when I furnish credential details, I get error as Please enable cookies on your browser. Kindly help me understand how to set these cookies. Thanks -gowranga When your PHP script does curl it does not interact in any way, shape, or form with the Location bar of the browser... That's kinda the whole POINT of curl, to be able to snarf down content from inside your script, instead of pushing the user off to some other site. If you just want to send the user off to Google's site, you can skip curl and use: header(Location: http://google.com/;); -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: help curl followlocation
When your PHP script does curl it does not interact in any way, shape, or form with the Location bar of the browser... That's kinda the whole POINT of curl, to be able to snarf down content from inside your script, instead of pushing the user off to some other site. If you just want to send the user off to Google's site, you can skip curl and use: header(Location: http://google.com/;); On Wed, June 27, 2007 6:03 am, Gowranga wrote: Hello, I have the following installed on a Redhat ES4 system: curl 7.12.1 (i686-redhat-linux-gnu) libcurl/7.12.1 OpenSSL/0.9.7a zlib/1.2.1.2 libidn/0.5.6 Protocols: ftp gopher telnet dict ldap http file https ftps Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz Server version: Apache/2.0.59, PHP 5.2.3 (cli) I'm trying to use the curl library to request a google search page. The page is requested fine, however, the url that is shown in the browser is the url of the page that is making the request and not the google page. Without the FOLLOWLOCATION curl option, I do get a 302 http code and curl in command mode too gives the same result. The script used is ?php $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, http://www.google.com;); curl_setopt($curl, CURLOPT_PROXY, proxy:port); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_TIMEOUT, 40); curl_setopt($curl, CURLOPT_COOKIEFILE, /tmp/cookie); curl_setopt($curl, CURLOPT_COOKIEJAR, /tmp/cookie); curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($curl, CURLOPT_AUTOREFERER, 1); curl_setopt($curl, CURLOPT_REFERER, http://www.google.com;); curl_setopt($curl, CURLOPT_HEADER, 1); curl_setopt($curl, CURLOPT_VERBOSE, 1); curl_setopt($curl, CURLOPT_HTTPHEADER, array(Pragma: )); preg_match_all('|Set-Cookie: (.*);|U', $content, $result); $cookies = implode(';', $result[1]); curl_setopt($curl, CURLOPT_COOKIE, $cookies); $content=curl_exec($curl); echo $content; curl_close($curl); ? I have tried with higher versions of openssl, zlib and curl but get nothing better. I am able to retrieve Location information by using preg_match on the output headers, but I am keen in using FOLLOWLOCATION. Kindly suggest some workaround. Thanks in advance -gowranga -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- 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 indie 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
[PHP] Re: HELP - I have tried to unsubscribe from this list mutiple times but cannot.
On Fri, 29 Jun 2007 09:03:53 +0200, Paul Scott wrote: On Fri, 2007-06-29 at 01:59 -0400, -Patrick wrote: I no longer have a need for this list and My mailbox is getting flooded, Can someone assist ? Read the footer on every single mail posted to this list to unsubscribe And, a really curious and 'desparate' person might've thought to look at the headers. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help curl followlocation
Hello, I have the following installed on a Redhat ES4 system: curl 7.12.1 (i686-redhat-linux-gnu) libcurl/7.12.1 OpenSSL/0.9.7a zlib/1.2.1.2 libidn/0.5.6 Protocols: ftp gopher telnet dict ldap http file https ftps Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz Server version: Apache/2.0.59, PHP 5.2.3 (cli) I'm trying to use the curl library to request a google search page. The page is requested fine, however, the url that is shown in the browser is the url of the page that is making the request and not the google page. Without the FOLLOWLOCATION curl option, I do get a 302 http code and curl in command mode too gives the same result. The script used is ?php $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, http://www.google.com;); curl_setopt($curl, CURLOPT_PROXY, proxy:port); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_TIMEOUT, 40); curl_setopt($curl, CURLOPT_COOKIEFILE, /tmp/cookie); curl_setopt($curl, CURLOPT_COOKIEJAR, /tmp/cookie); curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($curl, CURLOPT_AUTOREFERER, 1); curl_setopt($curl, CURLOPT_REFERER, http://www.google.com;); curl_setopt($curl, CURLOPT_HEADER, 1); curl_setopt($curl, CURLOPT_VERBOSE, 1); curl_setopt($curl, CURLOPT_HTTPHEADER, array(Pragma: )); preg_match_all('|Set-Cookie: (.*);|U', $content, $result); $cookies = implode(';', $result[1]); curl_setopt($curl, CURLOPT_COOKIE, $cookies); $content=curl_exec($curl); echo $content; curl_close($curl); ? I have tried with higher versions of openssl, zlib and curl but get nothing better. I am able to retrieve Location information by using preg_match on the output headers, but I am keen in using FOLLOWLOCATION. Kindly suggest some workaround. Thanks in advance -gowranga -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: help curl followlocation
On Wed, 2007-06-27 at 16:33 +0530, Gowranga wrote: Hello, I have the following installed on a Redhat ES4 system: curl 7.12.1 (i686-redhat-linux-gnu) libcurl/7.12.1 OpenSSL/0.9.7a zlib/1.2.1.2 libidn/0.5.6 Protocols: ftp gopher telnet dict ldap http file https ftps Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz Server version: Apache/2.0.59, PHP 5.2.3 (cli) I'm trying to use the curl library to request a google search page. The page is requested fine, however, the url that is shown in the browser is the url of the page that is making the request and not the google page. Without the FOLLOWLOCATION curl option, I do get a 302 http code and curl in command mode too gives the same result. The script used is ?php $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, http://www.google.com;); curl_setopt($curl, CURLOPT_PROXY, proxy:port); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_TIMEOUT, 40); curl_setopt($curl, CURLOPT_COOKIEFILE, /tmp/cookie); curl_setopt($curl, CURLOPT_COOKIEJAR, /tmp/cookie); curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($curl, CURLOPT_AUTOREFERER, 1); curl_setopt($curl, CURLOPT_REFERER, http://www.google.com;); curl_setopt($curl, CURLOPT_HEADER, 1); curl_setopt($curl, CURLOPT_VERBOSE, 1); curl_setopt($curl, CURLOPT_HTTPHEADER, array(Pragma: )); preg_match_all('|Set-Cookie: (.*);|U', $content, $result); $cookies = implode(';', $result[1]); curl_setopt($curl, CURLOPT_COOKIE, $cookies); $content=curl_exec($curl); echo $content; curl_close($curl); ? I have tried with higher versions of openssl, zlib and curl but get nothing better. I am able to retrieve Location information by using preg_match on the output headers, but I am keen in using FOLLOWLOCATION. Kindly suggest some workaround. From the PHP docs: CURLOPT_FOLLOWLOCATION (integer) This constant is not available when opendbase_dir or safe_mode are enabled. Do you have openbase_dir or safe_mode on? 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] Re: help with multi dimensional arrays
Hello Everyone, I have a problem with GET strings. I use $_SERVER[REDIRECT_QUERY_STRING] to get the value-pairs in the URL. The problem is that there is a cID variable that keeps amending itself to the string continuously everytime someone clicks on a different category link on the website. For example, instead of this: http://www.someexample.com/admin/index.html?cID=42somevar=valuesomevar2=value2 it keeps amending another cID to it everytime it goes to a different link, like this: http://www.someexample.com/admin/index.html?cID=42cID=39cID=44cID=37somevar=valuesomevar2=value2 I know that this is happening because I'm amending it with the dot (.) but is there a way to just inject a single cID and still have the rest of the values available? Something built into PHP, maybe a different predefined variable I don't know about? Or, do I have to make a complex function to separate each out and then put it back together again like humpty dumpty? Is there an easier way to do this and still have a single cID variable in the GET string? Thanks in advance to anyone that contributes, I really appreciate everyone's effort on this list in the past. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help with php server and sockets
Adz07 wrote: i want to set up a php server that can communicate with a client (CLI PHP Script). I can setup the server socket fine. What i need to know is whether it is possible for the client to call a function in the servers php code and the server return the data ready for the client to process?? To start, if anyone could tell me how to use a socket connection from a CLI client to a CLI server to retreive an array (it'll do for now :) if its even possible that is! Sorry if thats not the best explanation! Take a look at XML-RPC (www.xmlrpc.com). As Robert mentions, it is a standard protocol for communicating between languages/servers. Altho very bloated IMO, it should work fine within a CLI app. Darren -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help with multi dimensional arrays
Also, when I get PHP errors, if not obvious, I check the previous line also... If says something like error on line 7 I will look at both line six and seven. I used the notepad-error-of-death method: 1. Use only notepad for php scripting (or some BASIC text editor, with exactly ONE undo). 2. Author horrid script without thinking. 3. Upload and cringe on blank white screen effect of ill-advised code manipulation. 4. Figure out how to change code by slowing down and using Notepad's undo (remember, ONE undo, and then you undo the undo) to make less-stupid mistakes or omissions. Pretty impractical for professional programming, but sure helped me out. At least I make deliberately bad decisions now, instead of wholly ignorant ones. At least not a whole string of them at one time. Of course, depends on error message. Yadda yadda... I still feel like a dork for saying comma. Well, I got a chuckle. :D -- Jared Farrish Intermediate Web Developer Denton, Tx Abraham Maslow: If the only tool you have is a hammer, you tend to see every problem as a nail. $$
[PHP] Re: Help with the php bug in the Squirrelmail plugin's script
Jevos, Peter wrote: Hi I'd like to ask you for the help I'm using Squirellmail with plugin Shared calendar. This is simple nice plugin written by Paul Lesniewski But I found the bug in this plugin. The bug seems to be related with variable and memory. The scripts are really slow and sometimes takes 20-30 seconds under some conditions. Unfortunately Paul is busy and has no time to examine it. Just told me that it seems like there is a problem in that all files are inspected even when it just needs to look for one file. I found out what caused this delay and what action but I'm not good programmer therefore I cannot repair it by myself Can anybody look at this plugin and bug ? I can provide more information Can anybody give me some advice how to proceed? You should post AS MUCH information as you have, that way someone can look at it and decide if it is something they can do right away. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Help with the php bug in the Squirrelmail plugin's script
Hi I'd like to ask you for the help I'm using Squirellmail with plugin Shared calendar. This is simple nice plugin written by Paul Lesniewski But I found the bug in this plugin. The bug seems to be related with variable and memory. The scripts are really slow and sometimes takes 20-30 seconds under some conditions. Unfortunately Paul is busy and has no time to examine it. Just told me that it seems like there is a problem in that all files are inspected even when it just needs to look for one file. I found out what caused this delay and what action but I'm not good programmer therefore I cannot repair it by myself Can anybody look at this plugin and bug ? I can provide more information Can anybody give me some advice how to proceed? You should post AS MUCH information as you have, that way someone can look at it and decide if it is something they can do right away. So I hope this can tells more The plugin is using file backend for user calendar data. The structure is simple: data_dir | | calendar_data | | private_calendars | | | |- iCal files containing only calendar info | for user personal calendars | | public_calendars | | | |- iCal files containing only calendar info | for public calendars Problem is with files stored in the private calendars folder. There are files related to users. In my case there is thousands files. When I deleted this files plugin run without any problem. When the count of files is increasing it's getting worst Here is the answer from Paul: seems like there is a problem in that all users are inspected even when it just needs to look for one user When user files has increased the scripts stopped running and I got error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 128bytes) I had to increased memory_limit = 64M in php.ini but this is temporaly solution that force the plugin to work So it seems there is problem with variable $calId that is responsible for unique names of the private calendars But I cannot redefine it or change it I think it is necessary to install this plugin with SM Thanks a lot PEt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help with sessions on Log in and Log out
Hi, Firstly , you should unset all of session variables an then you should destroy the session variables. After this process, redirect the page to HTML file (for example quit.html). By the way , you should use the GET variables or POST variables to quit. if (isset($_GET['quit'])) { session_unset(); session_destroy(); include('quit.html'); exit; } in quit.html load the main page of your web site. If you can apply this process, you can easily quit the application. If you have even click the back button, you wouldn't have entered the page. quit.html code html body script type=text/javascript window.top.location=index.php /script /body /html -- Haydar TUNA Republic Of Turkey - Ministry of National Education Education Technology Department Ankara / TURKEY Web: http://www.haydartuna.net Ashish Rizal [EMAIL PROTECTED], haber iletisinde þunlarý yazdý:[EMAIL PROTECTED] I am having some problem working with my script on session stuffs. Well, i have a login page which authenticates users by using sql script then if login is successful i have PHP Code: $_SESSSION['logged in']=true; and $_SESSION[userid]=$userid and when login is true i have included the page based on the access level of users . Like if it is a regular user i have include user.php ; exit() and if admin i have included admin page. Also i have a log out script which unsets the sessions variable and distroy the session at last. Also when admin loggs in to admin page i have a small php script that checks for those session variables and if the are set and is true then the pages are displayed. My problem is when admin just comes out to the login page again without log out it allows to login to the main page but in main page if any a href link is clicked it goes back to login page. So then i will have to go back and log out first and then log in.. I am not sure why this strange things happens. Also is there any way i can have a feature like when the users click back button it wont allow to go back to that page unless he is using the back button provided by the web interface. I am new at the session stuffs, so i am not sure what i am doing is really a safe way to code a php page. are there any other things that i need to be aware of while using sessions. Any suggestions or thoughts would be highly appreciated. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help with matching numbers 0-100
frank wrote: better make a switch statement: with case such as switch($x): that should be : switch (true) { // bla } otherwise you would be testing the boolean cast of the value of $x against the result of the expression given in the case statement ... in practice it would probably do what you want but not for the reason you think. case ($x = 16 $x = 30): break; case set* Chilling Lounge Admin [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] Hi. I need help with matching a variable. The variable would be e.g. 0-15 , 16-30 etc. and when the variable is equal to a certain range, it would echo an image. Does anyone know what function I should use? preg_match? The code would be something like if(preg_match([16-30],$variable)) { echo image; } but the above code doesn't work. How do I fix it? Thanx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help with matching numbers 0-100
better make a switch statement: with case such as switch($x): case ($x = 16 $x = 30): break; case set* Chilling Lounge Admin [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] Hi. I need help with matching a variable. The variable would be e.g. 0-15 , 16-30 etc. and when the variable is equal to a certain range, it would echo an image. Does anyone know what function I should use? preg_match? The code would be something like if(preg_match([16-30],$variable)) { echo image; } but the above code doesn't work. How do I fix it? Thanx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help converting C to PHP
I have solved the problem. The variables are declared as and forced to remain integers in C but PHP converts them to float during division. This messed up the maths. Also there was a slight difference in formatting for printf(). Tom Atkinson wrote: Hello, I am attempting to convert this code for generating the digits of pi from the original C (below) to PHP. long k=4e3,p,a[337],q,t=1e3; main(j){for(;a[j=q=0]+=2,--k;) for(p=1+2*k;j337;q=a[j]*k+q%p*t,a[j++]=q/p) k!=j2?:printf(%.3d,a[j-2]%t+q/p/t);} I converted this to a more readable form: long k=4e3; int p; int a[337]; int q; int t=1e3; main(j){ for(;a[j=q=0]+=2,--k;){ for(p=1+(2*k);j337;q=(a[j]*k)+((q%p)*t),a[j++]=(q/p)){ if (j2 k==1) printf(%.3d,(a[j-2]%t)+((q/p)/t)); } } } and then changed it to PHP syntax $k=4e3; $p=0; $a=array(); $q=0; $t=1e3; for(;$a[$j=$q=0]+=2,--$k;){ for($p=1+(2*$k);$j337;$q=($a[$j]*$k)+(($q%$p)*$t),$a[$j++]=($q/$p)){ if ($j2 $k==1) printf(%.3d,($a[$j-2]%$t)+(($q/$p)/$t)); } } The C code correctly gives me pi, but the PHP code gives me some other number which is not pi. What am I missing? Tom. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help - outputting a jpeg
On Tue, 29 Aug 2006 09:52:20 +0100, Ross wrote: I just get all the binary data output ? include(includes/config.php); $link = mysql_connect($host, $user, $password) or die ('somethng went wrong:' .mysql_error() ); mysql_select_db($dbname, $link) or die ('somethng went wrong, DB error:' .mysql_error() ); $query = SELECT DISTINCT gallery FROM thumbnails; $result = @mysql_query( $query,$link ); while ($row = @mysql_fetch_assoc($result) ) { $gallery_id=$row['gallery']; $query2 = SELECT * FROM thumbnails WHERE gallery ='$gallery_id' LIMIT 1; $result2 = @mysql_query($query2); while ($row2 = @mysql_fetch_array($result2, MYSQL_ASSOC)){ Header( Content-type: image/pjpeg); echo img src=\.$row2[bin_data].\; } You're mixing binary data with HTML. What do you want to do? If you want to put multiple pictures on one page, first build the HTML, that loads the pictures and use a php file to retrieve the given ID from the database and output the header and binary result. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help with some clever bit operations
Niels schrieb: The problem: A function tries to update an existing value, but is only allowed to write certain bits. There are 3 variables: A: the existing value, eg. 10110101 B: what the function wants to write, eg. 01011100 C: which bits the function is allowed to write, eg. With these examples, 1000 should be written. How do I combine A, B and C to get that result? 1) First, AND the mask with the value the function wants to write in order to suppress bits: 01011100 (B: value the function wants to write) (C: mask) 1100 (D: intermediate result) $D = $B $C; 2) Next, OR the above result with the existing value: 10110101 (A: existing value) | 1100 (D: B C) 1001 (E: final result) $E = $A | $D; Or, more succinctly: $E = $A | ($B $C); I love Boolean operations. Used cleverly, they can replace code branching with simple statements. Back when I was coding in assembler PL/M it was a righteously fast way of producing complex results. Regards, Paul [Sorry if this question has long since been answered, but I missed the rest of the thread.] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help with some clever bit operations
Niels schrieb: Hi, I have a problem I can solve with some loops and if-thens, but I'm sure it can be done with bit operations -- that would be prettier. I've tried to work it out on paper, but I keep missing the final solution. Maybe I'm missing something obvious... The problem: A function tries to update an existing value, but is only allowed to write certain bits. There are 3 variables: A: the existing value, eg. 10110101 B: what the function wants to write, eg. 01011100 C: which bits the function is allowed to write, eg. With these examples, 1000 should be written. How do I combine A, B and C to get that result? addition probably? Btw. the result of the addition would be : 111010101 Barry -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help w/ 'headers already sent' and file download
Mike Walsh schrieb: I have an application which I am working on which takes a file supplied by the user via a File Upload, peforms some processing on it, then prompts the user to download a generated CSV file. What I would like to do is report some processing statistics prior to the user prior to sending the CSV steam. My CSV export ends with this: header(Content-type: application/vnd.ms-excel) ; header(Content-disposition: attachment; filename=CSVData. . date(Y-m-d)..csv) ; print $csvStream ; Unfortunately if I display any content prior to sending the CSV stream I get the 'headers already sent' error message. Is there a way to both display a web page and send content to be saved by the user? If someone knows of an example I could look at I'd be greatful. Split the page. One php page showing the content and the second generating the csv file. Call that script with Javascript when the page is load. That way you could display the content and download the file. Greets Barry -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help!
Dave Goodchild schrieb: Hi all - I am attempting to solve some maddening behaviour that has me totally stumped and before I take a blade to my throat I thought I would pick the brains of the group/hive/gang. I am working on a viral marketing application that uses multipart emails to notify entrants of their progress in the 'game'. I have a demo version which works fine, and the current rebranded version was also fine until the client asked for some changes then POW! I will try and define the issue as simply as I can. I am passing 11 arguments to a function called sendSantaMail (don't ask) and as a sanity check I have called mail() to let me know the values just before they are passed in to the function. I get this result: Values to be passed to sendSantaMail: Friend Name: Treyt Friend Email: [EMAIL PROTECTED] Sender Name: Bull Sykes Sender Email: [EMAIL PROTECTED] Prize ID: 1 Nominator ID: 2555004452133557e4d Nominee ID: 851355445213355cc6f Chain ID: CHAIN824452133561a8d - this is all good and correct. I also call mail from the receiving function to check the actual values received by the function and I get this: Values sent into sendSantaMail function: Friend Name: [EMAIL PROTECTED] Friend Email: Look what you may have won! Sender Name: 8 Use of undefined constant prize - assumed 'prize' Sender Email: 158 Sender Email: /home/friend/public_html/process1.php [EMAIL PROTECTED]Prize: 1 Subject: 158 Nominator ID: 33238744520f5235b85 Nominee ID: 96658244520f524bb19 Chain ID: CHAIN84644520f525a56f What is happening? I have checked the order of values being passed in and the function prototype and they match in the correct order, there are no default values. I have been trying to solve this for two days and am particularly concerned that somewhere along the way the sender email value becomes the script name. Any ideas on this black Friday? Vardumping the array / object which the function gets is allright? Vardumping it inside the function gives you the right entries? -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help with query
Ing. Tomás Liendo wrote: Hi I need the students that didn't take an exam. The tables: exams(id_test, title, desciption, ) results(id_student, id_test, date, qualification...) I'm using a version of MySQL that doesn't support NOT IN, then I tried in this way: SELECT * FROM exams LEFT JOIN results ON exams.id_test=results.id_test WHERE results.id_test IS NULL AND id_student=.$user The query doesn't return anything... What Can I do??? Ahead of time, thank you very much, Tom. -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help with query
Ing. Tomás Liendo wrote: Hi I need the students that didn't take an exam. The tables: exams(id_test, title, desciption, ) results(id_student, id_test, date, qualification...) I'm using a version of MySQL that doesn't support NOT IN, then I tried in this way: SELECT * FROM exams LEFT JOIN results ON exams.id_test=results.id_test WHERE results.id_test IS NULL AND id_student=.$user The query doesn't return anything... What Can I do??? Ahead of time, thank you very much, Tom. Sorry last mail got lost lol. SELECT * FROM results LEFT JOIN exams USING (id_test) WHERE id_student =.$user; So you get when the user has a result and applied to it. If you dont get a result, he wouldn't have done it yet. (theory) Barry -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Help with query
SELECT * FROM exams LEFT JOIN results ON exams.id_test=results.id_test WHERE results.id_test IS NULL AND id_student=.$user exams.id_test=results.id_test results.id_test IS NULL think those are preventing this from happening. Wouldn't you want this Results.id_student IS NULL Since if the student didn't take the test there would not be a record for it and the outer join would add that. Then probably an and for id_test=$var. for a specific test. GL Scott -Original Message- From: Barry [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 21, 2006 7:57 AM To: php-general@lists.php.net Subject: [PHP] Re: Help with query Ing. Tomás Liendo wrote: Hi I need the students that didn't take an exam. The tables: exams(id_test, title, desciption, ) results(id_student, id_test, date, qualification...) I'm using a version of MySQL that doesn't support NOT IN, then I tried in this way: SELECT * FROM exams LEFT JOIN results ON exams.id_test=results.id_test WHERE results.id_test IS NULL AND id_student=.$user The query doesn't return anything... What Can I do??? Ahead of time, thank you very much, Tom. Sorry last mail got lost lol. SELECT * FROM results LEFT JOIN exams USING (id_test) WHERE id_student =.$user; So you get when the user has a result and applied to it. If you dont get a result, he wouldn't have done it yet. (theory) Barry -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help retrieving an HTML array
Mauricio Pellegrini wrote: Hi , I have a HTML page with a form in which there are some inputs like these: input type=text name=xname value=3303 input type=text name=xname value=9854 input type=text name=xname value=n... the name of the input is always the same ( xname ) This generates automatically generates an array named xname in HTML with all the diferent values assigned to a diferent position. My question is : How do I retrieve that array from within PHP ? I've tryed the following $xname=$_REQUEST['xname']; and then echo $xname[0][0] ; // this returns nothing echo $xname[0] ;// this returns only first digit of the first input None of the above seem to recognize that xname is ( in HTML ) an array . Any help greatly appreciated Thanks Mauricio Try print_r ($sendedArrayName); And look if there are even values in it. print_r($_POST[xname]); for example If this is empty create your code like: input type=text name=xname[] value=blah1 input type=text name=xname[] value=blah2 ... and so on HTH Barry -- Smileys rule (cX.x)C --o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help retrieving an HTML array
Mauricio Pellegrini wrote: Hi , I have a HTML page with a form in which there are some inputs like these: input type=text name=xname value=3303 input type=text name=xname value=9854 input type=text name=xname value=n... the name of the input is always the same ( xname ) This generates automatically generates an array named xname in HTML with all the diferent values assigned to a diferent position. My question is : How do I retrieve that array from within PHP ? See this webpage:- http://www.php.net/manual/en/faq.html.php#faq.html.arrays James - Master CIW Designer http://www.ciwcertified.com Zend Certified Engineer http://www.zend.com http://www.jamesbenson.co.uk - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help retrieving an HTML array
Mauricio Pellegrini wrote: I have a HTML page with a form in which there are some inputs like these: input type=text name=xname value=3303 input type=text name=xname value=9854 input type=text name=xname value=n... That isn't an array, it is just a series of inputs with the same name. Most query string / post data processing libraries will present it as an array though (but in HTML its just data). How do I retrieve that array from within PHP ? PHP is ... odd. Unlike every other query string / post data library I've ever encountered, PHP will only present such data as an array if the name ends in the characters []. This has a minor advantage in that you can play with multidimensional arrays (I've never found it useful myself), but demands that you alter your input to suit its requirements. The other option is to bypass PHP's query string / post data parser and write your own (you can get access to the raw query string / post data). -- David Dorward http://blog.dorward.me.uk/ http://dorward.me.uk/ Home is where the ~/.bashrc is -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php