Re: [PHP] File concurrent file access
On Fri, Jul 22, 2011 at 10:44 AM, Florian Lemaitre florian.lemai...@evolutioncom.eu wrote: Hi ! I'm developing my new website and I'm worried about concurrent file access. In fact, I want to suppress a maximum database interactions so I keep information in files with faster I/O than databases. But I'm worried by the fact that an error can occur when someone try to access a file being edited by a cron task. Does PHP do all the stuff itself or is there something to do about it ? PS: I only use file_get_contents, file_put_contentsand unlink on files. Best regards. Florian With file_put_contents you send a flag to lock the file and avoid concurrency problems, eg: file_put_contents('/some/file', 'data', FILE_APPEND | LOCK_EX); Regards, Jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Common session for all subdomains?
Hi! You should use the function session_set_cookie_params to set the session cookie domain to .oire.org like this comment explains: php.net/manual/en/function.session-set-cookie-params.php#94961 Regards, Jonathan On Mon, Dec 20, 2010 at 7:18 PM, Andre Polykanine an...@oire.org wrote: Hello php-general, I've got a question: I have a site http://oire.org/. Then we started developing some applications at http://apps.oire.org/. How can I manage it in the way so the session valid at http://oire.org/ would be also valid at http://apps.oire.org/? Thanks! -- With best regards from Ukraine, Andre Skype: Francophile Twitter: http://twitter.com/m_elensule Facebook: http://facebook.com/menelion -- 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] Open Source PHP/ mySQL Project Management
Hi, I don't know if it meets all of the features you enumerated but Mantis (http://www.mantisbt.org/) is very good, and it is PHP+MySQL (or Postgres, or MSSQL). Jonathan On Thu, Nov 11, 2010 at 7:23 PM, Don Wieland d...@dwdataconcepts.com wrote: Hi gang, I am looking into Project Management apps for my projects. Any suggestions: I am interested in tracking Projects, Milestones, Tickets, Files, Discussions, Documents, Time Tracking, etc... Also, would like to have the system have robust email integration Reminders, Email Ticket echos (where a user can reply it will post back into the PM system and echo back email to assigned users - with file attachments) Suggestions? Thanks! Don -- 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] Including files on NFS mount slow with APC enabled
Hi, APC checks by default if every included file was modified doing a stat call. You can disable it, setting apc.stat to 0 (http://www.php.net/manual/en/apc.configuration.php#ini.apc.stat). Try if that improves the performance. Of course, you should manually delete the APC opcode cache every time you modify a PHP file, since APC won't detect that it was modified. Regards, Jonathan On Mon, Aug 16, 2010 at 10:21 AM, Mark Hunting m...@netexpo.nl wrote: I am struggling with the performance of some websites that use a lot of includes (using include_once). The files are on a NFS mount (NFSv4), and I use APC to speed things up. APC has enough memory, and I see all included files are in the APC cache. apc.include_once_override is enabled. This is on a Ubuntu Linux 10.04 server. What surprises me is that using strace I see apache open()ing all included files. I would think this is not necessary as APC has these files in its cache. Opening a file takes 1-3 ms, the websites include 100-200 files, so this costs about half a second for each request. I tried a lot to prevent this but my options are exhausted. Is it normal that all these files are open()ed each time, and if so how can I speed up these includes? Part of the trace is below, look especially at the first line where 2ms are lost while this file is in the APC cache: open(/[removed]/library/Zend/Application.php, O_RDONLY) = 1440 0.002035 fstat(1440, {st_mode=S_IFREG|0755, st_size=11365, ...}) = 0 0.000137 fstat(1440, {st_mode=S_IFREG|0755, st_size=11365, ...}) = 0 0.000124 fstat(1440, {st_mode=S_IFREG|0755, st_size=11365, ...}) = 0 0.000133 mmap(NULL, 11365, PROT_READ, MAP_SHARED, 1440, 0) = 0x7faf3f068000 0.000395 stat(/[removed]/library/Zend/Application.php, {st_mode=S_IFREG|0755, st_size=11365, ...}) = 0 0.000219 munmap(0x7faf3f068000, 11365) = 0 0.000151 close(1440) = 0 0.000845 Thanks, Mark -- 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] Storing time in mysql prior to 1970
On Wed, Jan 27, 2010 at 7:58 PM, Haig Davis level...@gmail.com wrote: Hi Everyone, I'm sure I'm missing something simple. I'm trying to store dates of birth prior to 1970 in mysql. I've tried mysql's date_format but am hitting a wall. I'm chasing my tail and was hoping for the best practice. Many Thanks Haig Use the types date or datetime instead of timestamp, read more about it here: http://dev.mysql.com/doc/refman/5.1/en/datetime.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] http vs https
Hi, isset($_SERVER['HTTPS']) should do it. Regards, Jonathan On Sat, Jan 23, 2010 at 2:11 PM, Ben Miller biprel...@gmail.com wrote: Is there a PHP function that will return whether the request was http or https? I have functions that need to cURL other servers - sometimes over SSL, sometimes not, depending whether the function is called from http://www.mydomain.com/script_that_calls_function.php or https://www.mydomain.com/script_that_calls_function.php Hope the question is clear. Thanks, Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array_count_values Problem
Hi, The function array_count_values returns an array (http://php.net/array_count_values). So you are using it the wrong way, you should assign the return value to a variable and then access some index. Regards, Jonathan On Tue, Jan 12, 2010 at 11:09 AM, Alice Wei aj...@alumni.iu.edu wrote: Hi, I have a code in the following, after investigating more closely on how to use array_count_values(): //Calculate the number of elements in array $total_num = count($friend_from); $total_num2 = count(array_unique($friend_from)); for ($i=0;$i=$total_num2;$i++) echo $friend_from[$i] . . array_count_values($friend_from[$i]) . \n; Neither of these two numbers, $total_num and $total_num2 are 0, but I only get something like this: Monroe, IN Cherokee, OK Cherokee, OK Cleveland, OK Greer, OK How come that I cannot get it to print out the individual array_count_values? Have I missed something here? Thanks for your help. _ Hotmail: Trusted email with powerful SPAM protection. http://clk.atdmt.com/GBL/go/196390707/direct/01/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Count the Number of Certain Elements in An Array
On Mon, Jan 11, 2010 at 6:21 PM, Alice Wei aj...@alumni.iu.edu wrote: Hi, This seems like a pretty simple problem, but I can't seem to be able to figure it out. I have a lot of elements in an array, and some of them are duplicates, but I don't want to delete them because I have other purposes for it. Is it possible for me to find out the number of certain elements in an array? For example, // Create a simple array. $array = array(1, 2, 3, 4, 5, 3,3,4,2); $total = count($array); echo $total; If I run the code, the value of $total would be 9. However, what I really want to do is to get the values of the different instances of each, like: 1 = 1 2 = 2 3 = 3 4= 2 5= 1 Is there a simple code that I use to find this out? Thanks for your help. Alice _ Hotmail: Trusted email with powerful SPAM protection. http://clk.atdmt.com/GBL/go/196390707/direct/01/ Hi, Try the function array_count_values. Regards, Jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] cannot access SimpleXML object property
On Thu, Jan 7, 2010 at 6:56 PM, Mari Masuda mari.mas...@stanford.edu wrote: Hi, I am working with an XML document and have a SimpleXML object whose var_dump looks like this: --- object(SimpleXMLElement)#2 (10) { [@attributes]= array(1) { [id]= string(7) 3854857 } [type]= string(7) Article [createDate]= string(25) 2006-09-06T16:42:20-07:00 [editDate]= string(25) 2007-07-16T09:15:53-07:00 [creator]= string(19) Michael Gottfredson [status]= string(5) ready [field]= ...snip a bunch of stuff... } --- Assuming the above object is referenced by $current_object, I can access the values of most stuff with $current_object-creator or whatever. However, I cannot figure out how to access the value of id. I tried the following, none of which worked for me: 1. $current_object-@attributes-id (gives Parse error: syntax error, unexpected '@', expecting T_STRING or T_VARIABLE or '{' or '$' in /Applications/apache/htdocs/test.php on line 33) 2. $current_object-'@attributes'-id (gives Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_STRING or T_VARIABLE or '{' or '$' in/Applications/apache/htdocs/test.php on line 33) 3. $current_object-{...@attributes}-id (no error but is null) 4. $current_object-{'@attributes'}-id (no error but is also null) Does anyone know how I can reference the value of id? Thanks! Mari -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php $id = (string)$current_object['id']; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: SQL Queries
Hello, That kind of queries usually run faster using a LEFT JOIN, like this: select u.id from users u left join notes n on u.id = n.user_id where n.id is null; That query will give you the ids of the users without notes. Make sure to have an index on notes.user_id to let the LEFT JOIN use it and run faster. Hope that helps, regards, Jonathan On Sun, Dec 20, 2009 at 6:41 PM, דניאל דנון danondan...@gmail.com wrote: Sorry for the double-post, forgot to add up the way I thought about using: Simple sql query: SELECT * FROM `users` as u WHERE (SELECT COUNT(id) FROM notes WHERE user_id = u.id LIMIT 0,1) = 0 Problem is I have about 450,000 users and about 90% don't have notes, and it takes LOADS of times even with I limit it: SELECT * FROM `users` as u WHERE (SELECT COUNT(id) FROM notes WHERE user_id = u.id LIMIT 0,1) = 0 LIMIT 0,10 Takes about 10 seconds which is too much time... Any way to optimize it? On Sun, Dec 20, 2009 at 11:30 PM, דניאל דנון danondan...@gmail.com wrote: Hey, Lets assume I got a table named users. It contains id name. I have another table called notes - which contains id, user_id, contents I want to delete all users from table users that don't have notes (SELECT ... FROM notes WHERE user_id=ID) returns empty result. What is the fastest way to do it? -- Use ROT26 for best security -- Use ROT26 for best security -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Logic of conditionals and the ( ) operators
Hi, Yes, what Ashley said is correct. Also, if you want to avoid writing $perm several times in the if, or if you have a lot of permissions you can do: if (in_array($perm, array(11, 22))) And you can put in that array all the permissions you need to. Regards, Jonathan On Fri, Dec 18, 2009 at 3:47 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Fri, 2009-12-18 at 10:21 -0800, Allen McCabe wrote: In a nutshell: Will this work? if ($perm == (11 || 12)) Explanation: I am laying the groundwork for a photo viewing system with a private and public mode, and additionally if an admin is logged in, there is an additional level of permission. I came up with a number system to make it easier (and is calcualted by a class) so now, instead of checking against the $mode variable, if the user is logged in, and then what their user level is if they are logged in, I just check against some numbers (the class evaluates all those conditions and assigns the appropriate number a single permission variable, $perm. That equates to if($perm == true) as 11 in this case translates to true (being a positive integer) The code never needs to figure out the || part, as the first part is true. I think what you'd want to do is possibly: if($perm == 11 || $perm == 12) Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with XPath query
Hi, You are missing a quote after widgetType: [...@alias=widgetType and @value=system] should be [...@alias=widgetType and @value=system] Regards, Jonathan On Mon, Dec 14, 2009 at 1:52 PM, Christoph Boget christoph.bo...@gmail.com wrote: Given the following XML: Pages Page DisplayRef alias=Widget parameter alias=widgetType type=variable value=system/ /DisplayRef /Page /Pages I'm using the following query: $oXPath-query( '//DisplayRef/paramet...@alias=widgetType and @value=system]' ); and I'm getting the following error: Warning: DOMXPath::query() [function.DOMXPath-query]: Invalid predicate If I remove this part of the query [...@alias=widgetType and @value=system] the error goes away. As far as I can tell from googling around, the query is valid. If that's the case, I don't understand what's causing the error. Could someone explain to me what I'm doing wrong? thnx, Christoph -- 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] PHP APACHE SAVE AS
You are probably missing something like this in the apache httpd.conf: LoadModule php5_module c:/PHP/php5apache2_2.dll PHPIniDir c:/PHP/php.ini AddType application/x-httpd-php .php DirectoryIndex index.php index.html index.html.var Regards, Jonathan On Fri, Nov 27, 2009 at 6:24 AM, Julian Muscat Doublesin opensourc...@gmail.com wrote: Hello Everyone, I have installed PHP, Apache and MySQL on a Windows 7 machine :(. I would prefer linux or unix :) These have been setup and working correctly. However when I access a php page. I get the save as dialog. Has anyone ever experinced such a situation. Can anyone please advise. Thank you very much in advance. Julian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Lightweight web server for Windows?
Try nginx (http://nginx.net/), very light, has a Windows binary distribution and can be configured easily for PHP. You can also find some version of Lighttpd compiled for Windows and skip the compilation troubles, and you can use this: http://sites.google.com/site/lightytray/ to control the webserver. Both of them are lighter than Apache. Good luck, Jonathan On Sun, Nov 15, 2009 at 6:00 PM, O. Lavell olav...@xs4all.nl wrote: What do people on this list use as an ultra-lightweight web server (with PHP capability of course) on Windows? I have an old but still well functioning laptop that I have just given a second life by installing Windows Fundamentals (a stripped down version of XP). This works surprisingly well. So now I am looking for the necessary software, so I can do some local programming. Some requirements I can think of: - Extremely small memory footprint and fast efficient code. This laptop still works well but it can certainly use some help! - Both free as in beer and free as in speech would be my preference. - Be able to run as a service in XP. - Be able to run PHP (obviously) and perhaps a few other nice server features, like SSI and name based virtual hosts. Any suggestions? I have not seriously used Windows for years now, so my knowledge of that platform is not exactly up to date anymore. I am used to dealing with Debian/Ubuntu Linux and Apache but not much else, frankly. Apache does seem to heavy for this. My initial thought was to install Lighttpd under Cygwin, but perhaps I would be missing out on some great little server program that I have not yet heard about. -- 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] Spam opinions please
That will work just for one IP, but they could spam you from another IP. I suggest you add a good captcha to the form and that way you can avoid spam forever. Regards, Jonathan On Tue, Oct 20, 2009 at 3:31 PM, Gary gwp...@ptd.net wrote: I have several sites that are getting hit with form spam. I have the script set up to capture the IP address so I know from where they come. I found a short script that is supposed to stop these IP addresses from accessing the form page, it redirects the spammer to another page (I was going to redirect to a page that has lots of pop-ups, scantily clad men and offers of joy beyond imagination), but someone suggested I redirect to the Federal Trade Commission or perhpas the FBI. Any thoughts on the script and its effectivness? ?php $deny = array(111.111.111, 222.222.222, 333.333.333); if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) { header(location: http://www.google.com/;); exit(); } ?Gary __ Information from ESET Smart Security, version of virus signature database 4526 (20091020) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Spam opinions please
On Tue, Oct 20, 2009 at 3:39 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2009-10-20 at 15:36 -0300, Jonathan Tapicer wrote: That will work just for one IP, but they could spam you from another IP. I suggest you add a good captcha to the form and that way you can avoid spam forever. Regards, Jonathan Firstly, in_array() is used in his example, so it will look for all the IP addresses in the array, not just one. Secondly, even the best captchas can be got around. Just look at what happened to Google a while back. And then what if you make the captcha too hard to discern? You'd essentially be breaking the law by impeding hard of seeing or blind users... Thanks, Ash http://www.ashleysheridan.co.uk Even if he puts a list or range of IPs he could always be attacked from an IP not in that list/range. About the blind users, he can use recaptcha (recently aquired by Google), http://recaptcha.net/, which has an audio version captcha. I'm not saying that the filter by IP won't work, but it won't be 100% effective, and a captcha will. Regards, Jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] exec() confused by a specially crafted string
Confirmed, it also happens to me on Linux, PHP version: PHP 5.2.4-2ubuntu5.7 with Suhosin-Patch 0.9.6.2 (cli) (built: Aug 21 2009 19:52:39) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies And adding a single character to the echoed string makes it work fine, seems like a bug to me. Regards, Jonathan On Mon, Oct 12, 2009 at 1:10 PM, Soner Tari so...@comixwall.org wrote: When shell command returns a specially crafted string, I get an empty array as $output of exec(), instead of the string. I can very easily reproduce this issue as follows: Put the following lines in bug.php: ?php exec('php echostr.php', $output); print_r($output); echo \n; ? Then put the following in echostr.php (the string is just one line actually, new lines may be inserted by this mail agent, I provide a link below): ?php echo 'a:25:{i:0;a:4:{s:4:Date;s:6:Aug 7;s:4:Time;s:8:16:00:01;s:7:Process;s:16:newsyslog[23117];s:3:Log;s:19:logfile turned over;}i:1;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:43:55;s:7:Process;s:12:openvpn[226];s:3:Log;s:76:OpenVPN 2.1_rc18 x86_64-unknown-openbsd4.5 [SSL] [LZO1] built on Jun 26 2009;}i:2;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:43:55;s:7:Process;s:12:openvpn[226];s:3:Log;s:102:NOTE: OpenVPN 2.1 requires \'--script-security 2\' or higher to call user-defined scripts or executables;}i:3;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:43:55;s:7:Process;s:12:openvpn[226];s:3:Log;s:27:LZO compression initialized;}i:4;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:43:55;s:7:Process;s:12:openvpn[226];s:3:Log;s:63:Control Channel MTU parms [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ];}i:5;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:43:55;s:7:Process;s:12:openvpn[226];s:3:Log;s:70:Data Channel MTU parms [ L:1542 D:1450 EF:42 EB:135 ET:0 EL:0 AF:3/1 ];}i:6;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:43:55;s:7:Process;s:12:openvpn[226];s:3:Log;s:39:Local Options hash (VER=V4): \'41690919\';}i:7;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:43:55;s:7:Process;s:12:openvpn[226];s:3:Log;s:49:Expected Remote Options hash (VER=V4): \'530fdded\';}i:8;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:43:55;s:7:Process;s:14:openvpn[31938];s:3:Log;s:48:Socket Buffers: R=[41600-65536] S=[9216-65536];}i:9;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:43:55;s:7:Process;s:14:openvpn[31938];s:3:Log;s:25:UDPv4 link local: [undef];}i:10;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:43:55;s:7:Process;s:14:openvpn[31938];s:3:Log;s:38:UDPv4 link remote: 81.215.105.114:1194;}i:11;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:44:55;s:7:Process;s:14:openvpn[31938];s:3:Log;s:98:TLS Error: TLS key negotiation failed to occur within 60 seconds (check your network connectivity);}i:12;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:44:55;s:7:Process;s:14:openvpn[31938];s:3:Log;s:31:TLS Error: TLS handshake failed;}i:13;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:44:55;s:7:Process;s:14:openvpn[31938];s:3:Log;s:23:TCP/UDP: Closing socket;}i:14;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:44:55;s:7:Process;s:14:openvpn[31938];s:3:Log;s:52:SIGUSR1[soft,tls-error] received, process restarting;}i:15;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:44:55;s:7:Process;s:14:openvpn[31938];s:3:Log;s:26:Restart pause, 2 second(s);}i:16;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:44:57;s:7:Process;s:14:openvpn[31938];s:3:Log;s:102:NOTE: OpenVPN 2.1 requires \'--script-security 2\' or higher to call user-defined scripts or executables;}i:17;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:44:57;s:7:Process;s:14:openvpn[31938];s:3:Log;s:24:Re-using SSL/TLS context;}i:18;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:44:57;s:7:Process;s:14:openvpn[31938];s:3:Log;s:27:LZO compression initialized;}i:19;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:44:57;s:7:Process;s:14:openvpn[31938];s:3:Log;s:63:Control Channel MTU parms [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ];}i:20;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:44:57;s:7:Process;s:14:openvpn[31938];s:3:Log;s:70:Data Channel MTU parms [ L:1542 D:1450 EF:42 EB:135 ET:0 EL:0 AF:3/1 ];}i:21;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:44:57;s:7:Process;s:14:openvpn[31938];s:3:Log;s:39:Local Options hash (VER=V4): \'41690919\';}i:22;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:44:57;s:7:Process;s:14:openvpn[31938];s:3:Log;s:49:Expected Remote Options hash (VER=V4): \'530fdded\';}i:23;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:44:57;s:7:Process;s:14:openvpn[31938];s:3:Log;s:48:Socket Buffers: R=[41600-65536] S=[9216-65536];}i:24;a:4:{s:4:Date;s:6:Aug 10;s:4:Time;s:8:22:44:57;s:7:Process;s:14:openvpn[31938];s:3:Log;s:25:UDPv4 link local: [undef];}}'; ? When you execute bug.php, you will get an empty array printed out: Array ( ) But actually, $output should have contained the string above as element 0 of the array. If you delete or add a character in the string, exec() runs correctly and you get the intended result. So the issue
Re: [PHP] Fatal error on functions valid for PHP 4, 5
What platform? If you compiled PHP yourself you need to compile with --enable-calendar. Jonathan On Fri, Oct 9, 2009 at 10:01 AM, kro...@aolohr.com wrote: Hi, Would someone be kind enough to test whether these following functions work? I'm getting: PHP Fatal error: Call to undefined function easter_date() . . . easter_days on both local and production sites. ?php echo easter_days(2009); print brbr; echo date(M-d-Y, easter_date(2009)); print brbr; echo date(D d M Y, easter_date(2009)); ? I'm using 5.2.10 production; PHP 5.2.4 local. Tia, Andre -- 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] XML RSS - Unexpected End of File error
Can you show the generated XML? Jonathan On Thu, Oct 8, 2009 at 3:45 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: Hi guys, I've knocked up a quick RSS feed on my site. It works fine in Fx 2 3, in Opera it throws an error unexpected end of file but allows the feed to be added anyway, and Chrome just says there's an XML error, and gives the second from last line as the one containing the error. I tried adding a newline to the end of the file, but that just makes the error message report the next line. Any ideas where I'm going wrong? The file is using utf-8 character encoding. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newb question about getting keys/values from a single array element
One possible solution: ?php $a = array(8575 = 'peach'); list($id, $name) = array_merge(array_keys($a), array_values($a)); echo The ID is $id and the name is $name; ? Prints: The ID is 8575 and the name is peach. Regards, Jonathan On Thu, Oct 8, 2009 at 10:08 PM, Daevid Vincent dae...@daevid.com wrote: I feel like a total newb asking this, but I'm just having a brain fart or something... I'm writing a page where I can either get back a list of items: Array { [1233] = apple, [6342] = apricot, [2345] = banana, ... } where the user then refines it by choosing one single item and a single element array is returned like this: Array { [8575] = peach, } How can I get this $item so I can print it like so: echo The ID is $id and the name is $name; Normally with an array of items, I do a: foreach ($item as $id = $name) echo... But that seems overkill for this scenario. The rub is that I don't know the id, so I can't use $item[0], and I also don't have something like $item['name'] to use either. There's got to be an easy way to extract those. list($id, $name) = $operator; Felt like it would work for a minute (wishful thinking). (I'm too embarrased to even sign my name on this one) -- 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] Converting print_r() output to an array
Hi, May be you want to take a look at serialize and unserialize functions, serialize generates a string from a variable and then unserialize can give you the value of the variable back from the string. Regards, Jonathan On Thu, Oct 1, 2009 at 12:07 AM, James Colannino ja...@colannino.org wrote: Hey everyone, I was pretty sure there was an easy built-in solution for what I want to do, but I've been googling around with no luck. Basically, I just want to take a string containing the output of print_r() and convert it back into an array again. That is possible, right? If so, how do I go about it? If not, what's a quick and easy way to parse a string and turn it into an array (I don't necessarily need the string to be in the format print_r returns). Thanks! James -- 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] html email showing br instead of line breaks
\r\n should be between double quotes: \r\n On Thu, Sep 24, 2009 at 3:52 PM, Adam Williams awill...@mdah.state.ms.us wrote: I have users enter support tickets into a a textarea form and then it emails it to me, I'm trying to get the emails to display when they hit enter correctly, so i'm changing the \r\n to br, but in the email i'm getting, its displaying the br instead of a line break: here is the code: $message = htmlheadtitlenew support request #.mysqli_insert_id($mysqli)./title/headbodyp Hello, .$_SESSION[full_name]. has created a new support request. Please log in at a href=\http://intra/helpdesk\;MDAH Helpdesk/a. The problem request is \; $message .= htmlspecialchars(str_replace('\r\n', 'br', $_POST[problem])); $message .= \ and the best time to contact is \.htmlspecialchars($_POST[contact_time]).\ /p/body/html; $headers = 'MIME-Version: 1.0' . \r\n; $headers .= 'Content-type: text/html; charset=iso-8859-1' . \r\n; $headers .= From: .$_SESSION[full_name]..$_SESSION[username].@mdah.state.ms.us .\r\n . X-Mailer: PHP/ . phpversion(); mail('isst...@mdah.state.ms.us', $subject, $message, $headers); but the email I get is: Hello, Karen Redhead has created a new support request. Please log in at MDAH Helpdesk http://intra/helpdesk. The problem request is Elaine is out today but her computer no longer has Past Perfect from what I can tell. Also how does she access her email. The Sea Monkey email icon does not take you anywhere.brThanks so much,brKaren and the best time to contact is 1:30 -5:00 How come the email is being displayed with br instead of line breaks? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] html email showing br instead of line breaks
Double quotes accept special characters and string interpolation, see the manual: http://php.net/manual/en/language.types.string.php On Thu, Sep 24, 2009 at 4:00 PM, Adam Williams awill...@mdah.state.ms.us wrote: Thanks, i'll try that. what is the difference in using '' and ? I thought they were interchangeable. Jonathan Tapicer wrote: \r\n should be between double quotes: \r\n -- 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] Stricter Error Checking?
Hi, There is, see here (or it can also be set through php.ini): http://www.php.net/manual/en/function.error-reporting.php You are looking for E_STRICT. Regards, Jonathan On Wed, Sep 23, 2009 at 3:11 PM, Tim Legg kc0...@yahoo.com wrote: Hello, I just spent way, way to much time trying to debug code due to a misnamed element. Here is a simplified example of the problem I dealt with. $test = SELECT * FROM `Materials` WHERE `Part_Number` = '125664'; $result = mysql_query($test,$handle); if(!$result) { die('Error: ' . mysql_error()); } $row = mysql_fetch_array($result); echo $row['Number']; After retyping the code 3 or 4 times over the course of the morning, I finally found where the problem was. The problem is that the database field is called 'Part_Number', not 'Number'. The field 'Number' does not exist in the database. I am very surprised that I didn't even get a warning that there might be a problem with the statement. All I saw is that nothing was being returned via the echo command. There really must be a stricter error checking that is turned on somewhere, isn't there? 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] Stricter Error Checking?
I think he meant that he is using 'Number' instead of 'Part_Number' when accessing the array and not in the SQL, his SQL was correct, this was wrong: echo $row['Number']; E_STRICT catches that kind of error. Jonathan On Wed, Sep 23, 2009 at 3:28 PM, Tommy Pham tommy...@yahoo.com wrote: - Original Message From: Tim Legg kc0...@yahoo.com To: php-general@lists.php.net Sent: Wednesday, September 23, 2009 11:11:46 AM Subject: [PHP] Stricter Error Checking? Hello, I just spent way, way to much time trying to debug code due to a misnamed element. Here is a simplified example of the problem I dealt with. $test = SELECT * FROM `Materials` WHERE `Part_Number` = '125664'; $result = mysql_query($test,$handle); if(!$result) { die('Error: ' . mysql_error()); } $row = mysql_fetch_array($result); echo $row['Number']; After retyping the code 3 or 4 times over the course of the morning, I finally found where the problem was. The problem is that the database field is called 'Part_Number', not 'Number'. The field 'Number' does not exist in the database. I am very surprised that I didn't even get a warning that there might be a problem with the statement. All I saw is that nothing was being returned via the echo command. if(!$result) { die('Error: ' . mysql_error()); } This didn't work when you used 'Number' instead of 'Part_Number'? Strange... There really must be a stricter error checking that is turned on somewhere, isn't there? 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with date
Adding the number of seconds in a day could fall in the same day due to daylight saving time, a more reliable way of adding one day (or a given number of days) is this: $tomorrow = mktime(0, 0, 0, date(m) , date(d)+1, date(Y)); Then use date() with $tomorrow to format it. (Taken from example #3 here: http://www.php.net/manual/en/function.date.php, see the Note below the example in that page). Hope that helps. Regards, Jonathan 2009/9/15 Korgan josber...@seznam.cz: Hi, I have a problem with date function. $gen_pos = mktime(0,0,1,10,25,2009); $d1 = date(Y-m-d, $gen_pos); // 2009-10-25 $d2 = date(Y-m-d, $gen_pos + (1*24*60*60)); // 2009-10-25 $d3 = date(Y-m-d, $gen_pos + (2*24*60*60)); // 2009-10-26 $d4 = date(Y-m-d, $gen_pos + (3*24*60*60)); // 2009-10-27 $d5 = date(Y-m-d, $gen_pos + (4*24*60*60)); $d6 = date(Y-m-d, $gen_pos + (5*24*60*60)); $d7 = date(Y-m-d, $gen_pos + (6*24*60*60)); $d8 = date(Y-m-d, $gen_pos + (7*24*60*60)); line 2 and line 3 return same date,its wrong ... it should be 2009-10-25 , 2009-10-26 ? :) -- 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] File download question
I think that your problem in this line: header(Content-Disposition: filename=$file . %20); I don't know what that %20 is for and you should quote the filename, that line should be something like this: header(Content-Disposition: attachment; filename=\$file\); Considering that $filename already has the 7z extension. Jonathan On Sun, Sep 6, 2009 at 3:19 PM, Chris Paynechris_pa...@danmangames.com wrote: Hi Everyone, I've setup a filedownload which works but i'm having an issue, i've left out but when it downloads it, while it has the correct file it doesn't have a file extension associated with it, I need the .7z extension associated with the filename, can anyone see why that would do this below? I'm sure it's something obvious but i'm new to doing file downloads. Thank you everyone Chris $file = SOMEFILE.7Z; $speed = 60; // i.e. 60 kb/s download rate if(file_exists($file) is_file($file)) { header(Cache-control: private); header(Content-Type: application/octet-stream); header(Content-Length: .filesize($file)); header(Content-Disposition: filename=$file . %20); flush(); $fd = fopen($file, r); while(!feof($fd)) { echo fread($fd, round($speed*1024)); // $speed kb at a time flush(); sleep(1); } fclose ($fd); } -- 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] Who kown this memcache_get_stats function ?
I think that the documentation for memcache_get_stats should be exactly the same as the one given for the method Memcache::getStats except that memcache_get_stats should receive as the first parameter a reference to the Memcache connection. Hope that helps. Jonathan On Sun, Sep 6, 2009 at 1:16 AM, hack988 hack988hack...@dev.htwap.com wrote: Nobody Kown this?This is my second question in this mail-list :(.I don't kown why it's no reply by anybody. 2009/9/5 hack988 hack988 hack...@dev.htwap.com: I found memcache_get_stats for memcached in some php code. I'm search it at php.net's function list,but it no matched result :(. I had found explain for Memcache::getStats() at this link http://www.php.net/manual/en/function.memcache-getstats.php In this link,tell me that == Also you can use memcache_get_stats() function. == But I can't find memcache_get_stats function's explain in online manual. Anybody can help me for using this function?Or give an more detail link for this function? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_replace anything that isn't WORD
For the record Shawn: I received your previous post from Aug 22 and I think that it is the best solution. Jonathan On Tue, Aug 25, 2009 at 12:41 AM, Shawn McKenzienos...@mckenzies.net wrote: hack988 hack988 wrote: Use preg_replace_callback instead! preg_replace_callback is better performance than preg_replace with /e. - code $str=cats i saw a cat and a dog; $str1=preg_replace_callback(/(dog|cat|.)/is,call_replace,$str); echo $str.BR/; echo $str1; function call_replace($match){ if(in_array($match[0],array('cat','dog'))) return $match[0]; else return ; } 2009/8/24 tedd tedd.sperl...@gmail.com: On Sat, Aug 22, 2009 at 12:32 PM, “•ÈýÏÝ“•ÂÔdanondan...@gmail.com wrote: Lets assume I have the string cats i saw a cat and a dog i want to strip everything except cat and dog so the result will be catcatdog, using preg_replace. I've tried something like /[^(dog|cat)]+/ but no success What should I do? Lot's of ways to skin this cat/dog. What's wrong with exploding the string using spaces and then walking the array looking for cat and dog while assembling the resultant string? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Certain posts of mine seem to get sucked into a black hole and I never see theme. Maybe because I use this list as a newsgroup? Anyway, what I posted before: Match everything but only replace the backreference for the words: $s = cats i saw a cat and a dog; $r = preg_replace('#.*?(cat|dog).*?#', '\1', $s); -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Displaying 2 digit minutes/seconds
You can use sprintf or str_pad to fill in with zeros, with sprintf you can do this: echo sprintf('%02d', 5); That will print the string 05. Jonathan On Thu, Aug 20, 2009 at 6:27 PM, sono...@fannullone.us wrote: Hi all, I'm using this code to display the current time for our location on our website: ?php date_default_timezone_set('America/Los_Angeles'); $theTimeIs = getdate(time()); $theHour = $theTimeIs['hours']; $theMinute = $theTimeIs['minutes']; // make minutes under 10 show two digits $theSecond = $theTimeIs['seconds']; if($theHour 12){ $theHour = $theHour - 12; $dn = PM; } else { $dn = AM; } echo $theHour:$theMinute:$theSecond $dn; ? It works great except for one small detail. If the time is 3:04:02, it is displayed as 3:4:2 which, of course, is very odd looking. So I corrected it as follows: ?php date_default_timezone_set('America/Los_Angeles'); $theTimeIs = getdate(time()); $theHour = $theTimeIs['hours']; if (strlen ($theTimeIs['minutes']) 2) { $theMinute = 0 . $theTimeIs['minutes']; } else { $theMinute = $theTimeIs['minutes']; } if (strlen ($theTimeIs['seconds']) 2) { $theSecond = 0 . $theTimeIs['seconds']; } else { $theSecond = $theTimeIs['seconds']; } if($theHour 12){ $theHour = $theHour - 12; $dn = PM; } else { $dn = AM; } echo $theHour:$theMinute:$theSecond $dn; ? It works, but is there a better way to do it? Thanks, Frank -- 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] Array
On Mon, Aug 10, 2009 at 9:28 AM, Ron Piggottron.pigg...@actsministries.org wrote: How do I change this ELSEIF into an array? } elseif ( ( $page ) AND ( $page home_page ) AND ( $page verse_of_the_day_activate ) AND ( $page member_services ) AND ( $page member_services_login ) AND ( $page member_services_logoff ) AND ( $page resource_center ) AND ( $page network ) ) { Something like: } elseif (!in_array($page, array(, home_page, verse_of_the_day_activate, ...))) { should work. Regards, Jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Embedding foreach loops
On Mon, Aug 10, 2009 at 6:44 PM, Allen McCabeallenmcc...@gmail.com wrote: Gmail automatically sent my last email, apologies. I am creating an order form for tickets for a list of performances at a performing arts center. Currently, the form is on paper, and is set up as follows: -Title - date - time - price - soldout - quantity - total($) -Nutcracker - Tues 10/13 - 9am - $4.00 - yes/no - - __ -Nutcracker - Tues 10/13 - 11am - $4.00 - yes/no - - __ -Mayhem P.. - Thur 01/21 - 9am - $4.00 - yes/no - - __ -Mayhem P.. - Thur 01/21 - 11am - $4.00 - yes/no - - __ -Max and... - Tues 04/21 - 9am - $4.00 - yes/no - - __ A given show may have between 1 and 4 performances, and I figured the best way to approach this was to consider each show time for each show as an entity. There are 19 unique titles, but given different showtimes, it becomes 38 'shows'. I have the shows in an array ($shows), and the details for each show in its own array (eg. $show_01) embedded into the show array. I need to generate a row for each show (so 38 rows), and assign quantity and total input fields a unique name and id. I can't seem to get my foreach loops to work, will PHP parse embedded loops? Here is an example of my embedded arrays: [code=shows.php] $shows = array(); $shows['show_01'] = $show_01; $show_01 = array(); $show_01['title'] = 'Van Cliburn Gold Medal Winner'; $show_01['date'] = 'Tues. 10/13/2009'; $show_01['time'] = '11am'; $show_01['price'] = 4.00; $show_01['soldout'] = 0; //IF THE SHOW SELLS OUT, CHANGE 0 to 1 (without quotations). $shows['show_02'] = $show_02; $show_02 = array(); $show_02['title'] = 'Jack and the Beanstalk'; $show_02['date'] = 'Fri. 10/23/2009'; $show_02['time'] = '11am'; $show_02['price'] = 4.00; $show_02['soldout'] = 0; //IF THE SHOW SELLS OUT, CHANGE 0 to 1 (without quotations). [/code] And here are the foreach loops I'm trying to build the rows with: [code=order.php] ?php foreach ($shows as $key = $value) { foreach ($value as $key2 = $value2) { print ' td bgcolor=#DD'. $value2 .'/td'; } print 'trtd'; print ' td colspan=3 bgcolor=#DDinput name='.$value.'_qty type=text id='.$value.'_qty size=5 //td'; print ' th bgcolor=#DDspan class=style6$/span'; print ' input name='.$value.'_total type=text id='.$value.'_total size=15 maxlength=6 //th'; print ' th bgcolor=#DD class=instructyes/no/th'; print '/tr'; } ? [/code] In case you were wondering why I embedded the foreach statement, I need each array (eg. $show_22) to display in a row, and I need PHP to build as many rows are there are shows. Is this something I need to have in a database to work? Thanks! Embedded loops are OK, actually I don't know a language where you can't do it :) I think that your problem is the $shows array creation, you do this: $shows = array(); $shows['show_01'] = $show_01; $show_01 = array(); Note that you are assigning $show_01 to a key in $shows before creating $show_01, you should first create and fill $show_01 and then assign it to a key in $shows. Hope that helps. Jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Notification system
Also, take a look at Comet Server: http://en.wikipedia.org/wiki/Comet_(programming) I think that Facebook uses that and also Gmail, it tends to consume less resources than periodical ajax calls, the hidden iframe method is simple and works fine. To implement it in PHP you will need to use the flush function to send data a continue processing/polling. Regards, Jonathan 2009/8/7 Phpster phps...@gmail.com: On Aug 2, 2009, at 7:59 AM, Dušan Novaković ndu...@gmail.com wrote: Hi, Does anyone has any idea how to create notification system with combination of php, mysql and javascript. It should be something similar to facebook notification system (when someone make some action it should be automatically reported to other people on system through pop-up menu or something like that). I just need some basic idea how to start or if someone has some example it would be perfect. Thanks, Dusan -- made by Dusan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think you could have some kind if Ajax polling of a php function. To keep the traffic down you could set it to poll once a minute or every 30 seconds or so. Send a simple XML stream that could feed a defined JavaScript function or a bit of xslt for display. Bastien Sent from my iPod -- 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] Trying to create a comment function
[code] comment(test of $newComment); [/code] This rendered a comment that said test of . So I added a \ before the $ to make it display properly, but I was wondering if there was a way that the function could work so that it will display anything you type within the quotes in comment( ). If you want the string to be rendered as it is without variable replacements you can use single quotes, like this: comment('test of $newComment'); That will render exactly this: test of $newComment Hope that helps you. Jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to pass variable argument list in a childconstructor to parent constructor, ideas wanted
I don't understand completely your problem, but think that something like this may help you: ?php class A { function __construct() { var_dump(func_get_args()); } } class B extends A { function __construct() { $args = func_get_args(); call_user_func_array(array(parent, '__construct'), $args); } } $a = new B(1, 2, 3); ? This will output: array(3) { [0]= int(1) [1]= int(2) [2]= int(3) } As expected. The key is using call_user_func_array in combination with func_get_args to call the parent constructor without knowing the number of parameters. Let me know if that helps. Jonathan On Sun, Aug 2, 2009 at 10:40 PM, Ralph Deffkeralph_def...@yahoo.de wrote: problem: __ construct( $something ... variable argument list ){ parent::__construct( ??? ); } I tried with func_get_args, but the problem is that it gives an indexed array back. lets say the argument list is mixed like this: ( string, string, array) func_get_args will give this [0] = string [1] = string [2] = array the parent constructor works also with the func:_get_args function in ordfer to handle variable argument lists if u pass the array from func_get_args the parent constructor will reveive after his func_get_args the following array( [0] = array( [0] = string [1] =string [2] = array( ) ok no problem so far. I thought just strip the key column of the array with a function like this function stripFirstColumn( $_fromThisArray ){ $b = ; $_b = array(); foreach( $_fromThisArray as $value){ if( !is_array($value) ){ if( empty( $b )){ $b = $value; // $_b[$b]=; } else { $_b[$b]=$value; $b = ; } } else { array_push($_b, $value); or $_b[] = $value; } } return $_b; } BUT this results in an arry like this array( string, string, [0] = array( ...)) HOWEVER u can create a propper array for this purpose by writing this : $_a = array( string, string, Array( string = string, string=string)); but there is no way to create the same construction by code unless I use the eval() function what limits me to string objects only. im really a senior coder (since 1982) but this gives me a headace. what do u think? -- 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] This isn't infinitely recursive is it?
Hi, Well, you will have an infinite recursion there if the mapping has cycles, something like A-B, B-C, C-A would generate an invite recursion. Checking if the mapping has cycles is pretty simple: you have to create a directed graph and then go through the graph in DFS marking each visited node, if you have to mark a node already marked then you have a cycle. Tarjan's algorithm does that and a little more, see here: http://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm Hope that helps. Jonathan On Thu, Jul 30, 2009 at 8:38 PM, Matt Neimeyerm...@neimeyer.org wrote: I'm cleaning up some inherited code in our data import module. For a variety of reasons we have to support old standards of the import format. Since some of those old versions were created we have since renamed some fields in our data structure. So right now I've a hard map for some field names... function GetMappedField($Field) { $FieldMap[A] = B; $FieldMap[C] = D; return isset($FieldMap[$Field])?$FieldMap[$Field]:$Field); } But I've just spent a while tracking down a bug where someone mapped A to B and then someone else mapped B to C. I'm thinking of changing the return to... return isset($FieldMap[$Field])?GetMappedField($FieldMap[$Field]):$Field); ...but I'm worried about the recursion. (Which isn't a strength of mine) I don't THINK I need to worry about circular mappings... but I'm not sure how to check for it if I did... Any suggestions? Thanks! Matt -- 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] Getting rid of extra lines
On Wed, Jul 29, 2009 at 4:20 PM, Miller, Teriontmil...@springfi.gannett.com wrote: On 7/29/09 1:45 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: [snip/] Have you thought of just using a regular str_replace() on your code? You can ask it to replace newlines and carriage returns with nothing and see if that fixes you problem? Thanks Ash www.ashleysheridan.co.uk Yep I have tried str_replace to get rid of \n and it didn't work Boss mentioned to explode the var that is full of so many blank lines then put it back together..seems like there has to be an easier way... This is what I tried: $tags = array('\n', 'br'); $sNotes = str_replace($tags,, $notes); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php That didn't work because \n needs to be between instead of ' '. Jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Expand Variables in String
Use eval, like this: eval('$str_expanded = ' . str_replace('', '\\', $str) . ';'); The str_replace is used because you could have a inside $str and it would break the string, if you are sure the $str has no inside you can omit it. Jonathan On Wed, Jul 29, 2009 at 5:43 PM, Daniel Kolbokolb0...@umn.edu wrote: Hello, Is it possible to force a string to expand variable names after the string has been set and before the variable's been defined without having to do a string replace or preg_replace? for example, ?php $str = some string and some \$var plus other stuff; echo $str.br /; $var = Variable Contents; echo $str.br /; $str_expanded = $str;//would like this to expand $var into $str_expanded echo $str_expanded.br /; ? Thanks, dK ` -- 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] Expand Variables in String
On Wed, Jul 29, 2009 at 6:47 PM, Daniel Kolbokolb0...@umn.edu wrote: Jonathan Tapicer wrote: Use eval, like this: eval('$str_expanded = ' . str_replace('', '\\', $str) . ';'); The str_replace is used because you could have a inside $str and it would break the string, if you are sure the $str has no inside you can omit it. Jonathan On Wed, Jul 29, 2009 at 5:43 PM, Daniel Kolbokolb0...@umn.edu wrote: Hello, Is it possible to force a string to expand variable names after the string has been set and before the variable's been defined without having to do a string replace or preg_replace? for example, ?php $str = some string and some \$var plus other stuff; echo $str.br /; $var = Variable Contents; echo $str.br /; $str_expanded = $str;//would like this to expand $var into $str_expanded echo $str_expanded.br /; ? Thanks, dK ` -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php nice! This would allow me to have $str loaded with all kinds of variables and not have to do a str_replace with each (assuming the quote business is cool) Why did you have the double \\? eval('$str_expanded = ' . str_replace('', '\\', $str) . ';'); Isn't the following equivalent? eval('$str_expanded = ' . str_replace('', '\', $str) . ';'); Thanks, dK ` Yes, it's the same, you can use only one \ in that case, sometimes you have to escape if it is followed by a character that needs to be escaped, for example you can't do echo '\'; you should do echo '\\'; Jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Question on code profiling
Just an idea: try using the (microtime(true) - $start) approach in portions of code to try isolate the portion that is taking more time. Sometimes that helps me to find the function that is slowing everything down. Jonathan On Thu, Jul 23, 2009 at 6:18 PM, Andrew Ballardaball...@gmail.com wrote: On Thu, Jul 23, 2009 at 5:10 PM, Ben Dunlapbdun...@agentintellect.com wrote: significant (around 46%), it says they only account for 193ms. What could account for that much difference between what xdebug calculates versus the total elapsed time? Are you counting total elapsed time from the perspective of the web browser? If so, YSlow might be helpful: http://developer.yahoo.com/yslow/ Ben -- Twitter: @bdunlap I'm using YSlow too. Here's the last run I did: YSlow: 4.494 seconds Elapsed (microtime(true) - $start): 3.990795135498 seconds xdebug(WinCacheGrind): 402ms (0.402 seconds) Andrew -- 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] newbie - Is there a calendar module for date entry?
On Tue, Jul 21, 2009 at 10:06 PM, c...@hosting4days.comc...@hosting4days.com wrote: newbie ... - is there a calendar module for date fields? - so that a small calendar pops up - then you can click on a date, to add to a field - like google or yahoo calendars has...? BTW: I saw this - but it doesn't seem to be the right thing ( more meant for Converter issues) for what I'm looking for... http://us2.php.net/manual/en/intro.calendar.php -- Thanks - RevDave Cool @ hosting4days . com [db-lists 09] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php That is javascript thing, not PHP. The Yahoo UI has a nice one, here you have an example: http://developer.yahoo.com/yui/examples/calendar/calcontainer_clean.html, and here the module reference: http://developer.yahoo.com/yui/calendar/ Jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP not running properly
2. Try ?php phpinfo(); ? On Mon, Jul 13, 2009 at 3:47 PM, Togrul Mamedbekovtogrul.mamedbe...@iadc.org wrote: We are running, Windows Server 2003. 1. Changed that 2. ?phpinfo();? Togrul Mamedbekov Marketing Publishing Assistant (Tel: +1-(713)-292-1945 / Fax: +1-(713)-292-1946 http://www.iadc.org http://www.iadc.org/ _ From: Zareef Ahmed [mailto:zareef.ah...@gmail.com] Sent: Friday, July 10, 2009 19:38 To: Bastien Koert Cc: Daniel Brown; Togrul Mamedbekov; php-general@lists.php.net Subject: Re: [PHP] PHP not running properly A quick checklist/todo list : 1. set display_errors=yes in php.ini 2. Make sure you are using full ?php tag to write your script. For a good solutions you should also mentions about your OS/Web Server Zareef Ahmed On Sat, Jul 11, 2009 at 1:53 AM, Bastien Koert phps...@gmail.com wrote: On Fri, Jul 10, 2009 at 4:17 PM, Daniel Browndanbr...@php.net wrote: On Fri, Jul 10, 2009 at 15:44, Togrul Mamedbekovtogrul.mamedbe...@iadc.org wrote: Hello Sir or Madam, We just updated our PHP 5.2 software. And when I try to run the php info script! I get a blank screen! What do you see when you view the source of the page with phpinfo() ? -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Check out our great hosting and dedicated server deals at http://twitter.com/pilotpig -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Your error handling is logging the errors, not displaying them to the screen. Check the php ini file settings for that. -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Zareef Ahmed :: A PHP Developer in India ( Delhi ) Homepage :: http://www.zareef.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache module PHP 5.3 on Windows
What version, VC6 or VC9, TS or NTS? I use VC6 TS and the dll is there... On Wed, Jul 1, 2009 at 7:31 PM, Pablo Viquezpviq...@pabloviquez.com wrote: Hi, I just downloaded the new stable version of PHP 5.3 and I couldnt find the php5apache2_2.dll file. Is the apache module on windows no longer supported? Thanks! -- 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] why is this shell_exec() failing to execute my shell to create a symlink?
Make sure that: - The user executing the script (apache I presume) has execute permissions on ls and ln binaries. - The user executing the script has write persmissions on the directory you are trying to write, and read permissions where you do ls. - This will probably help: put the full binary path for ls and ln, it depends on your OS, but probably they are: /bin/ls and /bin/ln If that doesn't help, can you show us the output? Jonathan On Sat, Jun 27, 2009 at 5:46 PM, Govindagovinda.webdnat...@gmail.com wrote: this code: ?php $testOutput = shell_exec(ls); $where2cd2='testDir/'; $firstCMD=cd $where2cd2; $firstOutput = shell_exec($firstCMD); // $firstOutput = shell_exec('cd testDir/'); $testOutput2 = shell_exec(ls); $secondCMD='ln -s amex_cid.gif myccGOV.gif'; $secondOutput = shell_exec($secondCMD); echo testOutput:brpre$testOutput/pre; echo testOutput2:brpre$testOutput2/prebrfirstCMD=$firstCMDhr; echo firstOutput:brpre$firstOutput/prebrsecondCMD=$secondCMDhr; echo secondOutput:brpre$secondOutput/prebrthirdCMD=$thirdCMDhr; ? is not producing the symlink that I think it should. (?!?) (neither in the dir/ where this script lives, nor in the testDir/ where I am actually trying to create it, on the fly. Server is not in safe mode. Govinda govinda.webdnat...@gmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CSV file
Hi, I don't say that reading the whole file into memory is the best option, I just say that your approach goes to the disk twice, if you have a 100MB file, you are reading 200MB from disk (unless there are some pages cached in physical memory, but you never can know, in the best case all the pages will be cached and you will only read 100MB from disk); and mine, if you have 100MB or more physical memory (available for the script) will only go once. Of course, if you have low physical memory, in the worst case you will end up reading 200MB from disk, because all the pages will go to the pagefile. So, both approaches have a worst case of reading approximately two times the file size from disk and a best case of reading it approximately only once from disk, and since you never know the actual conditions of the memory, you can't say which approach is better without additional information. In the general case, I think that your approach is better for large files and mine for small files, with the size barrier depending on the memory set up and current conditions at the time the script runs. This discussion went in a different direction considering the initial question of Alain, but this could always be useful for someone. Jonathan On Thu, Jun 25, 2009 at 5:37 AM, Richard Heyesrich...@php.net wrote: Hi, Well, you are reading the whole file there (and throwing the data you read not assigning the fgets result to anything), and then to store it in the database you need to read it again, so you read the file twice. It will probably better to store the data you read the first time in an array and then store it in the database, that way you read it only once. No, it's not. If the file is large then you could end up reading megs into memory. If physical memory is low then the pagefile will come into play and you'll get a lot of disk accesses. Reading 1 line at a time is far more efficient and with larger files will be faster. -- Richard Heyes HTML5 graphing: RGraph (www.rgraph.net - updated 20th June) PHP mail: RMail (www.phpguru.org/rmail) PHP datagrid: RGrid (www.phpguru.org/rgrid) PHP Template: RTemplate (www.phpguru.org/rtemplate) PHP SMTP: http://www.phpguru.org/smtp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CSV file
You can read the whole file (file_get_contents) and count the number of \n in it, or read it line by line with fgets and store the lines in an array, and then the number of lines is the count() of the array, and you can use that array to store it in the database. Jonathan On Wed, Jun 24, 2009 at 9:05 AM, Alain Rogerraf.n...@gmail.com wrote: Hi, i would like to import the content of a CSV file into my database. but in order to show a progress bar to user (to let him know that process is still working on) i would like to determine before to start, how many records / lines are in the CSV file. is there a way to do that ? thanks a lot. -- Alain --- Windows XP x64 SP2 / Fedora 10 KDE 4.2 PostgreSQL 8.3.5 / MS SQL server 2005 Apache 2.2.10 PHP 5.2.6 C# 2005-2008 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CSV file
If you want to know how many lines there are *before* inserting to the database, you can't count as you go, you have to either read the file twice or read it once, store it memory in a variable and then insert in the database. On Wed, Jun 24, 2009 at 11:12 AM, Richard Heyesrich...@php.net wrote: Hi, You can read the whole file (file_get_contents) and count the number of \n in it, or read it line by line with fgets and store the lines in an array, and then the number of lines is the count() of the array, and you can use that array to store it in the database. If you have a billion line CSV then speed may suffer somewhat though. Best to still use fgets() or fgetcsv() and count as you go. -- Richard Heyes HTML5 graphing: RGraph (www.rgraph.net - updated 20th June) PHP mail: RMail (www.phpguru.org/rmail) PHP datagrid: RGrid (www.phpguru.org/rgrid) PHP Template: RTemplate (www.phpguru.org/rtemplate) PHP SMTP: http://www.phpguru.org/smtp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CSV file
To do the line count first, you have to read the whole file, how would you do it? On Wed, Jun 24, 2009 at 3:00 PM, Richard Heyesrich...@php.net wrote: Hi, If you want to know how many lines there are *before* inserting to the database, you can't count as you go, you have to either read the file twice or read it once, store it memory in a variable and then insert in the database. Sure you can, simply do the line count first, then the insert. If it's a big file it will still be quicker than reading the whole thing into memory. -- Richard Heyes HTML5 graphing: RGraph (www.rgraph.net - updated 20th June) PHP mail: RMail (www.phpguru.org/rmail) PHP datagrid: RGrid (www.phpguru.org/rgrid) PHP Template: RTemplate (www.phpguru.org/rtemplate) PHP SMTP: http://www.phpguru.org/smtp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CSV file
Well, you are reading the whole file there (and throwing the data you read not assigning the fgets result to anything), and then to store it in the database you need to read it again, so you read the file twice. It will probably better to store the data you read the first time in an array and then store it in the database, that way you read it only once. Anyway, doing it by file size is better. On Wed, Jun 24, 2009 at 6:19 PM, Richard Heyesrich...@php.net wrote: Hi, To do the line count first, you have to read the whole file, how would you do it? Something like this: $fp = fopen('/tmp/foo', 'r'); $count = 0; while (!feof($fp)) { fgets($fp); ++$count; } -- Richard Heyes HTML5 graphing: RGraph (www.rgraph.net - updated 20th June) PHP mail: RMail (www.phpguru.org/rmail) PHP datagrid: RGrid (www.phpguru.org/rgrid) PHP Template: RTemplate (www.phpguru.org/rtemplate) PHP SMTP: http://www.phpguru.org/smtp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pointers for NuSOAP
I've used this one, split in 4 parts: Introduction to NuSOAP: http://www.scottnichol.com/nusoapintro.htm Programming with NuSOAP: http://www.scottnichol.com/nusoapprog.htm Programming with NuSOAP Part 2: http://www.scottnichol.com/nusoapprog2.htm Programming with NuSOAP Using WSDL: http://www.scottnichol.com/nusoapprogwsdl.htm It's nice, and it has lots of working examples. Jonathan On Mon, Jun 22, 2009 at 11:02 AM, Anton Heuschenanto...@gmail.com wrote: Does anyone have any good links to basic and more advanced (and some examples) of NuSOAP and using this ? Would be appreciated to see some recommendations that might of helped others etc. Thank you in advance. -- 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] Problems with APC, possible cache-corruption?
Can you do a phpinfo(); and tell us the value of the setting apc.filters (or every apc.* if you can)? Just curious, but I've seen apps set that setting to avoid APC opcode caching. Jonathan On Sun, Jun 21, 2009 at 8:56 PM, James McLeanjames.mcl...@gmail.com wrote: (Resend from around 1 week ago, because of no responses) Hi All, Over the weekend I setup a test of APC intending to benchmark a Moodle installation with various APC settings to see how well I could get it to perform. I successfully installed Moodle 1.9 and 2.0 under Apache 2.2.3 (installed via apt on Ubuntu 9.04), and with PHP 5.2.9 compiled from source. I should note, that Ubuntu had an older version of PHP installed from apt with Suhosin hardened PHP built in. Moodle 2.0 required at least PHP 5.2.8, so I uninstalled the original PHP module before compiling and installing the 5.2.9. No issues there; PHP worked well and performance was (mostly) acceptable. Progressed onto installing APC, firstly by downloading the APC 3.1.2 source from PECL and following the usual 'phpize, configure, make, make install' process which worked as expected, stop and start Apache and APC was present in my phpinfo();. I started with the reccomended PHP config exept with error_display turned on and E_ALL | E_STRICT enabled, and also the reccomended APC config also. I copied the 'apc.php' from the source tree to my webroot and changed the password as suggested. The issue arose when I attempted to benchmark my Moodle install with 'ab' (I realise it only downloads the single page, but it's good enough for what I need for now though) and the result was no different to before I had installed APC. View the apc.php page, and the only page cached is apc.php itself.. Certainly not what I've witnessed in the past. Then what would happen was if I viewed my seperate info.php page containing simply the opening PHP tag and a single line with phpinfo(); in the file - the cache would appear to reset, and it would firstly not load the info.php into the cache, it would reset the counter on the apc.php file back to 0. Through all of this, there was no errors displayed on the screen and no errors listed in the Apache error log either. Increased the Apache log level up to Debug, and no related information was displayed. Moodle itself worked as expected with no errors, and on a seperate RHEL installation I have Moodle working with APC and it is caching all it's files as expected. At this point, I thought it may be an issue with the module I compiled myself. I backed up the module, and allowed PECL to install the module, it installed 3.0.19. Restarted Apache and verified the version was as PECL had built and installed. This had no effect, and yeilded the same behaviour. I'm stumped as to what the issue could be, however I did see this issue of APC not caching files on an installation of Red Hat Enterprise Linux in the past - however at the time we assumed it was an issue with the framework we were using and due to time constraints simply ran without APC and didn't investigate further. Has anyone seen this issue in the past and perhaps even rectified it? Any information would be appreciated. Cheers, James -- 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: Issue with filter_var and FILTER_VALIDATE_EMAIL
Did you execute the code I sent? Does it give you a false? Jonathan On Fri, Jun 19, 2009 at 12:17 PM, Bastien Koertphps...@gmail.com wrote: Correct, I send the @ Bastien On Friday, June 19, 2009, Jonathan Tapicer tapi...@gmail.com wrote: Works for me: var_dump(filter_var('bastien_k(a)hotmail.com http://hotmail.com', FILTER_VALIDATE_EMAIL) !== false); //replace (a) with @ Gives: bool(true) You are sending an @ instead of at , right? Jonathan On Fri, Jun 19, 2009 at 11:49 AM, Bastien Koertphps...@gmail.com wrote: Hey guys, Running the new version of PHPMailer and my hotmail address fails the validation. Email address is bastien_k at hotmail dot com Any ideas? -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Issue with filter_var and FILTER_VALIDATE_EMAIL
Works for me: var_dump(filter_var('bastien_k(a)hotmail.com', FILTER_VALIDATE_EMAIL) !== false); //replace (a) with @ Gives: bool(true) You are sending an @ instead of at , right? Jonathan On Fri, Jun 19, 2009 at 11:49 AM, Bastien Koertphps...@gmail.com wrote: Hey guys, Running the new version of PHPMailer and my hotmail address fails the validation. Email address is bastien_k at hotmail dot com Any ideas? -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Issue with filter_var and FILTER_VALIDATE_EMAIL
Can you check if the code is using true or false branch of the first if? On Fri, Jun 19, 2009 at 12:56 PM, Bastien Koertphps...@gmail.com wrote: On Fri, Jun 19, 2009 at 11:46 AM, Shawn McKenzienos...@mckenzies.net wrote: Bastien Koert wrote: On Fri, Jun 19, 2009 at 11:20 AM, Jonathan Tapicertapi...@gmail.com wrote: Did you execute the code I sent? Does it give you a false? Jonathan On Fri, Jun 19, 2009 at 12:17 PM, Bastien Koertphps...@gmail.com wrote: Correct, I send the @ Bastien On Friday, June 19, 2009, Jonathan Tapicer tapi...@gmail.com wrote: Works for me: var_dump(filter_var('bastien_k(a)hotmail.com http://hotmail.com', FILTER_VALIDATE_EMAIL) !== false); //replace (a) with @ Gives: bool(true) You are sending an @ instead of at , right? Jonathan On Fri, Jun 19, 2009 at 11:49 AM, Bastien Koertphps...@gmail.com wrote: Hey guys, Running the new version of PHPMailer and my hotmail address fails the validation. Email address is bastien_k at hotmail dot com Any ideas? -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Bastien Cat, the other other white meat this is the relevant function from phpmailer public static function ValidateAddress($address) { if (function_exists('filter_var')) { //Introduced in PHP 5.2 if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) { return false; } else { return true; } } else { return preg_match('/^(?:[\w\!\#\$\%\\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address); } } Is your PHP version = 5.2? If not then the regex will return 1, so in your code don't check for === true. Try == true if that's what you're doing. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php its 5.2.4 -- Bastien Cat, the other other white meat -- 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] Problems with apc extension on wamp server.
Hi, Does the extension appear on a phpinfo()? Seems like the extension isn't loaded. Jonathan On Tue, Jun 16, 2009 at 5:20 PM, Valentinas Bakaitisv.bakai...@gmail.com wrote: Hello! I am trying to track file upload progress using APC extension. However, when trying to use, it gives Fatal error: Call to undefined function apc_fetch() in C:\wamp\www\old\getprogress.php on line 3 I am using WAMP 2.0, with php 5.2.8 APC extension appear on extensions list and is enabled. Any ideas what i am doing wrong? here is the code of getprogress.php: * * $upload = apc_fetch('upload_1'); if ($upload) { if ($upload['done']) $percent = 100; else if ($upload['total'] == 0) $percent = 0; else $percent = $upload['current'] / $upload['total'] * 100; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php