Re: [PHP] please help with regular expression in preg_replace
Many thanx to Jim and andy for their replies, with Jim`s changes its now working like in sed. Excuse me for my stupid question, but im old unix/linux system engineer coding with C , perl and bash, php gave me unpredictable results in this task. ;-) so, in final, may be this help some other roundcube users who need one universal site for many domain access. this is test page: ?php $host = host.1stdom.com ; //$host = host.2nddom.1stdom.com ; $pattern1 = '/[^.]*\./U' ; $pattern2 = '/^[^.]+\./' ; exec( echo $host | sed s/[^.]*\.//, $dom_sed ) ; $p1_1 = preg_replace( '/[^.]*\./U' , '', $host ) ; $p1_2 = preg_replace( $pattern1 , '', $host ) ; $p2_1 = preg_replace( '/^[^.]+\./' , '', $host ) ; $p2_2 = preg_replace( $pattern2 , '', $host ) ; echo $host br ; echo dom_sed = $dom_sed[0]br ; echo p1_1 = $p1_1 br ; echo p1_2 = $p1_2 br ; echo p2_1 = $p2_1 br ; echo p2_2 = $p2_2 br ; ? with result: host.1stdom.com dom_sed = 1stdom.com p1_1 = com p1_2 = com p2_1 = 1stdom.com p2_2 = 1stdom.com and this is line which i need in roundcube setup: $rcmail_config['username_domain'] = preg_replace( '/^[^.]+\./' , '', $_SERVER['HTTP_HOST'] ) ; many thanks again Rene - Original Message - From: Jim Lucas li...@cmsws.com To: Red r...@you.sk Cc: php-general@lists.php.net Sent: Friday, October 30, 2009 12:33 AM Subject: Re: [PHP] please help with regular expression in preg_replace Red wrote: hello, im not a php developer, i just need to rewrite one php file but having problem with understanding syntax of regexp in php. i need to get domain name from fqdn (for example from $_SERVER['HTTP_HOST'] ) in sed its working well with s/[^.]*\.// , but preg_replace behaves weird. http_host is for example hostname.domain.com ?php $host = $_SERVER['HTTP_HOST']; exec( echo $host | sed s/[^.]*\.//, $domain ) ; echo $domain[0] ? return domain.com, but ?php $host = $_SERVER['HTTP_HOST']; $domain = preg_replace( '/[^.]*\./' , '', $host) ; echo $domain; ? return only com i think when this php page get many hits, its not so wise to call sed everytime, i would like to ask someone for help how to write preg_replace pattern. thanx Rene I would add one thing and change another. ?php $host = $_SERVER['HTTP_HOST']; $domain = preg_replace( '/^[^.]+\./' , '', $host) ; echo $domain; ? Adding an additional '^' to the start tells it to start at the beginning. And changing '*' to a '+' Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] please help with regular expression in preg_replace
hello, im not a php developer, i just need to rewrite one php file but having problem with understanding syntax of regexp in php. i need to get domain name from fqdn (for example from $_SERVER['HTTP_HOST'] ) in sed its working well with s/[^.]*\.// , but preg_replace behaves weird. http_host is for example hostname.domain.com ?php $host = $_SERVER['HTTP_HOST']; exec( echo $host | sed s/[^.]*\.//, $domain ) ; echo $domain[0] ? return domain.com, but ?php $host = $_SERVER['HTTP_HOST']; $domain = preg_replace( '/[^.]*\./' , '', $host) ; echo $domain; ? return only com i think when this php page get many hits, its not so wise to call sed everytime, i would like to ask someone for help how to write preg_replace pattern. thanx Rene
[PHP] Re: Custom Open Tags
Hi Sven, i was in the need to allow ?php Tags within template-layers which caused me some problems at first as i ran into the situation you described. I was able to solve this problem quite well using this function: /** [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] */ function ParsePHP ( $content ) { preg_match_all(#\\?php(.*?)\?\#sim,$content,$source_parts); foreach($source_parts[1]AS$id=$php_source){ ob_start(); eval(ereg_replace(\\$([a-zA-Z_][a-zA-Z0-9_]*), \$GLOBALS[\\\1\] , $php_source ) ); $content=str_replace($source_parts[0][$id],ob_get_contents(), $content ); ob_end_clean(); } return$content; } Adding some minor changed would allow you to use custom opening and closing tags (in fact you would just replace the \?php with \?xyz and would be done. I'm using the regular expression to replace \\$([a-zA-Z_][a-zA-Z0-9_]*) with \$GLOBALS[\\\1\] to make sure all variables are found as we are within the function's scoope and not within the global one. Maybe this helps some ppl. -- red The only downside: No single quote (') is possible outside ?xyz ... ? tags in the file included. This can of course be fixed, but only with a ridiculous amount of code. If only there was a way to do heredoc strings that DON'T parse variables (like in Perl). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Display only one filed of the repeated records
Hi Ahmed, hope this helps: $ary = array() ; $sql = SELECT COUNT(*), category FROM movies GROUP BY category ; $res = mysql_query ( $sql ) ; while ( $line = mysql_fetch_assoc ( $res ) ) { $ary[] = $line[ 'category' ] ; } echo implode ( - , $ary ) ; -- red Ahmed Abdel-Aliem wrote: ID Title Cattegory 1Matrix Sci-Fi 2Spartacus History 3Alexander History 4whatever Horror i want to list the categories only like this Sci-Fi - History - Horror -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Globally accessible objects without using 'global $obj;'
Hi Chris, Something that worked out very well for me was using a function that would take care of the error handling ... kind of ?php define ( 'ERR_TYPE_ERROR' , 1 ) ; define ( 'ERR_TYPE_WARNING' , 2 ) ; class Error { // error handling code here } function _handleError ( $msg , $type ) { static $errClass ; if ( is_class ( $errClass ) === FALSE ) { $errClass = new Error(); } // hand $msg to $errClass here ... } function raiseError ( $msg ) { return _handleError ( $msg , ERR_TYPE_ERROR ) ; } function raiseWarning ( $msg ) { return _handleError ( $msg , ERR_TYPE_WARNING ) ; } ? But today i prefer using PHPs build-in Error-Handling functions using the 2 Errorlevels ( E_USER_NOTICE, E_USER_WARNING and E_USER_ERROR ) for my debugging and error-handling. But looking at PHP5's try-throw-catch constructs makes me think about rewritting large parts of my current project :-/ -- red Chris W. Parker wrote: Hello, Ok so I'm trying to write an error reporting class and I'm just sort of experimenting at this point (comments outside the scope of this email are welcome btw) with how to best implement it. One idea I had (which isn't working out as well as I'd hoped thus far) is to create an instance of my error class (incidentally called 'Error') at the start of each page and then reference that instance from within all other objects and functions. Maybe this would be best explained with some code: ?php $e = new Error(); function my_function() { // do stuff if($this == $that) { $e-RaiseError(); } } ? Of course, that doesn't work because my_function() doesn't know anything about $e unless I put a special statement into my_function(). ?php function my_function() { // here's the new line global $e; // do stuff ... } ? I already don't like the idea of having to put 'global $e;' within each and every function/method I write. Should I abandon this idea and try something else? If so, what? Here is my first idea just fyi. ?php function my_function() { $e = new Error(); // do stuff if($this == $that) { $e-RaiseError(); } else { // continue like normal } // get ready to return a response if($e-error_count 0) { return $e; } else { // return something else } } ? Now to use my_function() within a page I have to always assign the result to a variable so that I can determine whether or not any errors occured within the function. ?php $result = my_function(); if($result-error_count 0) { // an error occurred $result-DisplayErrors(); } ? But that also seems like a hassle (but maybe it's a completely necessary hassle?). I've looked around the internets for a while but have not found any REALLY useful documents on managing errors (could be that I've not found the write article yet) and such so any comments/pointers/links/etc. are very welcome. What I'd ultimately like to do is be able to return more than just a true/false from a function regarding it's end state. For example, a function could fail for multiple reasons and just returning a plain false for all situations does not suffice. Thank you for making it this far. Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP5 and pass by reference bug.
Maybe you recheck the dokumentation on what exactly referenzes are. Do you expect the function to alter the string something here and every- time you later print the string within your script you get the altered one? ONLY variables can be passed by referenze ! -- red Daevid Vincent wrote: So, I'm getting all these errors/warnings in PHP5 now saying that I have to put the on the function and not in the passing (which sorta makes sense and puts the burden on the function rather than the user, which I like too). So I spend the time to go and fix several thousand lines of code. Then I start to see these other errors... Maybe I'm missing something, but this seems like a glaring bug in passing by reference that nobody caught... say you have function foo($bar) { } well that works great as long as you use it like foo($x); but if you try foo(something here); Or foo( array('a','b','c') ); it shits the bed. :-( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP5 and pass by reference bug.
Maybe you recheck the dokumentation on what exactly referenzes are. Do you expect the function to alter the string something here and every- time you later print the string within your script you get the altered one? ONLY variables can be passed by referenze ! -- red Daevid Vincent wrote: So, I'm getting all these errors/warnings in PHP5 now saying that I have to put the on the function and not in the passing (which sorta makes sense and puts the burden on the function rather than the user, which I like too). So I spend the time to go and fix several thousand lines of code. Then I start to see these other errors... Maybe I'm missing something, but this seems like a glaring bug in passing by reference that nobody caught... say you have function foo($bar) { } well that works great as long as you use it like foo($x); but if you try foo(something here); Or foo( array('a','b','c') ); it shits the bed. :-( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: ereg question/prob...
$regs is an array not a string ! try print_r or var_dump to determine $regexp's content Tim Van Wassenhove wrote: In article [EMAIL PROTECTED], Bruce wrote: $file = .txt; ereg((\.)([a-z0-9]{3,5})$, $file, $regs); echo ww = .$regs. brbr; i'm trying to figure out how to get the portion of the regex that's the extension of the file. my understanding of the docs, says that the extension should be in the $reg array any ideas/comments on where my mistake is would be appreciated... Will it work with 123.123.txt ? If you have a look at the file functions in the manual, you'll find much better solutions like pathinfo(); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP5 release HTTP Authentication not working on FreeBSD.
known problem, will be fixed soon in 5.0.1 which should be released asap William Bailey wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Guys, I've just upgraded from 5.0 rc3 to 5.0 release on freeBSD (using the ports) and now find that HTTP Authentication dosent work. Here is the test script that i am using: ?php ~ error_reporting(E_ALL); ~ ini_set('display_errors', true); ~ if (! (isset($_SERVER['PHP_AUTH_USER']) || isset($_SERVER['PHP_AUTH_PW']) )) { ~ header('WWW-Authenticate: Basic realm=My Realm'); ~ header('HTTP/1.0 401 Unauthorized'); ~ echo 'Text to send if user hits Cancel button'; ~ exit; ~ } else { ~ echo pHello '{$_SERVER['PHP_AUTH_USER']}'./p; ~ echo pYou entered {$_SERVER['PHP_AUTH_PW']} as your password./p; ~ } ? And here is the output that i get: Notice: Undefined index: PHP_AUTH_USER in test.php on line 10 Hello ''. You entered pass as your password. As you can see PHP_AUTH_USER is on longer being set. Does anybody else have this issue or know of a fix? - -- Regards, William Bailey. Pro-Net Internet Services Ltd. http://www.pro-net.co.uk/ -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.1 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFA9o3ZzSfrYDJMXmERAmZqAKCunk+xl2w+RRIKOvbDTQEWjXbGCgCgxXsw DknafWhfiwLTYrusTzHl0gE= =IMNL -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Regular Expressions
Yep, but to avoid his problem with empty Strings he should use something like: /Last Name: *(.*?)\n/ outerwise \s* will match the first newline and continue to the end of the next line ! Tim Van Wassenhove wrote: In article [EMAIL PROTECTED], Arik Raffael Funke wrote: implement following pattern Last Name:\s*(.*)\n. I get just 'Jason'. But what I currently get is: Jason Street: abc This is behaviour because (.*) is greedy. As you noticed, it matched Jason \nStreet:abc /Last Name:\s+(.*?)\n/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Regular Expressions
Oh guess it would be even better and faster to only use: /Last Name:([^\n]*)/ and trim() the result :-) -- red Red Wingate wrote: Yep, but to avoid his problem with empty Strings he should use something like: /Last Name: *(.*?)\n/ outerwise \s* will match the first newline and continue to the end of the next line ! Tim Van Wassenhove wrote: In article [EMAIL PROTECTED], Arik Raffael Funke wrote: implement following pattern Last Name:\s*(.*)\n. I get just 'Jason'. But what I currently get is: Jason Street: abc This is behaviour because (.*) is greedy. As you noticed, it matched Jason \nStreet:abc /Last Name:\s+(.*?)\n/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to tell if the file is already locked with flock()???
http://de2.php.net/manual/en/function.is-writeable.php Jay Blanchard wrote: [snip] How do we tell if the file is already locked when someone use a flock() on the file?? [/snip] If your flock attempt returns FALSE then it is likely locked already -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Compile Php5: --with-mysql and --with-mysqli
[quote src=doc] If you would like to install the mysql extension along with the mysqli extension you have to use the same client library to avoid any conflicts. [/quote] Jacob Friis Larsen wrote: How do I install Php5 with both --with-mysql and --with-mysqli? MySQL is 4.1.3-beta and installed as official MySQL RPM. This didn't work: ./configure --with-mysql=/usr/include/mysql --enable-embedded-mysqli ./configure --with-mysql=/usr/include/mysql --with-mysql=/usr/bin/mysql_config ./configure --with-mysql=/usr/include/mysql --with-mysqli=/usr/bin/mysql_config The last gave me a lot of errors. Thanks, Jacob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: warning: function registration failed
Try a clean install of PHP5 otherwise head over to the interals list to make sure it won't be a showstopper for the Release sceduled for today. -- red Josh Close wrote: I installed php-5.0.0 and I get these error when doing php -v PHP Warning: Function registration failed - duplicate name - mssql_connect in Unknown on line 0 PHP Warning: Function registration failed - duplicate name - mssql_pconnect in Unknown on line 0 PHP Warning: Function registration failed - duplicate name - mssql_close in Unknown on line 0 PHP Warning: Function registration failed - duplicate name - mssql_select_db in Unknown on line 0 PHP Warning: Function registration failed - duplicate name - mssql_query in Unknown on line 0 PHP Warning: Function registration failed - duplicate name - mssql_free_result in Unknown on line 0 PHP Warning: Function registration failed - duplicate name - mssql_get_last_message in Unknown on line 0 PHP Warning: Function registration failed - duplicate name - mssql_num_rows in Unknown on line 0 PHP Warning: Function registration failed - duplicate name - mssql_num_fields in Unknown on line 0 PHP Warning: Function registration failed - duplicate name - mssql_fetch_field in Unknown on line 0 PHP Warning: Function registration failed - duplicate name - mssql_fetch_row in Unknown on line 0 PHP Warning: Function registration failed - duplicate name - mssql_fetch_array in Unknown on line 0 PHP Warning: Function registration failed - duplicate name - mssql_fetch_object in Unknown on line 0 PHP Warning: Function registration failed - duplicate name - mssql_data_seek in Unknown on line 0 PHP Warning: Function registration failed - duplicate name - mssql_field_seek in Unknown on line 0 PHP Warning: Function registration failed - duplicate name - mssql_result in Unknown on line 0 PHP Warning: Function registration failed - duplicate name - mssql_min_error_severity in Unknown on line 0 PHP Warning: Function registration failed - duplicate name - mssql_min_message_severity in Unknown on line 0 PHP Warning: mssql: Unable to register functions, unable to load in Unknown on line 0 I'm using gentoo linux. I downgraded back to php-4x and I'm still getting the errors. What's going on here? How do I fix this? Is it because gentoo now has both the mssql and freetds flags? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Saving variables in a session in a destructor
Maybe you check out the internals archives as an discussion about this topic was held 1-2 days ago. Hi all Using PHP5, I am trying to save some properties of an object when it is destroyed in its destructor, __destruct(). However, I have found that the session variable is NOT stored unless I explicitly destroy the object using unset(). If I leave php to finish executing the script and automatically destroy the object, the destructor IS called, however, the session variables are NOT saved. A quick code example for clarity: - class StateMachine { public $stateVariable; function __destruct() { $_SESSION['state'] = $this-stateVariable; } } $sm = new StateMachine(); if (isset($_SESSION['state'])) { $sm-stateVariable = $_SESSION['state']; } else { $sm-stateVariable = 'foobar'; } (please ignore the obvious bad coding standard of making that var public and accessing it, this is for simplicity of the example). Unless I do an unset($sm); at the end of a script like this, the $_SESSION array will never contain the state=foobar key/value. Can anyone offer some insight into this? Thanks! Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Regular expression
If you still like to gather the information without using any tools: $email = explode( \n , $mailText ); foreach ( $email AS $emailLine ) { $emailLine = trim( $emailLine ); if ( strtoupper ( substr( $emailLine , 0 , 4 ) ) == 'FROM' ) { preg_match( '#^from\s*:\s*([^]+)(([^]+))?#si' ,$emailLine ,$parts ); break ; } } $name = $parts[1] ; $email = $parts[3] ; But you should consider the following: FROM: Red Wingate [EMAIL PROTECTED] FROM: Red Wingate FROM: [EMAIL PROTECTED] . Which makes working like this a pita. -- red I suggest not using a regex. There are better tools for parsing an email, for example formail. $email = `formail -x Return-Path`; See google.com for more information Regards, Aidan Syed Ghouse [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi All will anyone give me a solution to get the name and email address of sender from the mail text below using regular expression. The result shud get name as syed ghouse and email as [EMAIL PROTECTED] --- Mail text start --- Return-Path: [EMAIL PROTECTED] Delivered-To: [EMAIL PROTECTED] Received: (qmail 25523 invoked by uid 508); 19 Jun 2004 06:23:25 - Received: from localhost (HELO 192.168.90.8) (127.0.0.1) by mail.jinis.com with SMTP; 19 Jun 2004 06:23:25 - Received: from 192.168.90.20 (proxying for 192.168.90.85) (SquirrelMail authenticated user [EMAIL PROTECTED]) by 192.168.90.8 with HTTP; Sat, 19 Jun 2004 11:53:25 +0530 (IST) Message-ID: [EMAIL PROTECTED] Date: Sat, 19 Jun 2004 11:53:25 +0530 (IST) Subject: test From : 'syed ghouse' [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED],[EMAIL PROTECTED] User-Agent: SquirrelMail/1.4.2 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 Importance: Normal test mail ignore --- Mail text end --- Regards Syed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Fw: [PHP] Re: Regular expression
First of all check who u credit :p Secondly why don't you just try to fix it yourself? There was just a typo in the regexp: - #^from\s*:\s*([^]+)(([^]+))?#si + #^from\s*:\s*([^]+)(([^]+))?#si Hopefully this will help you even more: ?php /** * @param string $runlevel * @return mixed */ function fetchSender ( $mailText ) { $mailText = explode( \n , $mailText ) ; foreach ( $mailText AS $mailLine ) { $mailLine = trim ( $mailLine ) ; if ( strtoupper ( substr ( $mailLine , 0 , 4 ) ) == 'FROM' ) { preg_match ( '#^\s*FROM\s*:\s*(([^]+)(\([^]+)\)?)#si' , $mailLine , $parts ); break ; } } if ( is_array ( $parts ) === FALSE ) { return FALSE ; } else { return array ( 'name' = isset ( $parts[2] ) ? $parts[2] : 'unknown' , 'from' = isset ( $parts[1] ) ? $parts[1] : 'unknown' , 'mail' = isset ( $parts[4] ) ? $parts[4] : 'unknown' ) ; } } /** * @param array $strings * @return void */ function debug_FetchSender ( $strings ) { echo 'pre'; foreach ( $strings AS $string ) { $sender = fetchSender ( $string ); $sender = array_map ( 'htmlspecialchars' , $sender ) ; print_r ( $sender ); } echo '/pre'; } debug_FetchSender ( array ( 'FROM: Red Wingate [EMAIL PROTECTED]' , 'FROM: Red Wingate' , 'FROM: [EMAIL PROTECTED]' ) ) ; ? [...] Thanks Aiden for ur help i used ur code and i got name as Red Wingate[EMAIL PROTECTED] and no email. So pls correct the code and send me such that i get name and email separately. Regards syed [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Fw: [PHP] Re: Regular expression
Oh ... you forgot to include your account-info so i won't be able to send you the money :-/ [...] You're too nice.. Btw, I need some money. Send me money ASAP. It must be an amount greater than $200, and be delivered to me directly, thank you. [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Protecting database passwords
Hashing ... but i guess he wants to protected the password needed to access the DB not a PW stored in the DB. [...] MD5 - http://ie2.php.net/md5 One way in encryption. [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Protecting database passwords
even for the guy who wrote the source. it's allmost impossible to restore the data as the only option is a brute-force attempt. Chris W. Parker wrote: Red Wingate mailto:[EMAIL PROTECTED] on Wednesday, June 30, 2004 9:33 AM said: Hashing ... but i guess he wants to protected the password needed to access the DB not a PW stored in the DB. you probably understand this already but for those who don't i would like to say: right, but the point with hashing is that even if the hashes are retrieved/stolen it will take time (possibly too long) for the password itself to be recovered/discovered. chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to escape apostrophe in HTML textbox exactly???
use quot; to display the data in the input-text element and undo this before inserting it into the database function quoteToHtml ( $string ) { return str_replace( '' , 'quot;' , $string ); } function htmlToQuote ( $string ) { return str_replace( 'quot;' , '' , $string ); } Only way to go :-) Scott Fletcher wrote: I'm using data that goes from the HTML textbox to PHP to MYSQL to PHP to HTML textbox. The only trouble I have is to escape the apostrophe character when it is put into the HTML textbox by PHP (from MySQL). --snip-- echo input type='textbox' value='.$value.'; --snip-- I can't use the HTML feature like quot or something because the quot would show up in the database... Any suggestion or advice? Thanks, Scott F. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Earliest PHP/FI
maybe take a look here : http://museum.php.net/ otherwise do some research using google. Jeff Loiselle wrote: Does anyone know where I would be able to find the earliest version of PHP/FI or PHP possible? I am looking for the earliest possible version for academic reasons. Thanks in advace. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Converting strings to match multiple charsets
Hey guys, i ran into serious trouble when facing the problem to convert data, which was retrieved from a single form in our CMS to match the requirements of multiple charsets. Our CMS uses UTF-8 which worked out quite fine to display the data but caused weired symbols when displayed within a TEXTAREA or INPUT field. So i tried to convert all characters beyound A-Z,0-9 to HTML entities which worked out even better ( i used the following functions to convert the data : function func_ConvertToHTML ( $string ) { $strlen = strlen ( $string ) ; $return = '' ; for ( $str_pos = 0 ; $str_pos $strlen ; $str_pos++ ) { $char = substr ( $string , $str_pos , 1 ); $ascii = ord ( $char ); if ( $ascii 5 == 6 ) { $char2 = substr ( $string , ++$str_pos , 1 ); $ascii2 = ord ($char2); $ascii = 31 ; $ascii2 = 63 ; $ascii2 |= ( ($ascii 3 ) 6 ) ; $ascii = 2 ; $return .= '#x' . str_pad ( dechex( $ascii ) , 2 , '0' , STR_PAD_LEFT ) . str_pad ( dechex( $ascii2 ) , 2 , '0' , STR_PAD_LEFT ) . ';' ; } else { $return .= $char; } } return $return; } But at this point i faced even bigger problems when using this kind of data on JavaScripts or sending the data in an text/plain E-Mail. I tryed to convert the data back but failed as chr() only supports a Charset of 255 Characters ( which most languages don't match eg ru, pl, ch, jp ... ) So my question is if anyone on this list has an idea on how to retrieve the data completely? Some kind of func_ConvertFromHTML() function. -- red -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Converting strings to match multiple charsets
[...] Can't you use utf8_decode() to display the utf8 encoded data? [...] The displayed data worked out fine for some languages but others didn't and even simple german chars like äöü won't show up correctly within a textarea. [...] Is this what you're looking for?: http://de2.php.net/manual/en/function.html-entity-decode.php [...] [quote](PHP 4 = 4.3.0, PHP 5)[/quote] This won't work on most servers we're hosting our CMS on :-/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to escape apostrophe in HTML textbox exactly???
[...] Bummer, mysql_escape_string() is available only in PHP 5 and up. I'm using PHP 4.3.1 [...] *mo* - wrong [quote] mysql_escape_string (PHP 4 = 4.0.3, PHP 5) [/quote] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with embeded objects and reference
Not sure over here, but isn't it $main-setChild($child1); Vincent Dupont wrote: Hi, could anyone help on this 'by reference' problem. I have 2 classes. The main class as a child class. The child class has properties (array) I would like to be able to manipulate the child's properties even after the child has been inserted into the main class. Does this make sense? I can do it with by getting a reference of the child class, then setting the property,like : $tmp = $main-getChild(); //get a reference to the child object $tmp-setProperty(forth);//ok OR $main-setChildProperty(third); //ok but Whyt can't I do it directly by calling a reference to the child, like in : $child1-setproperty(second); //The property is not set or not displayed I know I need a reference to the child class that is within the maoin class, but HOW?? Here is a complete example ?php class class1{ var $child; //array function class1(){ $this-properties = array(); } //set the child object (class2) function setChild($child){ $this-child=$child; } //get the child object (class2), and call its setProperty method function setChildProperty($prop){ $theChild = $this-child; $theChild-setProperty($prop); } //return a reference to the child object function getChild(){ return $this-child; } //print the child object properties function display(){ $this-child-toString(); } } class class2{ var $properties; //array function class2(){ $this-properties = array(); } function setProperty($new_property){ $this-properties[] = $new_property; } function getProperty($index){ return $this-properties[$index]; } function toString(){ print_r($this-properties); } } $main = new class1(); $child1 = new class2(); $child1-setproperty(first);//displayed $main-setChild($child1); $child1-setproperty(second); //NOT DISPLAYED $main-setChildProperty(third); //displayed $tmp = $main-getChild(); //get a reference to the child object $tmp-setProperty(forth);//displayed $main-display(); //output : Array ( [0] = first [1] = third [2] = forth ) ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with embeded objects and reference
Lill example: [...] $child1-setproperty(first);//displayed $main-setChild($child1); $child1-setproperty(second); //NOT DISPLAYED [...] $child1 is passed to $main with property 'first'. Later on you update $child1, but not $main-child, as they are not the same objects ( equal but not same ). So i guess you need to -$main-setChild($child1); +$main-setChild($child1); and -$this-child = $child; +$this-child = $child; // MUST !!! Now i see, $this-child = $child; copys the object instead of creating a ref. -- red Red Wingate wrote: Not sure over here, but isn't it $main-setChild($child1); Vincent Dupont wrote: Hi, could anyone help on this 'by reference' problem. I have 2 classes. The main class as a child class. The child class has properties (array) I would like to be able to manipulate the child's properties even after the child has been inserted into the main class. Does this make sense? I can do it with by getting a reference of the child class, then setting the property,like : $tmp = $main-getChild(); //get a reference to the child object $tmp-setProperty(forth);//ok OR $main-setChildProperty(third); //ok but Whyt can't I do it directly by calling a reference to the child, like in : $child1-setproperty(second); //The property is not set or not displayed I know I need a reference to the child class that is within the maoin class, but HOW?? Here is a complete example ?php class class1{ var $child; //array function class1(){ $this-properties = array(); } //set the child object (class2) function setChild($child){ $this-child=$child; } //get the child object (class2), and call its setProperty method function setChildProperty($prop){ $theChild = $this-child; $theChild-setProperty($prop); } //return a reference to the child object function getChild(){ return $this-child; } //print the child object properties function display(){ $this-child-toString(); } } class class2{ var $properties; //array function class2(){ $this-properties = array(); } function setProperty($new_property){ $this-properties[] = $new_property; } function getProperty($index){ return $this-properties[$index]; } function toString(){ print_r($this-properties); } } $main = new class1(); $child1 = new class2(); $child1-setproperty(first);//displayed $main-setChild($child1); $child1-setproperty(second); //NOT DISPLAYED $main-setChildProperty(third); //displayed $tmp = $main-getChild(); //get a reference to the child object $tmp-setProperty(forth);//displayed $main-display(); //output : Array ( [0] = first [1] = third [2] = forth ) ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with embeded objects and reference
so, why don't you reply correctly? :p Chris W. Parker wrote: Vincent DUPONT mailto:[EMAIL PROTECTED] on Wednesday, June 30, 2004 1:05 PM said: Hi, hi. could anyone help on this 'by reference' problem. when starting a new thread please do not just reply to an ongoing thread and change the subject. please start a new email. your fellow list members thank you. chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with embeded objects and reference
better don't blame the other pal :-) http://screens.erisx.de/reply.gif -- red Red Wingate wrote: so, why don't you reply correctly? :p Chris W. Parker wrote: Vincent DUPONT mailto:[EMAIL PROTECTED] on Wednesday, June 30, 2004 1:05 PM said: Hi, hi. could anyone help on this 'by reference' problem. when starting a new thread please do not just reply to an ongoing thread and change the subject. please start a new email. your fellow list members thank you. chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Converting strings to match multiple charsets
[] Hi Red, I'm actually working on a project as well at the moment that uses utf8 data in MySQL. All chars should be OK when output with utf8_decode(). Do the chars only look wrong within textarea or also outside of form elements? [] Actually everything ( expect one language ... i guess it was pl ) was displayed fine using utf8_decode but everything within an textarea or our RTE was displayed completly wrong ... either those 1/4... symbols or the good ol '' ... not sure in which kind formated the data was returned :-) -- red -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Converting strings to match multiple charsets
yep, as i said it was displayed correctly everywhere expect in the forms oh i might mention - Mozilla worked well but IE destroyed the data (only in textareas) Torsten Roehr wrote: Red Wingate [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [] Hi Red, I'm actually working on a project as well at the moment that uses utf8 data in MySQL. All chars should be OK when output with utf8_decode(). Do the chars only look wrong within textarea or also outside of form elements? [] Actually everything ( expect one language ... i guess it was pl ) was displayed fine using utf8_decode but everything within an textarea or our RTE was displayed completly wrong ... either those 1/4... symbols or the good ol '' ... not sure in which kind formated the data was returned :-) Does the data look correct in the database? Have you tried browsing the table with phpMyAdmin? Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Messages to List Being Truncated
the first one was truncated but the second one was complete. Btw thx Chris for opening up yet another thread that could have been avoided if your client was configured correctly. -- red Chris W. Parker wrote: Pablo Gosse mailto:[EMAIL PROTECTED] on Wednesday, June 30, 2004 2:29 PM said: Hi folks. I've just attempted to twice post a message, and for some reason it's being truncated somewhere between my Sent Items folder and when it appears on the list. Has anyone had similar problems. Anyone have any idea what could be causing it? this email appeared to be complete. is it always truncated at the same spot (or what appears to be the same spot)? chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Messages to List Being Truncated
Usually it should be \\\ to get a \ ... now lets take a look at your regexp /^[a-zA-Z0-9\(\)]{1}[ a-zA-Z0-9\(\)_\,\.\-\'\]{1,999}$/ ^[a-zA-Z0-9()] should work, as ( and ) only needs to be escaped when not within an []-block (cannot recall the name right now) [- a-zA-Z0-9(),.'_]{1,999}$ should be correct here, i am not sure about the . and ,. '\ should be replaced by \' if you use single quotes to build the pattern. Full regexp would be: #^[a-zA-Z0-9()][- a-zA-Z0-9(),.'_]{1,999}$# or even easier: #^[a-z0-9()][- a-z0-9(),.'_]{1,999}$#i I replaced the delimiter / with # as you don't use it within the regexp and using / makes escaping the / even worse ( guess it's 7 / then ) Hope this helps you :-) -- red Pablo Gosse wrote: snip the first one was truncated but the second one was complete. Btw thx Chris for opening up yet another thread that could have been avoided if your client was configured correctly. /snip This is strange. At any rate, I've put the message in an html page on our server. http://www.unbc.ca/regexp.html If anyone could take a look and give me a hint as to what the problem might be I would greatly appreciate it. Cheers and TIA. Pablo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Messages to List Being Truncated
Buddy, nobody ( and especialy not me ) would have offended you, if you wouldn't have flamed someone for creating a new thread by replying to another. Your E-Mail client breaks the Threads just like he did which makes reading the threads a pita. It was stated more then once that replying useing any version of Outlook causes troubles as they won't accept the MID ( or refs ) of other client software on the first reply ( as every other client adds the one set by outlook atleast every message following your initial message will follow the thread correctly ( maybe take a look at the header information ) I would recommend you to either use some kind of Newsgroup software or just try another e-mail client ( eg thunderbird ) -- red ps: stay calm :-) [...] oh woe is me! if only i hadn't offended thee, red, you wouldn't have sent such a hurtful email. from the depths of my soul, and the bottom of my heart, a thousand pardons to you and your kin. may they forever be blessed with configured correctly email clients. oh how i long for the day when i can stir up no trouble, and cause no pain. of all the people i could have been why was i me? oh how i rue the day i was born! argh i say. [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] safe mode/open basedir not working ?
Thats just what he said :p Robert Mena wrote: Marek, but the program was executed using a system call from a php script. - rt On Wed, 30 Jun 2004 23:50:02 +0200, Marek Kilimajer [EMAIL PROTECTED] wrote: robert mena wrote --- napísal:: Hi, I host a few virtual domains in apache 2 and use php. The virtual domain is something like VirtualHost a.b.c.d:80 ServerAdmin [EMAIL PROTECTED] DocumentRoot /home/httpd/html/domain.com ServerName www.domain.com ErrorLog logs/domain.com-error_log CustomLog logs/domain.com-access_log combined ScriptAlias /cgi-bin/ /home/httpd/cgi-bin/ Directory /home/httpd/html/domain.com/ AllowOverride AuthConfig Limit php_admin_value doc_root /home/httpd/html/domain.com/ php_admin_flag safe_mode on php_admin_value open_basedir /home/httpd/html/domain.com:/tmp/ /Directory /VirtualHost Recently I had a minor problem with a user that uploaded via ftp a php script in his domain and this domain used exec/system etc to call perl, read files. Shouldn't the settings above retrict such thing ? no, this setting affects only php, not programs executed from php -- 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] Session file in /tmp
i guess what u are looking for is session_destroy(); Binay wrote: If i m getting ur problem correctly then u want to restrict the same user logging from different machines concurrently. If tht being the case the snippet u mentioned below alone won't solve the problem . you have maintain a flag in the database which will be on when the user logs in and off when he/she logs out. Code: session_cache_expire(0); session_cache_limiter('private'); session_start(); I use this at the beginning of my script that processes data objects for my users. The users use multiple machines and login to the web site. This prevents the cached information from one user popping up when another user logs in. Will this contribute to the solution for my main problem: When a user exits a window without logging out they have to wait until the cookie expires or the session file in /tmp is deleted before they can get back in. This is the code that executes at login: session_cache_expire(0); session_cache_limiter('private'); setcookie(cookie,,0,/,iffinet.com,1); session_start(); I was hoping this would cause the session file in /tmp to be deleted but it doesn¹t work. I also tried unset($_SESSION[Oid¹]) this doesn¹t work either. Anyone have any ideas as to how I can resolve this? Thanks for your help! /Tim -- 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] Question about executing PHP script
Yep :-) [...] can I do a #!/usr/bin/php -q at the begining of the text file? [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP, Classes, Sharing Code
Look correct from my point of view... class Portfolio { var $portfolioID ; var $albums = array () ; function Portfolio ( $newID ) { $this-portfolioID = $newID ; } function addAlbum ( $album ) { $this-albums[] = $album ; } function getAlbum () { return current ( $this-album ) ; } } some knowlege on the iterator pattern is required though But you could even use a stack ( which i prefer ) class main { var $stack = NULL ; function create ( $ID ) { $this-stack = new stack ( $ID , $this-stack ); } function remove ( $ID ) { $this-stack = $this-stack-remove(); } function getID () { return $this-stack-getID(); } } class stack { var $ID ; var $prev = NULL ; function stack ( $ID , $prev ) { $this-ID = $ID ; $this-prev = $prev ; } function getID () { return $this-ID ; } function remove () { return $this-prev ; } } $foo = new main(); $foo-create( 100 ); $foo-create( 200 ); echo $foo-getID();// 200 $foo-remove(); $foo-create( 300 ); echo $foo-getID();// 300 $foo-remove(); echo $foo-getID();// 100 $foo-remove(); unset ( $foo ); [...] from what you wrote it seems that only the type of display is similar in both classes. I don't think this is enough to extend them from the same base class because the class properties and update/insert/load methods will be different in each. You have more of a 'is part of' relationship here. So I'd suggest something like this (simplified): class Portfolio { var $portfolioID; var $albums = array(); } class Album { var $albumID; var $portfolioID; var $photos = array(); } class Photo { var $photoID; var $albumID; var $name; } [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Works in Mozilla, not in IE
I wish there wouldn't be so many ppl using IE anyway :) Matthew Sims wrote: * Thus wrote Robert Sossomon: That just put me right back at the beginning, IE trying to DL the PHP page... put your disposition back to attachment and send the vnd.ms-excel content type. Also, on how the behaviour IE will treat any header is unpredictable in an unctontrolled environment, so don't be alarmed if you have someone else claiming that it isn't working for them :) Read as: IE sucks. I have php 4.2.2 installed at this moment as well... php really hasn't anything to do with how the browser will handle the filedownload. You're at the mercy of the intellegence of the browser :/ Read as: IE is stupid. ;) --Matthew Sims --http://killermookie.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Image support
RTFM Gus wrote: I have PHP 4.3.6 I want to add image support to manipulate JPEGs. I downloaded http://www.boutell.com/gd but what I do next? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Problem
Read: The best database to store images in is the Filesystem because thats what it's for :-) Raditha Dissanayake wrote: Monil Chheda wrote: Hi, I store images in DB properly... no issues using the Storing an image directly in the database certainly isnt' the proper way of doing it :-) The common practice is just to store the path to the image name in the database. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can I detect size of files which are too large to upload?
Right, guess i saw some kind of JS that determined the size of the selected file and wrote it into an hidden field. Maybe you try it that way. -- red Marek Kilimajer wrote: Pablo Gosse wrote --- napísal:: Marek Kilimajer wrote: Pablo Gosse wrote --- napísal:: Hi folks. I'm just tweaking the file manager portion of my CMS, and am wondering if there is any way I can identify the size of an uploaded file which exceeded the upload_max_filesize? I'd like to be able to tell the user the size of the file they tried to upload, in addition to telling them the allowable maximum size. It would seem logical to me that I would not be able to do this, since if the file exceeds the limit set by upload_max_filesize then the upload should not continue past that point. Is this an accurate assumption? Cheers and TIA. Pablo Content-Length request header, approximately, it also contains other post fields. H, thanks Marek. That might work, though I'm not entirely sure. The form through which users upload files can upload five at a time, so I'm assuming that the content-length request header would contain the sum total of all uploaded files, and I don't really see how I could get the individual sizes. Thoughts? Cheers and TIA. Pablo Then you are lost. If you want it really bad, you can turn on always_populate_raw_post_data and parse the post stream, but post_max_size will still limit you anyway. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: OT?? - calling frames within frames
Allright, even if it's OT Many ways to handle it, first would be to add a function within the frameset which handles redirects to the frames: script language=javascript function handleFrameRedirect ( frame , url ) { document.frames[ frame ].document.location.href = url ; } /script Within the frame you use script language=javascript parent.handleFrameRedirect( framename , url ); /script Another way is calling this directly within the frame: script language=javascript parent.document.frames[ framename ].document.location.href = url ; /script -- red Robert Sossomon wrote: I have two frames (A and main) When I pull up one page it reloads main with the full page, however what I need the system to do when I click off that page is to jump to main.html and load item.html in the top. Main.html currently loads 2 other pages at the beginning. I have tried to jump them in this order, but it does not seem to be working: //Call the main page echo 'script language=javascriptparent.main.location.href =main.html;/script'; //Open the next two pages I need in them echo 'script language=javascriptparent.B.location.href =item.html;/script'; echo 'script language=javascriptparent.C.location.href =cart.html;/script'; TIA! Robert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Unit Testing
Used all but 'Generic PHP Framework' and everything was quite fine and worked out just as i expected. But i was still missing some features which made me build my own small library to fit into my Framework. -- red Rick Fletcher wrote: Has anyone done any PHP unit testing? I've been looking around for a unit testing library to try out. Below are the ones I've found so far: SimpleTest: http://www.lastcraft.com/simple_test.php PHPUnit (dead?): http://phpunit.sourceforge.net/ Pear PHPUnit: http://pear.php.net/package/PHPUnit Generic PHP Framework (dead?): http://gpfr.sourceforge.net/ SimpleTest looks the most complete and the most active, so that's where I'm leaning. Anyone have any experience with any of these libraries, or have any comments on PHP Unit testing in general? Thanks. Rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Unit Testing
Allmost forgot about this one: http://www.phppatterns.com/index.php/article/articleview/33/1/2/ very well written ( phpPatterns() ) covers some other nice topics as well, allways worth a read. -- red Red Wingate wrote: Used all but 'Generic PHP Framework' and everything was quite fine and worked out just as i expected. But i was still missing some features which made me build my own small library to fit into my Framework. -- red Rick Fletcher wrote: Has anyone done any PHP unit testing? I've been looking around for a unit testing library to try out. Below are the ones I've found so far: SimpleTest: http://www.lastcraft.com/simple_test.php PHPUnit (dead?): http://phpunit.sourceforge.net/ Pear PHPUnit: http://pear.php.net/package/PHPUnit Generic PHP Framework (dead?): http://gpfr.sourceforge.net/ SimpleTest looks the most complete and the most active, so that's where I'm leaning. Anyone have any experience with any of these libraries, or have any comments on PHP Unit testing in general? Thanks. Rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: MySQL equivalent for odbc_result_all()???????
Some old piece of source i found in my libs: function sql_dump_result ( $result ) { $line = ''; $head = ''; while ( $temp = mysql_fetch_assoc( $result ) ){ if ( empty ( $head ) ) { $keys = array_keys($temp); $head = 'trtdb'.implode('/b/tdtdb',$keys).'/b/td/tr'; } $line .= 'trtd'.implode('/tdtd',$temp).'/td/tr'; } return 'table border=0'.$head.$line.'/table'; } maybe this helps :-) Scott Fletcher wrote: I noticed there is no MySQL equivalent for odbc_result_all(), so it meant I had to make a user-defined function from scratch. That part, I haven't been able to do very well. Does anyone have a good code or whip up one that would work. Thanks... FletchSOD -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Expedia.com
Allmost, after having a quick look at the source i tell you they do it like that: div id=loading style=display:block ... loading stuff here ... /div page loading here done? JS: document.getElementByid('loading').display='none'; take a look for yourself :-) James Harrell wrote: Hi Rene, Here's a thought- make your animated gif that's a grow-bar that fills from left to right. Maybe it maxes out at 99% or loops back around to 0 after reaching 100. :) Display this at the top of the screen - but not within a table that is part of the results display. More on why shortly. Send about 256 characters of HTML (including the IMG SRC link to your gif), then issue a flush(). At this point begin your long-running query, displaying output as it becomes avialable. Once the output is complete, issue a javascript that changes the gif to a different one that's not animated (ex: 100%). A few things to keep in mind: - Some IE browsers won't display anything until 255 chars have been output- hence the 256 number above. - Some NS browsers won't display a portion of a table until the entire table including closing tag has been written. Hence, don't put your grow-bar inside a table unless it's completed before issuing the long-running query. Hope this helps, james -Original Message- From: Ren Fournier [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 09, 2004 3:35 PM To: php Subject: [PHP] Expedia.com When Expedia.com is searching for flights, it displays a page with a little animated GIF progress bar, then display the results. How do they do that? How does the page sit idle until the query is finished, and then sends a new page with the results? I was thinking that they might use HTTP-REFRESH or something, and just keep hitting the database until the result is there. But is there a best way to do this? In my application, when the user clicks a certain button, it will take 10-20 seconds for the operation to completeduring that time I need the web browser to waiit for the data. I looked around for an article on this, but I'm not sure how to characterize this operation. ...Rene -- 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: file knowing its own directory
the magic constant __FILE__ will give you the absolut filesystem location of the file it is called. Eg: /home/www/tests/foo.php - ?php echo __FILE__ ; ? will print: '/home/www/tests/foo.php'; to retrieve the path only you could do: /home/www/tests/foo.php - ?php echo str_replace( basename ( __FILE__ ) , '' , __FILE__ ); ? will print: '/home/www/tests/'; hope this helps :-) Dennis Gearon wrote: please CC me 'cause I am on digest the scenario: three files: .htaccess has line saying php_prepend 'true_filesystem_location_php_prepend_file' prepend.php (aforementioned prepend file) has line saying include file_a.php file_a.php has line saying$my_true_file_system_location = I_NEED_A_FUNCTION_HERE; So, what do I replace I_NEED_A_FUNCTION_HERE with? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multiple substring replacement
In this special case you would even use 'file' to read the content of the file into an array and use 'implode' to replace every \n with br $content = implode( br , file ( './my_file.txt' ) ); -- red Brent Baisley wrote: Normally, I would say str_replace(), but for converting \n to br, use the nl2br() function. On May 24, 2004, at 4:28 PM, GodFoca wrote: What's the best way of replacing every ocurrence of a substring in a LARGE string by another (longer) substring? Specifically, I have read the contents of a file into a tring with fread, and now I want to replace all \n with br Thanks in advance Nicolas Sanguinetti -- 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: Select from 24 tables
First, this is a MySQL Question, next time you better send your request to a list which covers your type of question. use tablename.fieldname in your WHERE clause if you have fields with the same name. -- red Dave Carrera wrote: Hi List, How do I select data from 24 table in my database. Each one is identical in structure layout being Id,name,list I want to select where like $_POST[var] from a form all of the tables but I am having trouble :( I thought making a var string like $string = table1,table2,table3,.; And doing (select * from $string where list like \%$_POST[var]%\); Would work but I get a MySql error which say Column: 'list' in where clause is ambiguous I am stumped so I ask the list for help or advise please. Any advise is very much appreciated and I thank you in advance for any help or pointers. Thank you Dave C --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.672 / Virus Database: 434 - Release Date: 28/04/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Sorting text with multibyte characters
Run into this before, PHP seams to do quite well when you set the locale right ( de_DE ) which will place AÄBCD instead of ABCDÄÖÜ. Hope this helps :-) -- red Michal Migurski wrote: Hi, Does anyone have any thoughts on how to effectively sort text with multi byte characters? I am working on a project that uses lots of German text, and the letters with umlauts don't sort correctly. I'm using the mb_* functions in a few places (to adapt an ASCII-encoded database to XML output for flash, which is always expected to be in UTF-8), but none of them seems to be made for string comparison. thanks, -mike. - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: $_SERVER['SERVER_NAME'] in read-only.
AFAIK the content of the superglobal variables cannot be changed ( even though i haven't found this in the docs i can remeber got beaten by PHP for doing so :-) ) Back to the problem ( if existent ): If you don't do stuff like '$_SERVER['SERVER_NAME'] = ;' inside your script you won't run into trouble - I know some ppl like to use such strange work-arounds ;-) Otherwise using define ( 'SERVER_NAME' , $_SERVER['SERVER_NAME'] ); right at startup will usually solve your problem ( as workarounds will most likely kill other scripts if the SERVER_NAME is diffrent :-)) -- red [...] Hello, I am using the variable $_SERVER['SERVER_NAME'] inside a function, for example: function check_servname() { global $server ; if($_SERVER['SERVER_NAME'] != $server) { echo NOT OK, NOT GOOD SERVER NAME ; exit ; } } But we can modify the value of $_SERVER['SERVER_NAME'] before calling the function check_servname(). And I am looking for a the right server name not for a server name which may have been changed before calling check_servername: $_SERVER['SERVER_NAME'] = www.google.com ; //before calling check_servname and $_SERVER['SERVER_NAME'] will be www.google.com inside the function even the server name is not www.google.com. Is there any way to get the server name with a variable which would be read-only ? Thanks, Vincent. Agreed - constants are the way to do this. I wanted to mention that the $_SERVER variables are meant to hold values generated by your server. Of course if you really ARE google then I'm going to feel stupid for even mentioning this :) http://www.php.net/reserved.variables [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: global vars inside includes inside functions?
Again ain't no problem anyway foreach ( $GLOBALS AS $k = $v ) { $$k = $GLOBALS[$k] ; } zap you are done ... again when using a function to include a file with relying on depts within the file you would most probably use a registry-pattern or similar to access the required variables. -- red That makes local copies only, still no access to the global variable The other thing to consider is that everything dies at the conclusion of the function. It may be better to do this via a class construct -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: global vars inside includes inside functions?
Pattern are always done using OOP, but phppatterns that is one of the best sources on this topic i could think of :-) -- red [] Red, can you provide any more info or resources on a registry-pattern? I've found this: http://www.phppatterns.com/index.php/article/articleview/75/1/1/ , but I'm not really looking to get into OOP just yet :) [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OR
BEEP wrong :) http://www.php.net/manual/en/language.operators.php#language.operators.precedence therefore: $a AND $b OR $c AND $d is not equal $a AND $b || $c AND $d but is equal to $a $b || $c $d -- red Evan Nemerson wrote: On Sunday 25 April 2004 12:14 am, Aidan Lister wrote: if (cond || cond2) OR if (cond OR cond2) What do you use, and why? Doesn't matter- personal preference. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to do type/existence checking in PHP5
Hi, this is a plain design fault on your side: ?php $a = 'this is not an array'; if( is_array( $a['foo'] ) ) print '1'; [...] ? allright, just set $a to be a string, thats allright, now you check wether an string-offset ( foo ) is an array or not which causes an FATAL ERROR on PHP5. Now if you wrote some clean code you would have done: ?php $a = 'this is not an array'; if ( is_array ( $a ) ) { if ( is_array ( $a['foo'] ) ) { print '1' ; } } else { print 'nope'; } ? Now this makes sense as you first of all would make sure if $a is an array and not start with the first index ( which doesn't exist as $a is not even an array ) -- red PS: PHP5 says: Fatal error: Cannot use string offset as an array in /www/htdocs test_offset.php on line 6 [...] Hi In PHP5 the behaviour of illegal string offsets has changed. This is documented in the 'thin changes' file. This gives a problem in checking for existence / types of values, directly into a deeper level of a multidimensional array. I reported this as a bug[1] because I find the behaviour unfortunate, and furthermore it's inconsistent. This was refused, with a note 'So don't do it'. I think it's a really bad idea not to check the existence/types of values, before using them, so how should this be done properly in PHP5, without risking fatal errors in the case of a non-existent array? This is a problem in migrating applications from PHP4 because the error will not appear unless the value deosn't exist, which is exactly why you do the check. [1] http://bugs.php.net/bug.php?id=28107 [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: SQL Hell
Guess some guys don't get the point of this posting or have no idea what foreign keys are about. This problem can easily be solved using JOINs -- red Lester Caine wrote: Jason Barnett wrote: So far I've made multiple statements pulling out all the data and using PHP to formulate the information. But I know there is a better way using mysql. Only thing is I haven't got the faintest idea how to do it in one query and keep overheads low. I start to get lost when I'm doing select statements within select statements. I'm no DB guru, but as I understand it what you want to do requires the use of foreign keys. InnoDB tables implement them, but I don't think they currently grab the related information when you do SELECT statements. It sounds like you are emulating that right now with your SQL statements, and I don't think that any of the 4.x versions of MySQL will fully support foreign keys. I did find something interesting, though: apparently MySQL is going to support *stored_procedures* and *foreign_keys* in the 5.0-5.1 branch. I may have to go play with some of the 5.0 alpha stuff soon... Alternatively, use a better database :) Firebird has had Triggers and Stored Procedures from the start. Using these with PHP gives the power needed to update cross references without having to build complex PHP code. http://www.firebirdsql.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] FW: Resizing Pictures
Maybe you should take a look at PHPs Image functions, finding out which function matches your needs is not that hard :-) If you don't find the right functions you can also take a look at this list's archives as this topic was raised around 5 times 04/04 :-p -- red [...] Hi Warren, Thanks for the reply; however, that wasn't the answer I was searching for. Using PHP, I would like to resize a file once it's store in a directory on a (my) webserver. Anyone know? [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Flatten/Unflatten arrays
Orangehairedboy wrote: Hi, check out http://php.net/serialize and http://php.net/unserialize . hope this helps :-) -- red [...] Hi all, In Perl there is a way to flatten an array into a string, and a matching function to unflatten the array. This is different from explode/implode because the function supports multidimentional arrays as well. The purpose is to be able to write an array to a flatfile, and when necessary, read it in and it's in it's original form ready to use. Are there PHP functions which do the same thing? If not, has anyone ever written functions to do this? [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Program that'll parse HTML form with results and send HTML email?
Nice one here, got some class for this type of handling as well but it will also do some nice magic when it comes to checking for valid data or displaying the input again for validation :-) My way to go: 1. Display the form 2. Check all required fields (name start with req_) 2.1 ( ok ) Parse page and display input instead of fields 2.2 ( fail ) Parse page and display form again with values inserted 3. Send the E-Mail [...] Here is a class I use with my template system but it is easy to modify it. [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unwanted e-mails
Is php.net bounceing your posts or does your ISP bounce your e-mails? maybe you could send us a copy to have a look? -- red Lester Caine wrote: Chris W. Parker wrote: but your messages *ARE* getting accepted otherwise i would not be reading this email right now! NO THEY ARE NOT - This reply HAS to be sent via the newsgroup! The bounce messages I am getting are as a result of .php.net NOT accepting my perfectly valid posts! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: show_source or highlight_string wrapping
Aidan Lister wrote: Why do these functions wrap at approximately 80 chars? It's stupid! How can this be worked around? It doesn't check the source to see that the browser wraps the text as it reaches the border of the window. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: show_source or highlight_string wrapping
Red Wingate wrote: Aidan Lister wrote: Why do these functions wrap at approximately 80 chars? It's stupid! How can this be worked around? It doesn't check the source to see that the browser wraps the text as it reaches the border of the window. Oh just another note, use nobr to skip this limitation :-) nobr ?php hightlight_file ( '...' ); ? /nobr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: slow upload with http post
Yavuz maFelak wrote: Hello I have a webserver that running php4.3.x,mysql3.5x,apache1.3.x on Mandrake9. I intended to transfer this server to another server. I installed Freebsd4.9 on newserver. and certainly apache1.3x,php4,mysql and concerning components. it works well. and I have a problem. We have 100Mbit/s Lan media. no problem Folders that (some has size of 1Mbyte or more ) are uploaded with http_post to the server. in old server the folder that size of 1mbyte was uploaded with in 2 second. but on Freebsd the same folder uploading with in 7,8 second. That is, Upload is slow What shall i do ? wait aprox 5.8 seconds longer? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: $PHP_SELF problem
[EMAIL PROTECTED] wrote: Hi $thisFileName = $PHP_SELF; works in a file just a few lines after the program start. $thisFileName = $PHP_SELF; doesn't work (echo (pDebug: self: $PHP_SELF/p); returns pDebug: self: /p) if it's within function getNavigation() in the Navigation object called by another program. You better check the docs on 'global' and $GLOBALS :-) -- red Why? The Navigation object is called like this: include (Navigation.php4); $myNavigation = new Navigation (a, b); $myNavigation-getNavigation(); I guess I'm asking $PHP_SELF something confusing. Does it respond index.php4 which is where the above three lines reside, or Navigation.php4 which is where the actual $PHP_SELF resides. All help appreciated :-) Cheers J -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Unwanted e-mails
[...] but your messages *ARE* getting accepted otherwise i would not be reading this email right now! NO THEY ARE NOT - This reply HAS to be sent via the newsgroup! The bounce messages I am getting are as a result of .php.net NOT accepting my perfectly valid posts! No, I don't believe so -- the bounce you posted looks exactly like the one I get from every message posted to the list, and my messages get through fine. In fact, the bounce generally arrives days after the message has made it to the list! [...] Allright, lets glue this two posts together [...] Delivery-date: Mon, 19 Apr 2004 20:30:30 +0100 Received: from dswu27.btconnect.com ([193.113.154.28]) by mx1.mail.uk.clara.net with smtp (Exim 4.30) id 1BFeTO-000KR9-8m for [EMAIL PROTECTED]; Mon, 19 Apr 2004 20:30:30 +0100 Received: from btconnect.com by dswu27.btconnect.com id [EMAIL PROTECTED]; Mon, 19 Apr 2004 20:27:04 +0100 Message-Type: Delivery Report [...] Sooo ... now if you would have taken a slight look at the mail you got, you might have noticed 'dswu27.btconnect.com'. Now, someone registered an e-mail adress to PHP.General [EMAIL PROTECTED] which bounces every message back it gets from the list (right to the author of the mail as is does a simple reply. -- red -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: show_source or highlight_string wrapping
I just build a testcase to check wether PHP does or not and it doesn't even if i have 1080 chars in a line :p -- red No, PHP explicity inserts br at 80chars Red Wingate [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Red Wingate wrote: Aidan Lister wrote: Why do these functions wrap at approximately 80 chars? It's stupid! How can this be worked around? It doesn't check the source to see that the browser wraps the text as it reaches the border of the window. Oh just another note, use nobr to skip this limitation :-) nobr ?php hightlight_file ( '...' ); ? /nobr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: show_source or highlight_string wrapping
Maybe you take a look at the source as there ARE NO linebreaks in any wrong places. I know the source produced by PHP's Source functions is a mess but take yourself a while and you will see there are no linebreaks at all :p -- red Aidan Lister wrote: Here's a PHP4 example: http://ircphp.com/users/imho/?file=function.str_chop.php Here's an example where PHP has explicitly wrapped at 80 chars, but only the PHP, not the HTML. http://ircphp.com/users/imho/ Red Wingate [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I just build a testcase to check wether PHP does or not and it doesn't even if i have 1080 chars in a line :p -- red No, PHP explicity inserts br at 80chars Red Wingate [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Red Wingate wrote: Aidan Lister wrote: Why do these functions wrap at approximately 80 chars? It's stupid! How can this be worked around? It doesn't check the source to see that the browser wraps the text as it reaches the border of the window. Oh just another note, use nobr to skip this limitation :-) nobr ?php hightlight_file ( '...' ); ? /nobr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: lt;buttongt; tag
Try something like this: script language=javascript function submit_form( type ) { document.forms['submit_form'].elements['mode'].value = type; document.forms['submit_form'].submit(); } /script form name=submit_form method= input type=hidden name=mode value= input type=submit onClick=javascript:submit_form('foo'); /form [...] switch ($_POST['submit']) { case edit: ... case new: ... } [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why NNTP is not default protocol for php groups
[...] That is mostly Outlook and OE that are real good at trashing the Xref ... others (old) clients do it too, but OE is the biggest sinner in that aspect... (and Outlook runs on the OE engine when it comes to mail). [...] who is outlook ? :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Converting XML into something PHP like....
Nunners wrote: Array != Object echo $data-Title .'br'; echo $data-avail_dataset[0]-dept_date .'br'; etc. pp There are some examples on how to convert your XML-Dump into an Array check out the comments over at php.net -- red [...] Hi Folks, At the end of the email is a var_dump of my XML... I can go through and do foreach on each section, however, this is completely useless in practice. How do I call things like $data[Title] and $data[avail_dataset][0][dept_date]? At the moment, every time I do this, it comes out as NULL Cheers Nunners [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Logic problem
As foreach is a language-construct you cannot concat it to a string. try something like: $temp = '.'; foreach ( $array AS $key ) $temp .= ''.$key.''; $temp .= ''; instead --red [...] Hi All, I am having a logic problem. (insert jokes here) I am trying to create a function that will allow me to pass any number of fields and tables into a blanket query. I am getting an error; Unexpected foreach. I have tried placing the loop in several different places and am getting the same error. What should I be doing differently? Here's my code; function myselect($array1, $array2){ $i= 0; $n= 0; $query= SELECT.foreach($array1 as $flds){ $flds[$i]; }. FROM.foreach($array2 as $tbls){ $tbls[$n]; }.; $result = mssql_query($query); print table width=\100%\ border=\1\ tr; $j= 0; while($row= mssql_fetch_array($result)){ $fields = $row[flds[$j]]; print td.$fields./td/tr; } } alex [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why NNTP is not default protocol for php groups
[...] According to historical records, on Tue, 20 Apr 2004 18:31:19 +0200 Red Wingate [EMAIL PROTECTED] wrote about Re: [PHP] Why NNTP is not default protocol for php groups: [...] That is mostly Outlook and OE that are real good at trashing the Xref ... others (old) clients do it too, but OE is the biggest sinner in that aspect... (and Outlook runs on the OE engine when it comes to mail). [...] who is outlook ? :-) Rumor will have it that it's a mail-program ... I've yet to see proof of that claim. [...] Sounds quite dangerous ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why NNTP is not default protocol for php groups
Curt Zirzow wrote: * Thus wrote T. H. Grejc ([EMAIL PROTECTED]): Justin Patrin wrote: The threading works just fine. The problem is that users have ignorant mail software that don't set the thread headers correctly. Even newsgroup client software might do this. This is *not* the server's fault in any way, shape, or form. Sure it's not servers fault, knowing that news.php.net is not *real* news server. It is mailing list mirror. News server dont make threads based on subject like mailing list, but based on message header field. The servers don't make threads, its the client software that is responsible for following up to and displaying threads, properly. Curt You could also build your own client using PHP displaying threads by using the imap_thread function which will return the structure of the mails. But you will have serious performance troubles as you are only allowed to fetch all headers at once :-( -- red -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why NNTP is not default protocol for php groups
Same here, just installed some Newsgroup Software and everything works just fine for me :-) -- red Justin Patrin wrote: Curt Zirzow wrote: * Thus wrote T. H. Grejc ([EMAIL PROTECTED]): Hello, I've seen this subject before, but never really got any answer. PHP have news server at news.php.net but it is 'always' down and it is only a mailing list mirror, so some messages get lost or get 'out of thread'. I've never had any problems with news.php.net being down or loosing messages. As for 'out of thread', that is usually due to the person's email/newsreader client not replying correctly to a thread. Curt Same for me, I've used the newsgroup interface for quite a while now and it's never been down or lost messages on me. It's likely that the out of thread thing is a difference between your newsgroup client's threading code and your mail readers threading code. Some programs (such as mutt) can also use subject matching for threads while most others only use headers. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why NNTP is not default protocol for php groups
Same here, just installed some Newsgroup Software and everything works just fine for me :-) -- red Justin Patrin wrote: Curt Zirzow wrote: * Thus wrote T. H. Grejc ([EMAIL PROTECTED]): Hello, I've seen this subject before, but never really got any answer. PHP have news server at news.php.net but it is 'always' down and it is only a mailing list mirror, so some messages get lost or get 'out of thread'. I've never had any problems with news.php.net being down or loosing messages. As for 'out of thread', that is usually due to the person's email/newsreader client not replying correctly to a thread. Curt Same for me, I've used the newsgroup interface for quite a while now and it's never been down or lost messages on me. It's likely that the out of thread thing is a difference between your newsgroup client's threading code and your mail readers threading code. Some programs (such as mutt) can also use subject matching for threads while most others only use headers. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
AW: [PHP] example from meloni not working
Execute $sql :) -- red -Ursprüngliche Nachricht- Von: Anthony Ritter [mailto:[EMAIL PROTECTED] Gesendet: Sunday, April 18, 2004 7:42 PM An: [EMAIL PROTECTED] Betreff: [PHP] example from meloni not working A basic ht counter script from Meloni's book on mysql (page 318). Not working for me. Every time I load the page the counter stays at zero. Thanks for help. TR .. ? $page_name=test1; $db=mysql_connect(localhost,root,'mypass); mysql_select_db(sitename); $sql = UPDATE test_track SET hits = hits + 1 WHERE page_name = '$page_name'; $sql2=SELECT hits FROM test_track WHERE page_name='$page_name'; $res=mysql_query($sql2); $hits = mysql_result($res,0,'hits'); ? html body h1You have been counted./h1 p The current number is ? echo $hits; ?/p /body /html . // mysql SCHEMA CREATE TABLE test_track( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, page_name VARCHAR(50), hits INT ); INSERT INTO test_track VALUES(1,'test1',0); -- 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] Compile PHP question
Wrong one here: http://de2.php.net/manual/en/features.commandline.php [quote] The CLI SAPI was released for the first time with PHP 4.2.0, but was still experimental and had to be explicitly enabled with --enable-cli when running ./configure. Since PHP 4.3.0 the CLI SAPI is no longer experimental and the option --enable-cli is on by default. You may use --disable-cli to disable it. [/quote] Using: './configure --enable-cli --with-mysql' is just right :-) -- red [...] Hi List, How do I compile php without apache, with mysql (client is installed) as cli. ./configure --enable-cli --with-mysql I believe cgi is enabled by default, so ./configure --disable-cgi --enable-cli --with-mysql would be better. [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Bar/Line Graph Tool
PEAR has some very nice Tools for this job :-) -- red [...] Good morning gang, I'm looking for a snazzy line/bar graph class. I've got GD running, with just the basic fonts (I'm using an ISP, so I can't do anything about it!). Any ideas? I've tried a few of the classes at www.phpclasses.org http://www.phpclasses.org , but they all seem to be giving me errors... Although some of them are rather old! Hope you can help Richard [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] storing an array in an ini file
Hi, had the same problem before and got around this by writing my own tiny parser that should work just nicely ( as serializing is a pain-in-the-ass when editing the .ini file on foot ) Anyway i switched to using an XML-File now :-) define ('REGEXP_VARIABLE','[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'); define ('REGEXP_INDEX','[0-9a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'); /** * @author Christian Jerono [EMAIL PROTECTED] * @paramstring $file_name Zu verarbeitende .INI-Datei * @parambool$process_sections Verarbeitung von Sectionen * @return array */ function _parse_config_file( $file_name , $process_sections = FALSE ){ $match_index = #^\[?(. REGEXP_INDEX .)\]?#; $match_section = #^\s*\[(. REGEXP_VARIABLE .)\]#; $match_config_param = #^\s*(. REGEXP_VARIABLE .(\[. REGEXP_INDEX .\])*)\s*=\s*(.*)$#; $match_value = #^(([\\\'])(.*)(?(2)[\\\']))|([^;]*).*$#; $return = array(); $file_content = file($file_name); $pointer = $return; foreach ( $file_content AS $file_line ){ $file_line = trim($file_line); if ( $process_sections === TRUE AND preg_match( $match_section , $file_line , $section ) ){ $pointer = $return[$section[1]]; } else if ( preg_match( $match_config_param , $file_line , $config_param ) ) { $index_name = $config_param[1]; $value = trim(preg_replace( $match_value , \\3\\4 , $config_param[3] )); $sub_pointer = $pointer; while ( preg_match( $match_index , $index_name , $temp ) ){ $sub_pointer = $sub_pointer[$temp[1]]; $index_name = substr($index_name,strlen($temp[0])); } $sub_pointer = defined($value) ? constant($value) : $value; } } return $return; } -- red [...] I have an ini file for my application and I use parse_ini_file to load it and some custom code to save modifications. I'd like to figure out how to store array values in there since that is the logical place to keep config data. If I can't, I could probably use a string with @@ or | in it as the token but an array is so much more elegant because that's what it's meant to do :-) Any suggestions? [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] automatic doc generation for classes
Which version of PHP and phpDocumentor are you using ? -- red Am Mittwoch, 14. April 2004 06:25 schrieb Andy B: so far it looks good... i got a test class/package to compile as far as the docs go but now when i try to do more with it it always crashes: c: c:\php\cli\php -t c:\src\test\ -o CHM:default:default -d c:\src\test\ fatal error: undefined member to object in c:\phpdoc\php documenter\includes\converter.php on line 4199 cant quite tell what im doing wrong but going to go through the docs and see if i messed it up somehow... - Original Message - From: Richard Harb [EMAIL PROTECTED] To: Andy B [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, April 13, 2004 11:37 PM Subject: Re: [PHP] automatic doc generation for classes Well, since you already mentionned it: Why not use phpdoc? I use it on a regular basis: it's pretty good. (Yes, it works like a charm on a windows box with enough memory) Richard Tuesday, April 13, 2004, 9:10:23 PM, you wrote: does anybody have any good recommendations for anything to do auto doc generation for php classes/functions and stuff.. like phpdoc or something of that sort? what ones are the best to use for windows -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] remote files handling
http://de.php.net/filemtime [quote] As of PHP 5.0.0 this function can also be used with some URL wrappers. Refer to Appendix J for a listing of which wrappers support stat() family of functionality. [/quote] -- red [...] hello sir need help in remote files handling. i.e, i want to know the last modified date of a file on a remote server. for example www.abc.com/abc/Test.zip. i want to know the last modified date of that file. can u pls help me. thankz in advance [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] automatic doc generation for classes
Back on-line :-) http://phpdoc.org/docs/HTMLSmartyConverter/default/phpDocumentor/ tutorial_tags.pkg.html [...] well got it to work... there was problems with the way i was making their comments... kept doing **/ at end of comment block instead of */ never did figure out what most of the @ things are for... got as far as @var and their server died...oh well ill figure it out someday... like the chm format though...gues it could be a slight better but overall its ok... grin [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP time zone
Best: use gmmktime() and add the required offset by: $time_here = gmmktime() + ( $offset * 60 * 60 ) ; how can get a specific time zone, not the server time. example: if the server time is 13:15:46 I need to output that time +5hours so 18:15:46 because the hosting server time is not my local or other area time.. thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] intermittent problems using ftp_get ...Help!
Maybe the max number of connections to the FTP server is reached? My provider allows only up to 3 FTP connections at the same time which causes similar problems to my scripts :-) -- red [...] Can anyone tell me what would cause intermittent problems downloading files using ftp_get. I have a php file that regularly connects to a number of servers in turn using php's (ftp functions) and downloads files using ftp_get(...). This usually works but often it just fails to download a file and ends up giving a timeout error. Also it seems it can be any file. I just cannot understand why when I run the script a number of times in sucsession this will sometimes but not others. Any ideas? [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting the barcode
it's preg_match_all Am Dienstag, 13. April 2004 15:05 schrieb Brent Clark: Hi All I have asked this question before, and the solution was partyly solved, I hope hope someone can help me again. I have a binary file ( readbar ) that I execute with exec(). and it give me an output as so: readbar file Key1 is 4 barcodes found Code 39-10301535 Code 39-10301536 Code 39-10301537 Code 39-10301538 I need to get all the numbers after the - I there is a carriage return after the number. My preg_match is like so if(preg_match(#([0-9]{8})# , $key1, $result)){ which works for only the first top number, but not for the rest. If there away to get this it an array or do a grep on this. There can be many lines that begin with Code 39- If somone can assist that would be most appreciated. Im out of ideas on this one Kind Regards and thank you Brent Clark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] page design and possible conflict??
ok Am Donnerstag, 8. April 2004 14:45 schrieb Andy B: dont know what his deal is but ok will close this idea now i guess.. - Original Message - From: Miles Thompson [EMAIL PROTECTED] To: Andy B [EMAIL PROTECTED] Sent: Thursday, April 08, 2004 7:41 AM Subject: Re: [PHP] page design and possible conflict?? You're right, ot out of range. Seems to be an issue of taste and control. Could this be because the person in charge is confusing CSS borders with padding? MT At 07:19 AM 4/8/2004 -0400, you wrote: hi.. this might be sort of ot and out of the range of the list but i had a site design question: is it an absolute no no to put inset borders 3px wide around EVERY table on the section of the site?? im trying to make an attempt at making the site have some sort of layout standards and that happen to be one of the new changes (my part) the site owner liked.. i didnt think there was any huge rule for that as long as everybody could still use the page... possible conflict: the main person doing the site doesnt like it when there are borders around any table at all and i was already told by him not to do that or my stuff wont get added?? even though i was paid before i finished the work *stress* dont know what to do... -- 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] Using WinNT login
Search the archive, we had this topic about a month ago and i pointed out a quite good solution on this topic. -- red Hi All, Is it possible to use the users WinNT network login for a php app? If so can someone point me in the direction for a tutorial or directions. Thanks, alex hogan ** The contents of this e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom it is addressed. The views stated herein do not necessarily represent the view of the company. If you are not the intended recipient of this e-mail you may not copy, forward, disclose, or otherwise use it or any part of it in any form whatsoever. If you have received this e-mail in error please e-mail the sender. ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regular expression
Alright, first of all, in E-Mail Headers every param needs to be written in a seperate line, therefore following will work even with multiple recipients: $recipients = array(); $header = explode( \n , $header ); foreach ( $header AS $param ) { $param = trim ( $param ); if ( strtolower( substr( $param , 0 , 3 ) ) == 'to:' ) { $recipients[] = trim ( substr( $param , 3 ) ); } } This will match every of these: 'TO:[EMAIL PROTECTED]' ' TO: [EMAIL PROTECTED]' ' TO:Mr Baz [EMAIL PROTECTED]' ' TO:[EMAIL PROTECTED],[EMAIL PROTECTED],[EMAIL PROTECTED]' etc. pp -- red PS: I'm not sure about wether 'TO :' is allowed or not - sad thing :-) Am Mittwoch, 7. April 2004 11:28 schrieb Simon Hayward: preg_match(/To: ([^]+)?([^]+)??/i,$string,$matches); returns email in $matches[1] in the first instance and name in $matches[1] and email in $matches[2] in the second. -Original Message- From: Robert Kornfeld [mailto:[EMAIL PROTECTED] Sent: 07 April 2004 09:32 To: [EMAIL PROTECTED] Subject: [PHP] regular expression hey, professionals out there: i need to write a parser for an email-header to retrieve the email of the 'To:'-field. there are 2 possibilities: 'To: [EMAIL PROTECTED]' or 'To: first foo [EMAIL PROTECTED]' i would only need the email-adress! does anyone know the regular expression that can handle both possibilities? (i give up!) thanx! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Legal Disclaimer:- Internet communications are not secure and therefore the Barclays Group does not accept legal responsibility for the contents of this message. Although the Barclays Group operates anti-virus programmes, it does not accept responsibility for any damage whatsoever that is caused by viruses being passed. Any views or opinions presented are solely those of the author and do not necessarily represent those of the Barclays Group. Replies to this e-mail may be monitored by the Barclays Group for operational or business reasons. Barclays Bank PLC trading as Shopsmart from Barclaycard. Registered Office: 54 Lombard Street London EC3P 3AH Registered in England, Registration No. 1026167. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] assign mysql query to a variable first or not
One of the greatest benefits is the fact, that you can easily display your actual query without copying it, passing it to a variable and then display it's content: $result = mysql_query( ); would first become: $var = ; $result = mysql_query( ); echo $var ; now if the query fails, you have to rewrite the Query, copy it to the variable again etc. pp When doing $var = . ; $result = mysql_query( $var ); echo $var ; you just have to rewrite one query instead of two. This way of working only helps you to debug a little faster. [...] AB is it better to give the mysql query string to a variable AB instead of directly doing it with mysql_query? AB i.e. AB $query=select * from table;//is this a better way? AB $query=mysql_query(select * from table);//or is this way AB //better? AB mysql_query(select * from table);//not a good idea i dont think... Most people here probably use some kind of database abstraction layer already (ADOdb, a Pear lib, or a home-grown one, etc). While you are not doing this at the moment, if you hold the query in a string before passing to MySQL it means you could implement a database handler in the future with minimal code changes and not have to re-do every single query. There are other benefits, but that one strikes me as the most important at the moment. [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validating form field text input to be a specificvariable type
An RegExp will work but is not as fast as native functions, but you could use something like: $len1 = strlen ( $input ); $len2 = strspn ( $input , 1234567890,. ); if ( $len1 == $len2 ) { echo 'yuuhooo'; } else { echo 'd\'oh'; } [...] From: William Lovaton [EMAIL PROTECTED] Instead of doing a lot of casting, you can use is_numeric() to see if a variable is a number or a numeric string. Yeah, but the OP wanted to be able to tell an integer from a real number from a string. is_numeric() is going to validate 5, 5.5, and 5.05E6, for example. well, an integer is a float too, the real problem is when you type 5.5 in a variable that is expected to be integer. In this case is_numeric() won't do the trick. May be using regexps ([0-9]) will be enough to check integer values but I think it is a bit slower. It is always better to use native functions instead of regexps where possible. [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validating form field text input to be aspecificvariable type
Why not add a function: display_my_cms(); This function will check the current cirumstances and displays an CMS system which fits 100% in every enviroment and layout. Even if new technics are available those will suddenly appear ( maybe CSS3 ). [...] That's not bloat. And using a lot of lines of code to do a simple validation like this is not fun. -William El mi? 07-04-2004 a las 09:54, John W. Holmes escribió: Don't add more bloat to the code. Don't be afraid of actually using a couple of lines to accomplish something instead of demanding a built-in function. [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validating form field text input to be a specificvariable type
No, as this would be yet another line of source. Maybe get those guys to add another function ctype_digit_and_not_empty(); -- red [...] * Thus wrote William Lovaton ([EMAIL PROTECTED]): or modify is_numeric() to explictly perform an integer validation: is_numeric(mixed value [, bool is_integer = false]) um.. ctype_digit(). Very nice! it works fine. The only issue is that it will return true if the parameter is an empty string (). Nothing that an empty() can't fix. [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] confused big time
You could even do: $sql .= ( '.implode( ',' , $a ).' ); This way everything is quoted though ( but this doesn't matter using MySQL anyway ). If you want to escape the values of $a you could use array_map to do this also without having to loop :-) -- red [...] To get your list of columns, you could do this: $column_list = implode(',',array_keys($a)); $sql = INSERT INTO $tablename ($column_list) VALUES ; That way you only have to loop through $a once. [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5: SimpleXML attributes
There is a way, but somehow i don't like it though ( but you can find this in the documentation ): This is config.xml: ?xml version=1.0 encoding=iso-8859-1 ? config lib_error param name=error_logfile_write type=booleanFALSE/param /lib_error /config And my Testfile: $xml = simplexml_load_file( 'config.xml' ); foreach ( $xml-lib_error-param AS $id = $param ) { echo $param['name'] ; // will output 'boolean' ! } -- red [...] Hello, I have what I hope to be a simple question about SimpleXML. Is it possible to get the attributes of a SimpleXML node as an associative array? Consider the following: ?php $sxe = simplexml_load_string('root attr=value/'); print_r($sxe-attributes()); // Gives: simplexml_element Object ( [0] = value ) ? Is there some way to find out that 'value' is the attribute called 'attr'? In other words, can I iterate over SimpleXML attributes without losing track of what their attribute name is? Or is this a case where I should switch over to DOM? [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5: SimpleXML attributes
So, this one will work out quite well ( maybe one should take a look at the documentation of attributes() :-) foreach ( $xml-lib_error-param AS $param ) { $n = 0 ; while ( is_object ( $xml-lib_error-param[$n] ) ) { foreach( $xml-lib_error-param[$n]-attributes() AS $a = $b ){ echo $a .' -- '. $b .'br'; } $n++; } } -- red Dan Phiffer wrote: Red Wingate wrote: ?xml version=1.0 encoding=iso-8859-1 ? config lib_error param name=error_logfile_write type=booleanFALSE/param /lib_error /config $xml = simplexml_load_file( 'config.xml' ); foreach ( $xml-lib_error-param AS $id = $param ) { echo $param['name'] ; // will output 'boolean' ! } I think you mean that would output 'error_logfile_write'. However, what I'm asking is if it's possible to iterate over the SimpleXML node attributes 'name' and 'type', without knowing ahead of time that 'name' and 'type' are expected associative keys. There is an attributes() class method, but that just returns a numerically indexed array of the attribute values: Array ( [0] = 'error_logfile_write', [1] = 'boolean' ) What I want is: Array ( ['name'] = 'error_logfile_write', ['type'] = 'boolean' ) Thanks! -Dan Hello, I have what I hope to be a simple question about SimpleXML. Is it possible to get the attributes of a SimpleXML node as an associative array? Consider the following: ?php $sxe = simplexml_load_string('root attr=value/'); print_r($sxe-attributes()); // Gives: simplexml_element Object ( [0] = value ) ? Is there some way to find out that 'value' is the attribute called 'attr'? In other words, can I iterate over SimpleXML attributes without losing track of what their attribute name is? Or is this a case where I should switch over to DOM? [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5: SimpleXML attributes
Guess it was quite luck i saw the little note in the documentation: Note: SimpleXML has made a rule of adding iterative properties to most methods. They cannot be viewed using var_dump() or anything else which can examine objects. Guess i will have to take a look at my config parser again :-) -- red Dan Phiffer wrote: Red Wingate wrote: So, this one will work out quite well ( maybe one should take a look at the documentation of attributes() :-) Wow I can't believe I missed that. Hehe. I guess the lesson here is don't always trust what you get from print_r(). Thanks for the responses, -Dan foreach ( $xml-lib_error-param AS $param ) { $n = 0 ; while ( is_object ( $xml-lib_error-param[$n] ) ) { foreach( $xml-lib_error-param[$n]-attributes() AS $a = $b ){ echo $a .' -- '. $b .'br'; } $n++; } } -- red Dan Phiffer wrote: Red Wingate wrote: ?xml version=1.0 encoding=iso-8859-1 ? config lib_error param name=error_logfile_write type=booleanFALSE/param /lib_error /config $xml = simplexml_load_file( 'config.xml' ); foreach ( $xml-lib_error-param AS $id = $param ) { echo $param['name'] ; // will output 'boolean' ! } I think you mean that would output 'error_logfile_write'. However, what I'm asking is if it's possible to iterate over the SimpleXML node attributes 'name' and 'type', without knowing ahead of time that 'name' and 'type' are expected associative keys. There is an attributes() class method, but that just returns a numerically indexed array of the attribute values: Array ( [0] = 'error_logfile_write', [1] = 'boolean' ) What I want is: Array ( ['name'] = 'error_logfile_write', ['type'] = 'boolean' ) Thanks! -Dan Hello, I have what I hope to be a simple question about SimpleXML. Is it possible to get the attributes of a SimpleXML node as an associative array? Consider the following: ?php $sxe = simplexml_load_string('root attr=value/'); print_r($sxe-attributes()); // Gives: simplexml_element Object ( [0] = value ) ? Is there some way to find out that 'value' is the attribute called 'attr'? In other words, can I iterate over SimpleXML attributes without losing track of what their attribute name is? Or is this a case where I should switch over to DOM? [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OO concepts
You will find some usefull ressources over at http://www.phppatterns.com/ -- red Robert Cummings wrote: [...] Hello, I have am checking out PHP OOP and it's pretty smooth. I have a decent amount of Java experience so PHP OOP is really easy to pick up. However I have a few questions I was hoping someone could help me with. Can php have a main()? If not ... how to you start a program that is purley PHP OOP or is this even possible? How popular is PHP OOP? Should I use PHP OOP for small dynamic web pages? Is this the convention? [...] [...] There is no main() for PHP. The concept of main is implied at the beginning of you source file. PHP OOP is fairly popular amongst those familiar with it's benefits and techniques; however, many developers use it when they feel it is the best solution for the task at hand. And so it is not uncommon to see both procedural style code and OOP code intermingled. This is fairly accepted in the PHP community. For examples of OOP code you could check out the PEAR web site... http://pear.php.net/ Or my own website: http://www.interjinn.com Or even PHP Classes http://www.phpclasses.org/ And a multitude of other sites which you can probably find by doing a search for OOP and PHP in google (or your favourite search engine). [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about operators
arrays :-) you are defining arrays like: $x = array ( 'a' = 'Apple' , 'b' = 'Banana' , ... ); -- red Gabe wrote: Thanks for the page. That was helpful. Just to make sure, is that operator only typically used then with foreach loops and arrays? Matt Matijevich [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [snip] foreach ($some_array as $name=$value) { ... some code ... } [/snip] http://www.php.net/foreach will give you a good explanation. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validating form field text input to be a specificvariable type
JFYI : var_dump ( '' == 0 ) eq TRUE William Lovaton wrote: I don't think so, Wouldn't be better if ctype_digit() return false on an empty string?? any way an empty string is not a digit. This change will brake backward compatibility so it is not an option. if you look carefully the function that you propose is doing two things at once... at this level this is not a good idea. -William El mi? 07-04-2004 a las 12:39, Red Wingate escribió: No, as this would be yet another line of source. Maybe get those guys to add another function ctype_digit_and_not_empty(); -- red [...] * Thus wrote William Lovaton ([EMAIL PROTECTED]): or modify is_numeric() to explictly perform an integer validation: is_numeric(mixed value [, bool is_integer = false]) um.. ctype_digit(). Very nice! it works fine. The only issue is that it will return true if the parameter is an empty string (). Nothing that an empty() can't fix. [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php