php-general Digest 14 Dec 2013 13:03:52 -0000 Issue 8448
php-general Digest 14 Dec 2013 13:03:52 - Issue 8448 Topics (messages 322570 through 322570): Re: Array + php 322570 by: marco.behnke.biz Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- Maybe ask in english? Bigger target audience El Ale... alexissauc...@gmail.com hat am 14. Dezember 2013 um 01:01 geschrieben: Gente una consulta bastante off topic. Quiero meter un array en una clase y no se como hacerlo se me ocurrio algo asi: ? class Listado_Completo { protected $datosArray =array(0= array( juan, perez, 2352562), 1=array(Marina, Zafon, 32568952), 2= array(fulano, de tal, 32149856); public function Get_Listado_Completo(){ return $this-datosArray; } } ? Pero no puedo llamar a ninguno, alguien sabe como hacerlo? -- Marco Behnke Dipl. Informatiker (FH), SAE Audio Engineer Diploma Zend Certified Engineer PHP 5.3 Tel.: 0174 / 9722336 e-Mail: ma...@behnke.biz Softwaretechnik Behnke Heinrich-Heine-Str. 7D 21218 Seevetal http://www.behnke.biz ---End Message---
php-general Digest 28 Nov 2013 19:11:08 -0000 Issue 8440
php-general Digest 28 Nov 2013 19:11:08 - Issue 8440 Topics (messages 322515 through 322527): Re: echo count(false); == 1 ?! 322515 by: Camilo Sperberg 322516 by: Tsvetan Nikolov 322517 by: Aziz Saleh 322518 by: Tim Behrendsen 322519 by: Daevid Vincent 322521 by: Daevid Vincent 322522 by: David OBrien 322523 by: Tsvetan Nikolov 322524 by: Jim Lucas 322525 by: Sebastian Krebs 322526 by: Tsvetan Nikolov Binded params and MySQL functions 322520 by: Camilo Sperberg Processing the file as its being uploaded 322527 by: Marcelo Taube Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On 27 nov. 2013, at 19:04, Daevid Vincent dae...@daevid.com wrote: Really? 1?? I would have expected 0 or false or something other than positive. *sigh* $ php -a php echo count(false); 1 :-\ Same as with sizeof() btw (which is alias). I've did run into this issue a few years ago and decided that you should check whether the argument you're passing to count() or sizeof() is an array: problem solved. So: $a = $count = false; if (is_array($a)) { $count = count($a); } The 1 result is due to type conversion, well known and discussed within this same mailing list. unreal4u-MBP:~ unreal4u$ php -a Interactive shell php $a = false; php print_r((array)$a); Array ( [0] = ) Greetings. Met vriendelijke groet, Camilo Sperberg W: http://unreal4u.com T: http://twitter.com/unreal4u ---End Message--- ---BeginMessage--- Just think about it. When was the last time you counted something and the result was false? It makes no sense. Logically counting should return negative, 0 or positive value. On Wed, Nov 27, 2013 at 7:04 PM, Daevid Vincent dae...@daevid.com wrote: Really? 1?? I would have expected 0 or false or something other than positive. *sigh* $ php -a php echo count(false); 1 :-\ ---End Message--- ---BeginMessage--- On Wed, Nov 27, 2013 at 1:04 PM, Daevid Vincent dae...@daevid.com wrote: Really? 1?? I would have expected 0 or false or something other than positive. *sigh* $ php -a php echo count(false); 1 :-\ http://us3.php.net/count The manual is a great place to figure out why things happen a certain way. Aziz ---End Message--- ---BeginMessage--- Why? count() counts the number of objects in an array. Since we're giving it a scalar value, then it's one value. Would you expect count(array(false)) to give a zero or a false? How about count(0) versus count(1)? You might be confusing false and null, which are not the same thing. False is a boolean number, null is an empty set. You'll note that count(null) gives a zero. This is actually one of the cases where php is doing something logical. :) Tim On 11/27/2013 10:04 AM, php-general-digest-h...@lists.php.net wrote: Really? 1?? I would have expected 0 or false or something other than positive.*sigh* $ php -a php echo count(false); 1 ---End Message--- ---BeginMessage--- -Original Message- From: Aziz Saleh [mailto:azizsa...@gmail.com] Sent: Wednesday, November 27, 2013 10:15 AM To: Daevid Vincent Cc: php-gene...@lists.php.net Subject: Re: [PHP] echo count(false); == 1 ?! On Wed, Nov 27, 2013 at 1:04 PM, Daevid Vincent dae...@daevid.com wrote: Really? 1?? I would have expected 0 or false or something other than positive. *sigh* $ php -a php echo count(false); 1 :-\ http://us3.php.net/count The manual is a great place to figure out why things happen a certain way. The manual page does not explain WHY that logic is used and even inconsistent since null returns 0. It only says that it does return 1. ---End Message--- ---BeginMessage--- -Original Message- From: Tsvetan Nikolov [mailto:live.websc...@gmail.com] Sent: Wednesday, November 27, 2013 10:15 AM To: Daevid Vincent Cc: PHP-General Subject: Re: [PHP] echo count(false); == 1 ?! Just think about it. When was the last time you counted something and the result was false? It makes no sense. Logically counting should return negative, 0 or positive value. Well in my case I have a method that populates a property. The property starts out as null (since it was never loaded). If there is an error, the method returns false, otherwise it fills the array. We could argue about flow/logic/etc. and how to fix my code. But logically, given how null/false/0 are usually treated, almost interchangeably, such as $foo = false; $foo = 0; $foo = null; If (!foo) All do the same thing It would stand to reason that count() would return 0 for anything that isn't an array
php-general Digest 24 Nov 2013 20:39:26 -0000 Issue 8435
php-general Digest 24 Nov 2013 20:39:26 - Issue 8435 Topics (messages 322493 through 322495): Re: DSN for MS SQL Server Express 2005 322493 by: marco.behnke.biz 322494 by: Tomás Corrales Lemoine PHP tutorial 322495 by: Martin Christian Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- Have you tried this http://php.net/manual/de/ref.pdo-dblib.php#66917 Tomás Corrales Lemoine to...@hog.ecasa.avianet.cu hat am 23. November 2013 um 21:21 geschrieben: Greetings all, Please, I'm trying to connect to a MS SQL Server Express 2005 using PDO for ODBC, but I need the DSN string. I tried with: $dsn = 'odbc:DRIVER={SQL Server};HOSTNAME=CCTPV608\SQLEXPRESS;DATABASE=db_ibripos'; but it doesn't work. Thanks!!! Tomas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Marco Behnke Dipl. Informatiker (FH), SAE Audio Engineer Diploma Zend Certified Engineer PHP 5.3 Tel.: 0174 / 9722336 e-Mail: ma...@behnke.biz Softwaretechnik Behnke Heinrich-Heine-Str. 7D 21218 Seevetal http://www.behnke.biz ---End Message--- ---BeginMessage--- Thanks, Marco. I found it: $dsn = 'odbc:Driver=SQL Server;Server= CCTPV608\SQLEXPRESS;Database=db_ibripos'; Tomas -Mensaje original- De: ma...@behnke.biz [mailto:ma...@behnke.biz] Enviado el: Sábado, 23 de Noviembre de 2013 5:36 pm Para: php-gene...@lists.php.net; Tomás Corrales Lemoine Asunto: Re: [PHP] DSN for MS SQL Server Express 2005 Have you tried this http://php.net/manual/de/ref.pdo-dblib.php#66917 Tomás Corrales Lemoine to...@hog.ecasa.avianet.cu hat am 23. November 2013 um 21:21 geschrieben: Greetings all, Please, I'm trying to connect to a MS SQL Server Express 2005 using PDO for ODBC, but I need the DSN string. I tried with: $dsn = 'odbc:DRIVER={SQL Server};HOSTNAME=CCTPV608\SQLEXPRESS;DATABASE=db_ibripos'; but it doesn't work. Thanks!!! Tomas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Marco Behnke Dipl. Informatiker (FH), SAE Audio Engineer Diploma Zend Certified Engineer PHP 5.3 Tel.: 0174 / 9722336 e-Mail: ma...@behnke.biz Softwaretechnik Behnke Heinrich-Heine-Str. 7D 21218 Seevetal http://www.behnke.biz -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- Hi, I've written a PHP DB/Template tutorial at: http://christianix.de/php-tutor/index.html I hope it will be useful to someone. Regards, Martin ---End Message---
php-general Digest 21 Nov 2013 07:23:33 -0000 Issue 8431
php-general Digest 21 Nov 2013 07:23:33 - Issue 8431 Topics (messages 322475 through 322478): Re: form submit send SMS 322475 by: Camilo Sperberg 322476 by: Bálint Horváth 322477 by: Jonathan Sundquist An upload that was, but now isn't... 322478 by: PHP List Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On 19 Nov 2013, at 16:15, Gregor Leskovšek legr...@gmail.com wrote: Is it possible and how can I send an SMS with data from a submitted web form? Using Linux, Kubuntu LTS. Thanks in advance, Gregor ♥♥♥ When the sun rises I receive and when it sets I forgive! ♥♥♥ http://gleskove.userworld.com/ http://moj.skavt.net/gleskovs/♥ Always, Gregor Leskovšek Yes, it is possible. It has a certain degree of difficulty, but if you outsource the service, it is very cheap and easy. If you google on php send sms you can learn a lot more than what I'm able to write about the subject. Greetings.---End Message--- ---BeginMessage--- For example using [GW]ammu is a simple way on Linux, see http://wammu.eu/. It has a web interface too. It's easy to call from PHP using exec(). Pre-written classes also available: http://www.phpclasses.org/package/3865-PHP-Send-and-receive-SMS-messages-using-Gammu.html Or it's possible to make a Perl script handles the GSM device. I really love this solution. http://search.cpan.org/dist/Device-Gsm/Gsm.pm Good ways for own GSM modem. ...but there are lots of SMS gateway APIs. Some of them with free test period and even could be cheap in case of bulk SMS sending. *--Bálint Horváth* On Tue, Nov 19, 2013 at 4:54 PM, Camilo Sperberg unrea...@gmail.com wrote: On 19 Nov 2013, at 16:15, Gregor Leskovšek legr...@gmail.com wrote: Is it possible and how can I send an SMS with data from a submitted web form? Using Linux, Kubuntu LTS. Thanks in advance, Gregor ♥♥♥ When the sun rises I receive and when it sets I forgive! ♥♥♥ http://gleskove.userworld.com/ http://moj.skavt.net/gleskovs/♥ Always, Gregor Leskovšek Yes, it is possible. It has a certain degree of difficulty, but if you outsource the service, it is very cheap and easy. If you google on php send sms you can learn a lot more than what I'm able to write about the subject. Greetings. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- If you have the budget use a professional service such as Twilio. Their api is very easy to use and quick to set up. I would also avoid using any type of exec() function unless you are doing a very good job of checking to see what is being executed. You would be opening yourself up the a number of security attacks. On Tue, Nov 19, 2013 at 10:44 AM, Bálint Horváth hbal...@gmail.com wrote: For example using [GW]ammu is a simple way on Linux, see http://wammu.eu/. It has a web interface too. It's easy to call from PHP using exec(). Pre-written classes also available: http://www.phpclasses.org/package/3865-PHP-Send-and-receive-SMS-messages-using-Gammu.html Or it's possible to make a Perl script handles the GSM device. I really love this solution. http://search.cpan.org/dist/Device-Gsm/Gsm.pm Good ways for own GSM modem. ...but there are lots of SMS gateway APIs. Some of them with free test period and even could be cheap in case of bulk SMS sending. *--Bálint Horváth* On Tue, Nov 19, 2013 at 4:54 PM, Camilo Sperberg unrea...@gmail.com wrote: On 19 Nov 2013, at 16:15, Gregor Leskovšek legr...@gmail.com wrote: Is it possible and how can I send an SMS with data from a submitted web form? Using Linux, Kubuntu LTS. Thanks in advance, Gregor ♥♥♥ When the sun rises I receive and when it sets I forgive! ♥♥♥ http://gleskove.userworld.com/ http://moj.skavt.net/gleskovs/♥ Always, Gregor Leskovšek Yes, it is possible. It has a certain degree of difficulty, but if you outsource the service, it is very cheap and easy. If you google on php send sms you can learn a lot more than what I'm able to write about the subject. Greetings. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- Hi, Fair warning - not 100% PHP based question coming, but since it's almost Friday, I thought I'd risk it. My wife posed a question to me today for which I didn't have a very good answer and thought I'd check the hive mind here. At work, she uses a certain service to upload PDF files, until about 3 days ago this worked well enough. However, in the past three days when she tries to upload
php-general Digest 17 Nov 2013 22:02:38 -0000 Issue 8428
php-general Digest 17 Nov 2013 22:02:38 - Issue 8428 Topics (messages 322467 through 322468): Re: save $_GLOBALS to a database field 322467 by: Robert Cummings 322468 by: marco.behnke.biz Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- You have other problems if you think base64_encode is the solution to the hassle of escaping your query properly. Cheers, Rob. On 13-11-15 08:52 PM, Tamara Temple wrote: Or run it through base64_encode after json_encode, never have to worry about quotes and things. On Nov 14, 2013, at 4:38 PM, Shawn McKenzie sh...@mckenzies.net wrote: If you are for example saving the entire $_POST array in a text field of your DB, then just serailize() it or json_encode() it and run it through the appropriate real_escape_string() function if you're not using prepared statements or other custom escaping. On Thu, Nov 14, 2013 at 3:40 PM, Ramiro Barrantes ram...@precisionbioassay.com wrote: Hello, I would like to record, on a database, the global variables $_POST and $_SERVER for each action that the user does that involves a modification of the database. I am just saving, say $_POST or $_SERVER (and others), as a string and putting it in a field on the database. However, when I try to get the info out of the database and access it as an XML (using the DOMDocument library) it becomes a pain to handle due to all the special characters (I think, as I haven't been able to get it to work), for example: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20100101 Firefox/16.0 (I seem to need to replace all the /s) It's a pain, and I would like not to have to replace special characters with preg_replace if possible. Any suggestions? I have been having a lot of trouble with this. Thanks in advance, Ramiro -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. ---End Message--- ---BeginMessage--- There is no need for escaping if you use prepared statements, which everyone should do. Tamara Temple tamouse.li...@gmail.com hat am 16. November 2013 um 02:52 geschrieben: Or run it through base64_encode after json_encode, never have to worry about quotes and things. On Nov 14, 2013, at 4:38 PM, Shawn McKenzie sh...@mckenzies.net wrote: If you are for example saving the entire $_POST array in a text field of your DB, then just serailize() it or json_encode() it and run it through the appropriate real_escape_string() function if you're not using prepared statements or other custom escaping. On Thu, Nov 14, 2013 at 3:40 PM, Ramiro Barrantes ram...@precisionbioassay.com wrote: Hello, I would like to record, on a database, the global variables $_POST and $_SERVER for each action that the user does that involves a modification of the database. I am just saving, say $_POST or $_SERVER (and others), as a string and putting it in a field on the database. However, when I try to get the info out of the database and access it as an XML (using the DOMDocument library) it becomes a pain to handle due to all the special characters (I think, as I haven't been able to get it to work), for example: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20100101 Firefox/16.0 (I seem to need to replace all the /s) It's a pain, and I would like not to have to replace special characters with preg_replace if possible. Any suggestions? I have been having a lot of trouble with this. Thanks in advance, Ramiro -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Marco Behnke Dipl. Informatiker (FH), SAE Audio Engineer Diploma Zend Certified Engineer PHP 5.3 Tel.: 0174 / 9722336 e-Mail: ma...@behnke.biz Softwaretechnik Behnke Heinrich-Heine-Str. 7D 21218 Seevetal http://www.behnke.biz ---End Message---
php-general Digest 14 Nov 2013 10:44:41 -0000 Issue 8425
php-general Digest 14 Nov 2013 10:44:41 - Issue 8425 Topics (messages 322447 through 322454): Re: regarding print_r() 322447 by: George Wilson 322448 by: Shawn McKenzie 322452 by: Tamara Temple 322453 by: Sachin Raut Date sequence calculating 322449 by: Ron Piggott 322450 by: Jonathan Sundquist 322451 by: George Wilson PHP 5.5.6 has been released 322454 by: Julien Pauli Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- That is insanely awesome! Thanks for passing that along. On Tue, Nov 12, 2013 at 10:17 AM, Phred White phpl...@planetphred.comwrote: My fave: echo 'textarea . print_r($a,true) . '/textarea'; - print_r's indents etc. maintained (as in pre) - default textarea is small and consistent size, doesn't disrupt layout even for massive arrays - you can resize at will (at least in Safari) - you can have multiples for complex problem solving and view them next to each other! On Nov 10, 2013, at 8:15 AM, Ken Robinson wrote: A nice application of the second parameter is to get the output of print_r formatted on your web page: echo 'pre' . print_r($ary, true) . '/pre'; much easier to read... Ken At 08:26 AM 11/10/2013, Sachin Raut wrote: Thank you Mr.Sperberg for telling about 2nd parameter. Really appreciate your help. Thanks Sachin Raut On Sun, Nov 10, 2013 at 2:39 PM, Camilo Sperberg unrea...@gmail.com wrote: On 10 nov. 2013, at 06:24, Sachin Raut imsachinr...@gmail.com wrote: Issue resolved. I didn't notice that i was passing print_r() function to echo. Silly mistake. Thanks Sachin Raut On Sun, Nov 10, 2013 at 10:39 AM, Sachin Raut imsachinr...@gmail.com wrote: Hello, I am trying to print following array using print_r(), but it appends number 1 to the output. Can someone pls tell me what is the issue here or is there any setting i need to do in PHP. Thanks Sachin Raut ?php $a[]=Paris; $a[]=London; echo print_r($a); ? Output : Array ( [0] = Paris [1] = London ) 1 I think everyone on this list has made that same mistake once. Just as a sidenote, you can pass true as second parameter to have print_r return the contents instead of printing them directly. It comes in very handy in case you need to escape characters before printing or manipulate the string before you want to print. Greetings. Met vriendelijke groet, Camilo Sperberg W: http://unreal4u.com T: http://twitter.com/unreal4u -- 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 ---End Message--- ---BeginMessage--- FWIW, I use var_export() since it is valid PHP code and can be copy/pasted etc. On Sat, Nov 9, 2013 at 11:09 PM, Sachin Raut imsachinr...@gmail.com wrote: Hello, I am trying to print following array using print_r(), but it appends number 1 to the output. Can someone pls tell me what is the issue here or is there any setting i need to do in PHP. Thanks Sachin Raut ?php $a[]=Paris; $a[]=London; echo print_r($a); ? Output : Array ( [0] = Paris [1] = London ) 1 ---End Message--- ---BeginMessage--- + for var_export()! + for textarea! On Nov 12, 2013, at 1:17 PM, Shawn McKenzie sh...@mckenzies.net wrote: FWIW, I use var_export() since it is valid PHP code and can be copy/pasted etc. On Sat, Nov 9, 2013 at 11:09 PM, Sachin Raut imsachinr...@gmail.com wrote: Hello, I am trying to print following array using print_r(), but it appends number 1 to the output. Can someone pls tell me what is the issue here or is there any setting i need to do in PHP. Thanks Sachin Raut ?php $a[]=Paris; $a[]=London; echo print_r($a); ? Output : Array ( [0] = Paris [1] = London ) 1 ---End Message--- ---BeginMessage--- Wow...didn't know about textarea var_export(). Really awesome. thanks Sachin Raut On Wed, Nov 13, 2013 at 4:30 AM, Tamara Temple tamouse.li...@gmail.comwrote: + for var_export()! + for textarea! On Nov 12, 2013, at 1:17 PM, Shawn McKenzie sh...@mckenzies.net wrote: FWIW, I use var_export() since it is valid PHP code and can be copy/pasted etc. On Sat, Nov 9, 2013 at 11:09 PM, Sachin Raut imsachinr...@gmail.com wrote: Hello, I am trying to print following array using print_r(), but it appends number 1
[PHP] Re: How to download a multi-part file at the server side?
I just came across http://www.w3schools.com/php/php_file_upload.asp, and tested it.. It works fine, when the file is uploaded via a form. It does seem that the client-method might indeed play a role. Here is my Java code for uploading the file :: ### HttpClient httpclient = new DefaultHttpClient(); httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); HttpPost httppost = new HttpPost(URL); File file = new File(/path/to/png/file.png); // Send the image-file data as a Multipart-data. MultipartEntity mpEntity = new MultipartEntity(); ContentBody cbFile = new FileBody(file, image/png); mpEntity.addPart(userfile, cbFile); httppost.setEntity(mpEntity); HttpResponse response = httpclient.execute(httppost); ### Any ideas if making a change at the client (Java) OR/AND server (PHP) might do the trick? On Sat, Nov 2, 2013 at 6:06 PM, Ajay Garg ajaygargn...@gmail.com wrote: Hi all. I intend to implement a use-case, wherein the client uploads a file in multi-part format, and the server then stores the file in a mysql database (after downloading it at the server side). I have been unable to find any immediate answers through googling; I will be grateful if someone could start me in a direction to achieve the downloading at server via php requirement. (Don't think it should matter, but I use Java to upload a file in multi-part format). I will be grateful for some pointers. Thanks in advance Thanks and Regards, Ajay -- Regards, Ajay
Re: [PHP] How to download a multi-part file at the server side?
Hi Aziz. Thanks for the reply. Unfortunately, making the change suggested by you does not make any difference :( Sorry, Thanks and Regards On Sat, Nov 2, 2013 at 10:51 PM, Aziz Saleh azizsa...@gmail.com wrote: On Sat, Nov 2, 2013 at 1:03 PM, Ajay Garg ajaygargn...@gmail.com wrote: Hi all. 1. I could have the proper $_FILES[userfile][name] been echoed back, by replacing ContentBody cbFile = new FileBody(file, image/png); with ContentBody cbFile = new FileBody(file); 2. However, now I am stuck with the following server-side code. No matter what I do, I always get a no echoed back (specifying that the file is not copied to its target place). ### ?php $headers = apache_request_headers(); foreach ($headers as $header = $value) { if($header == active_window_title) { $active_window_title = $value; break; } } $target_path = /home/ajay/success.png; move_uploaded_file($_FILES[userfile][tmp_name], $target_path); if(file_exists($target_path)) { echo yes; } else { echo no; } echo \n . $_FILES[userfile][name]; # I always get the proper file-name echoed. ? Any ideas what stupidity am I making in the PHP code? On Sat, Nov 2, 2013 at 7:13 PM, Ajay Garg ajaygargn...@gmail.com wrote: Does not work :( As per the code-snippet I pasted, $_FILES[userfile][name] should be /path/to/png/file.png However, $_FILES[userfile][name] is empty. On Sat, Nov 2, 2013 at 6:59 PM, Shawn McKenzie sh...@mckenzies.net wrote: Fairly easy: http://www.php.net/manual/en/features.file-upload.post-method.php On Sat, Nov 2, 2013 at 7:36 AM, Ajay Garg ajaygargn...@gmail.com wrote: Hi all. I intend to implement a use-case, wherein the client uploads a file in multi-part format, and the server then stores the file in a mysql database (after downloading it at the server side). I have been unable to find any immediate answers through googling; I will be grateful if someone could start me in a direction to achieve the downloading at server via php requirement. (Don't think it should matter, but I use Java to upload a file in multi-part format). I will be grateful for some pointers. Thanks in advance Thanks and Regards, Ajay -- Regards, Ajay -- Regards, Ajay Ajay, try changing your mpEntity to: new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE) See if it makes a difference. Ajay
Re: [PHP] How to download a multi-part file at the server side?
On Sat, Nov 2, 2013 at 1:03 PM, Ajay Garg ajaygargn...@gmail.com wrote: Hi all. 1. I could have the proper $_FILES[userfile][name] been echoed back, by replacing ContentBody cbFile = new FileBody(file, image/png); with ContentBody cbFile = new FileBody(file); 2. However, now I am stuck with the following server-side code. No matter what I do, I always get a no echoed back (specifying that the file is not copied to its target place). ### ?php $headers = apache_request_headers(); foreach ($headers as $header = $value) { if($header == active_window_title) { $active_window_title = $value; break; } } $target_path = /home/ajay/success.png; move_uploaded_file($_FILES[userfile][tmp_name], $target_path); if(file_exists($target_path)) { echo yes; } else { echo no; } echo \n . $_FILES[userfile][name]; # I always get the proper file-name echoed. ? Any ideas what stupidity am I making in the PHP code? On Sat, Nov 2, 2013 at 7:13 PM, Ajay Garg ajaygargn...@gmail.com wrote: Does not work :( As per the code-snippet I pasted, $_FILES[userfile][name] should be /path/to/png/file.png However, $_FILES[userfile][name] is empty. On Sat, Nov 2, 2013 at 6:59 PM, Shawn McKenzie sh...@mckenzies.net wrote: Fairly easy: http://www.php.net/manual/en/features.file-upload.post-method.php On Sat, Nov 2, 2013 at 7:36 AM, Ajay Garg ajaygargn...@gmail.com wrote: Hi all. I intend to implement a use-case, wherein the client uploads a file in multi-part format, and the server then stores the file in a mysql database (after downloading it at the server side). I have been unable to find any immediate answers through googling; I will be grateful if someone could start me in a direction to achieve the downloading at server via php requirement. (Don't think it should matter, but I use Java to upload a file in multi-part format). I will be grateful for some pointers. Thanks in advance Thanks and Regards, Ajay -- Regards, Ajay -- Regards, Ajay Ajay, try changing your mpEntity to: new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE) See if it makes a difference.
php-general Digest 31 Oct 2013 07:14:27 -0000 Issue 8414
php-general Digest 31 Oct 2013 07:14:27 - Issue 8414 Topics (messages 322393 through 322396): Re: Starting with XML 322393 by: Stuart Dallas Re: Apache/PHP exploit 322394 by: Tamara Temple 322395 by: Joshua Kehn 322396 by: Camilo Sperberg Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On 30 Oct 2013, at 13:43, leam hall leamh...@gmail.com wrote: I'm trying to work on an XML document and turn it into something I can put into a database or array. Am getting stuck as I try to learn the PHP stuff needed for XML. What I have so far is just: $xml = simplexml_load_file('my-file.xml'); $status = $xml-status; echo status is $status.\n; $href = $xml-reference-href; echo href is $href.\n; Which gives: status is accepted. href is . If I do: print_r($xml); It starts out with: SimpleXMLElement Object ( [@attributes] = Array ( [id] = My_Info ) [status] = accepted [title] = Nice long string title [reference] = SimpleXMLElement Object ( [@attributes] = Array ( [href] = http://www.example.com ) ) How do I reference the nested objects? The file is fairly long and seems deeply nested. The value you’re trying to retrieve is an attribute, and can be accessed using the attributes method: http://php.net/simplexmlelement.attributes -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/---End Message--- ---BeginMessage--- This info cruised by my screen from G+ today, thought I’d at least pass it along: http://www.exploit-db.com/exploits/29290/ ---End Message--- ---BeginMessage--- Summary for those on phones? Best, -Josh ___ http://byjakt.com Currently mobile On Oct 30, 2013, at 8:37 PM, Tamara Temple tamouse.li...@gmail.com wrote: This info cruised by my screen from G+ today, thought I’d at least pass it along: http://www.exploit-db.com/exploits/29290/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- On 31 okt. 2013, at 01:55, Joshua Kehn j...@kehn.us wrote: Summary for those on phones? Best, -Josh ___ http://byjakt.com Currently mobile On Oct 30, 2013, at 8:37 PM, Tamara Temple tamouse.li...@gmail.com wrote: This info cruised by my screen from G+ today, thought I’d at least pass it along: http://www.exploit-db.com/exploits/29290/ -- 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 It opens a shell on default ubuntu/debian lamp's, compromising several versions of php, including the 5.5 branch. Sent from my iPhone 6 Beta [Confidential use only]---End Message---
Re: [PHP] preg_replace
Hi, On Fri, Nov 01, 2013 at 11:06:29AM -0400, leam hall wrote: Despite my best efforts to ignore preg_replace... Why? :) PHP Warning: preg_replace(): Delimiter must not be alphanumeric or backslash Thoughts? You are just using it wrong. http://us2.php.net/manual/en/regexp.reference.delimiters.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] FYI: Apache/PHP exploit
On 31 okt. 2013, at 01:55, Joshua Kehn j...@kehn.us wrote: Summary for those on phones? Best, -Josh ___ http://byjakt.com Currently mobile On Oct 30, 2013, at 8:37 PM, Tamara Temple tamouse.li...@gmail.com wrote: This info cruised by my screen from G+ today, thought I’d at least pass it along: http://www.exploit-db.com/exploits/29290/ -- 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 It opens a shell on default ubuntu/debian lamp's, compromising several versions of php, including the 5.5 branch. Sent from my iPhone 6 Beta [Confidential use only] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
php-general Digest 26 Oct 2013 08:44:06 -0000 Issue 8410
php-general Digest 26 Oct 2013 08:44:06 - Issue 8410 Topics (messages 322376 through 322384): Re: framework or not 322376 by: Stuart Dallas 322378 by: Robert Cummings 322380 by: Stuart Dallas 322381 by: David Harkness News Regard Attack; Announcing Official php.net Twitter Account 322377 by: Daniel Brown 322379 by: Tedd Sperling I am puzzled. Error on one site, no error on the other 322382 by: Stephen 322383 by: Aziz Saleh Does a call to trigger_error ever return? 322384 by: Peter West Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On 25 Oct 2013, at 15:01, Robert Cummings rob...@interjinn.com wrote: On 13-10-24 09:41 PM, Larry Garfield wrote: On 10/23/2013 08:51 AM, Jay Blanchard wrote: [snip] a bitter rant[/snip] Dang Larry - bad night? That wasn't a bitter rant. You haven't seen me bitter. :-) That was tough love to the OP. I don't see a reason to pussyfoot around the original question, which is one that comes up about once a month. The answer is always the same: How much is your time worth? Basic math... Life: finite Time: infinite finite / infinite = 0 *sniffle* Who's valuation of your time actually matters? Yours, and yours alone. Therefore: Life: n years Time I can benefit from my life: n years n years / n years = 1 *hoorah* Your time is the most precious commodity you have. Whether you use a framework or not you will (hopefully) reuse code between projects. If you choose to make part of that reused code one of the many frameworks that exist, you need only do one thing to ensure it continues to be worth using: how much of your time do you spend battling against the restrictions of the framework? If that's sufficiently low then using that framework is probably a good thing. If a significant portion of your time is spent battling the framework it's time to make a change. Also remember that the only person who can truthfully judge whether you're wasting time is you, unless you earn money by selling your time to someone else in which case they have some right to decide what constitutes a waste of the time for which they're paying. I found the experience of writing my own framework to be hugely beneficial to my future productivity, but I might have struggled to justify spending the extra time it took to my employer at the time. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ ---End Message--- ---BeginMessage--- On 13-10-25 10:17 AM, Stuart Dallas wrote: On 25 Oct 2013, at 15:01, Robert Cummings rob...@interjinn.com wrote: On 13-10-24 09:41 PM, Larry Garfield wrote: On 10/23/2013 08:51 AM, Jay Blanchard wrote: [snip] a bitter rant[/snip] Dang Larry - bad night? That wasn't a bitter rant. You haven't seen me bitter. :-) That was tough love to the OP. I don't see a reason to pussyfoot around the original question, which is one that comes up about once a month. The answer is always the same: How much is your time worth? Basic math... Life: finite Time: infinite finite / infinite = 0 *sniffle* Who's valuation of your time actually matters? Yours, and yours alone. Therefore: Life: n years Time I can benefit from my life: n years n years / n years = 1 *hoorah* Your time is the most precious commodity you have. Whether you use a framework or not you will (hopefully) reuse code between projects. If you choose to make part of that reused code one of the many frameworks that exist, you need only do one thing to ensure it continues to be worth using: how much of your time do you spend battling against the restrictions of the framework? If that's sufficiently low then using that framework is probably a good thing. If a significant portion of your time is spent battling the framework it's time to make a change. Also remember that the only person who can truthfully judge whether you're wasting time is you, unless you earn money by selling your time to someone else in which case they have some right to decide what constitutes a waste of the time for which they're paying. I found the experience of writing my own framework to be hugely beneficial to my future productivity, but I might have struggled to justify spending the extra time it took to my employer at the time. You stripped away the context of my response. By removing the evil grin you made it look like I was serious. You should be a reporter ;) Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s
php-general Digest 25 Oct 2013 14:01:46 -0000 Issue 8409
php-general Digest 25 Oct 2013 14:01:46 - Issue 8409 Topics (messages 322370 through 322375): Persistent connections 322370 by: Nibin V M 322371 by: Stuart Dallas 322372 by: Nibin V M 322373 by: Stuart Dallas 322374 by: Nibin V M Re: framework or not 322375 by: Robert Cummings Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- Hello, I have been reading docs and many are telling that persistent connections are kept open indefinitely. But I found in PHP docs that it will not close after script execution like requesting a page; so should it close after the request is over? So when exactly a persistent connection should close? Please advice. -- Regards Nibin. ---End Message--- ---BeginMessage--- On 25 Oct 2013, at 11:10, Nibin V M nibi...@gmail.com wrote: I have been reading docs and many are telling that persistent connections are kept open indefinitely. But I found in PHP docs that it will not close after script execution like requesting a page; so should it close after the request is over? So when exactly a persistent connection should close? Please advice. A persistent connection is closed when the PHP process ends, or it gets disconnected by the server-side or due to a network error. Attempting to explicitly close a persistent connection will do nothing without complaining. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ ---End Message--- ---BeginMessage--- Thank you for the quick response Stuart...one more doubt..at http://php.net/manual/en/features.persistent-connections.php they states = This means that when the same client makes a second request to the server, it may be served by a different child process than the first time. When opening a persistent connection, every following page requesting SQL services can reuse the same established connection to the SQL server = Is the persistent connection pool is re-used between apache child processes ? On Fri, Oct 25, 2013 at 3:54 PM, Stuart Dallas stu...@3ft9.com wrote: On 25 Oct 2013, at 11:10, Nibin V M nibi...@gmail.com wrote: I have been reading docs and many are telling that persistent connections are kept open indefinitely. But I found in PHP docs that it will not close after script execution like requesting a page; so should it close after the request is over? So when exactly a persistent connection should close? Please advice. A persistent connection is closed when the PHP process ends, or it gets disconnected by the server-side or due to a network error. Attempting to explicitly close a persistent connection will do nothing without complaining. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- Regards Nibin. http://TechsWare.in ---End Message--- ---BeginMessage--- On 25 Oct 2013, at 12:51, Nibin V M nibi...@gmail.com wrote: Thank you for the quick response Stuart...one more doubt..at http://php.net/manual/en/features.persistent-connections.php they states = This means that when the same client makes a second request to the server, it may be served by a different child process than the first time. When opening a persistent connection, every following page requesting SQL services can reuse the same established connection to the SQL server = Is the persistent connection pool is re-used between apache child processes ? No, connections are not shared between PHP processes. Nothing is shared between PHP processes. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ On Fri, Oct 25, 2013 at 3:54 PM, Stuart Dallas stu...@3ft9.com wrote: On 25 Oct 2013, at 11:10, Nibin V M nibi...@gmail.com wrote: I have been reading docs and many are telling that persistent connections are kept open indefinitely. But I found in PHP docs that it will not close after script execution like requesting a page; so should it close after the request is over? So when exactly a persistent connection should close? Please advice. A persistent connection is closed when the PHP process ends, or it gets disconnected by the server-side or due to a network error. Attempting to explicitly close a persistent connection will do nothing without complaining. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- Regards Nibin. http://TechsWare.in ---End Message--- ---BeginMessage--- ok..thank you very much Stuart :) On Fri, Oct 25, 2013 at 6:02 PM, Stuart Dallas stu...@3ft9.com wrote: On 25 Oct 2013, at 12:51, Nibin V M nibi...@gmail.com wrote: Thank you for the quick response Stuart...one more doubt..at http://php.net/manual/en
Re: [PHP] Persistent connections
On 25 Oct 2013, at 12:51, Nibin V M nibi...@gmail.com wrote: Thank you for the quick response Stuart...one more doubt..at http://php.net/manual/en/features.persistent-connections.php they states = This means that when the same client makes a second request to the server, it may be served by a different child process than the first time. When opening a persistent connection, every following page requesting SQL services can reuse the same established connection to the SQL server = Is the persistent connection pool is re-used between apache child processes ? No, connections are not shared between PHP processes. Nothing is shared between PHP processes. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ On Fri, Oct 25, 2013 at 3:54 PM, Stuart Dallas stu...@3ft9.com wrote: On 25 Oct 2013, at 11:10, Nibin V M nibi...@gmail.com wrote: I have been reading docs and many are telling that persistent connections are kept open indefinitely. But I found in PHP docs that it will not close after script execution like requesting a page; so should it close after the request is over? So when exactly a persistent connection should close? Please advice. A persistent connection is closed when the PHP process ends, or it gets disconnected by the server-side or due to a network error. Attempting to explicitly close a persistent connection will do nothing without complaining. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- Regards Nibin. http://TechsWare.in -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Persistent connections
Hello, I have been reading docs and many are telling that persistent connections are kept open indefinitely. But I found in PHP docs that it will not close after script execution like requesting a page; so should it close after the request is over? So when exactly a persistent connection should close? Please advice. -- Regards Nibin.
Re: [PHP] I am puzzled. Error on one site, no error on the other
On Fri, Oct 25, 2013 at 8:27 PM, Stephen stephe...@rogers.com wrote: Problem Situation I have two web sites on the same shared host. They share code for the control panel. When executed for one site I get a warning (reproducible always), but on the other there is no warning. One my home server, set up in the same way, I do not get a warning for either site. The warning is from this code: if ( in_array( $keys, $photo_ids ) ) *Warning*: in_array() expects parameter 2 to be array, null given in */home/rois3324/include/**cpprocessforms.php* on line *203* Steps 1) Photos are transferred to incoming directory using ftp. 2) Photo data is imported into database and files moved to web site's file system 3) Photos are linked to a category by i) Specifying photos to consider by entering filespec using wildcards ii) User presented with photos iii) User selects photos to be added to category and clicks process button iv) Form returns array of photo_ids (key in database table) v) Form processor creates entry in link table that links category_id to photo_id vi) A check is made to detect and reject when the link already exists This is where the error occurs I have looked at the code, but I am at a total loss to figure out why I have trouble on one site and not the other, even though they are using the code. And my home development system has no problems. I can't play trial and error on the development system. Anyone have any ideas? This is the code where the warning is triggered: function linkphotos( $dbh, $x ) { global $thumbsdirectory; $ret_str = ; $cat_id = $x['category']; $photos = $x['list']; $sql0 = SELECT photo_filename FROM photographs WHERE photo_id = :id; $sql1 = SELECT photo_id FROM gallery_photos WHERE photo_category = :id; $sql2= INSERT INTO gallery_photos VALUES ( :id, :photo_id, :order ); $stmt = $dbh-prepare($sql0); try { foreach( $photos as $keys= $on) { $stmt-bindValue(':id', $keys); $stmt-execute(); $row = $stmt-fetch(PDO::FETCH_ASSOC)**; $filenames[$keys] = $thumbsdirectory . / . $row['photo_filename']; } } catch (PDOException $e) { return 'Error selecting existing file names: ' . $e-getMessage(); } $stmt = $dbh-prepare($sql1); try { $stmt-bindValue(':id', $cat_id); $stmt-execute(); while ( list( $id ) = $stmt-fetch(PDO::FETCH_NUM)) { $photo_ids[] = $id; } } catch (PDOException $e) { return 'Error selecting existing photos: ' . $e-getMessage(); } $stmt = $dbh-prepare($sql2); try { $stmt-bindValue(':id', $cat_id); foreach( $photos as $keys= $on) { $ret_str .= htmlimage($filenames[$keys], $filenames[$keys] ) . br /; if ( in_array( $keys, $photo_ids ) ) { warning raised here $ret_str .= Duplicate. Already in Category.br /; } else { $stmt-bindValue(':photo_id', $keys); $stmt-bindValue(':order', $keys); $stmt-execute(); $ret_str .= Added to Category.br /; } } } catch (PDOException $e) { return 'Error inserting new photos: ' . $e-getMessage(); } return $ret_str; } -- Stephen Your $photo_ids array is not declared. After $photos = $x['list']; add $photo_ids = array();
Re: [PHP] framework or not
On 25 Oct 2013, at 15:40, Robert Cummings rob...@interjinn.com wrote: On 13-10-25 10:17 AM, Stuart Dallas wrote: On 25 Oct 2013, at 15:01, Robert Cummings rob...@interjinn.com wrote: On 13-10-24 09:41 PM, Larry Garfield wrote: On 10/23/2013 08:51 AM, Jay Blanchard wrote: [snip] a bitter rant[/snip] Dang Larry - bad night? That wasn't a bitter rant. You haven't seen me bitter. :-) That was tough love to the OP. I don't see a reason to pussyfoot around the original question, which is one that comes up about once a month. The answer is always the same: How much is your time worth? Basic math... Life: finite Time: infinite finite / infinite = 0 *sniffle* Who's valuation of your time actually matters? Yours, and yours alone. Therefore: Life: n years Time I can benefit from my life: n years n years / n years = 1 *hoorah* Your time is the most precious commodity you have. Whether you use a framework or not you will (hopefully) reuse code between projects. If you choose to make part of that reused code one of the many frameworks that exist, you need only do one thing to ensure it continues to be worth using: how much of your time do you spend battling against the restrictions of the framework? If that's sufficiently low then using that framework is probably a good thing. If a significant portion of your time is spent battling the framework it's time to make a change. Also remember that the only person who can truthfully judge whether you're wasting time is you, unless you earn money by selling your time to someone else in which case they have some right to decide what constitutes a waste of the time for which they're paying. I found the experience of writing my own framework to be hugely beneficial to my future productivity, but I might have struggled to justify spending the extra time it took to my employer at the time. You stripped away the context of my response. By removing the evil grin you made it look like I was serious. You should be a reporter ;) Who says I'm not! :) -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] framework or not
On 13-10-24 09:41 PM, Larry Garfield wrote: On 10/23/2013 08:51 AM, Jay Blanchard wrote: [snip] a bitter rant[/snip] Dang Larry - bad night? That wasn't a bitter rant. You haven't seen me bitter. :-) That was tough love to the OP. I don't see a reason to pussyfoot around the original question, which is one that comes up about once a month. The answer is always the same: How much is your time worth? Basic math... Life: finite Time: infinite finite / infinite = 0 *sniffle* Oh wait... you meant in the smaller scheme of things :) Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] framework or not
On 25 Oct 2013, at 15:01, Robert Cummings rob...@interjinn.com wrote: On 13-10-24 09:41 PM, Larry Garfield wrote: On 10/23/2013 08:51 AM, Jay Blanchard wrote: [snip] a bitter rant[/snip] Dang Larry - bad night? That wasn't a bitter rant. You haven't seen me bitter. :-) That was tough love to the OP. I don't see a reason to pussyfoot around the original question, which is one that comes up about once a month. The answer is always the same: How much is your time worth? Basic math... Life: finite Time: infinite finite / infinite = 0 *sniffle* Who's valuation of your time actually matters? Yours, and yours alone. Therefore: Life: n years Time I can benefit from my life: n years n years / n years = 1 *hoorah* Your time is the most precious commodity you have. Whether you use a framework or not you will (hopefully) reuse code between projects. If you choose to make part of that reused code one of the many frameworks that exist, you need only do one thing to ensure it continues to be worth using: how much of your time do you spend battling against the restrictions of the framework? If that's sufficiently low then using that framework is probably a good thing. If a significant portion of your time is spent battling the framework it's time to make a change. Also remember that the only person who can truthfully judge whether you're wasting time is you, unless you earn money by selling your time to someone else in which case they have some right to decide what constitutes a waste of the time for which they're paying. I found the experience of writing my own framework to be hugely beneficial to my future productivity, but I might have struggled to justify spending the extra time it took to my employer at the time. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Persistent connections
On 25 Oct 2013, at 11:10, Nibin V M nibi...@gmail.com wrote: I have been reading docs and many are telling that persistent connections are kept open indefinitely. But I found in PHP docs that it will not close after script execution like requesting a page; so should it close after the request is over? So when exactly a persistent connection should close? Please advice. A persistent connection is closed when the PHP process ends, or it gets disconnected by the server-side or due to a network error. Attempting to explicitly close a persistent connection will do nothing without complaining. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] framework or not
I'm looking forward to the day that I'll know everything and can stop all this learning nonsense. Sounds like the attitude most people take when they sit down to a keyboard. (Ref: http://xkcd.com/386/) Off-topic is the new on-topic Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] framework or not
On 13-10-22 05:38 PM, Larry Garfield wrote: If you need more convincing, I will cite Fred Brooks: http://www.cs.nott.ac.uk/~cah/G51ISS/Documents/NoSilverBullet.html Excellent article, thanks for the pointer. So many assertions have stood the test of time thus far. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] framework or not
On Wed, Oct 23, 2013 at 10:26 AM, Tedd Sperling tedd.sperl...@gmail.comwrote: On Oct 23, 2013, at 12:04 AM, Robert Cummings rob...@interjinn.com wrote: On 13-10-22 05:38 PM, Larry Garfield wrote: If you need more convincing, I will cite Fred Brooks: http://www.cs.nott.ac.uk/~cah/G51ISS/Documents/NoSilverBullet.html Excellent article, thanks for the pointer. So many assertions have stood the test of time thus far. Cheers, Rob. Yes, it was an excellent article. One of the things I liked about the article was the concept of Incremental Development, which is something I have practiced since the Old Apple ][ days (Incidentally, he states he learned of this in 1958 -- is that a typo?). In 1977, I started many of my programs with (pardon my failing memory of AppleSoft syntax): Gosub GatherData() Gosub ProcessData() Gosub PresentDate() END It ran, but didn't do anything. Incidentally, that resembles a one-pass MVC design, does it not? In any event, I would flesh out the code until I got what I wanted. Maybe that's one of the reasons why Android or iOS Development starts with a Default Hello World App that does very little than run. Start simple, develop complex. Is there any other way to do it? I've been programming since 1975 and that's what I was taught and that's how always do it. Was it Brian Kernighan who said the 3 rules of programming are: 1. Keep it simple. 2. Build it in stages. 3. Let someone else do the hard part.
Re: [PHP] framework or not
On Wed, Oct 23, 2013 at 11:08 AM, Tedd Sperling tedd.sperl...@gmail.comwrote: On Oct 23, 2013, at 12:34 PM, Larry Martell la...@software-horizons.com wrote: Was it Brian Kernighan who said the 3 rules of programming are: 1. Keep it simple. 2. Build it in stages. 3. Let someone else do the hard part. Sounds good to me. I would also add: I've learned something new everyday of my life -- and I'm getting damned tired of it. I'm looking forward to the day that I'll know everything and can stop all this learning nonsense. Everything that can be invented has been invented. -Charles H. Duell, Commissioner of US patent office, 1899.
php-general Digest 20 Oct 2013 15:50:29 -0000 Issue 8402
php-general Digest 20 Oct 2013 15:50:29 - Issue 8402 Topics (messages 322325 through 322339): Re: Best Secure practice for uploading a csv file to import 322325 by: Ashley Sheridan 322326 by: Joshua Kehn Re: Algorithm Help 322327 by: German Geek 322334 by: German Geek 322335 by: German Geek 322337 by: Ayush Ladia 322338 by: German Geek If date is greater than 322328 by: John Taylor-Johnston 322329 by: German Geek 322330 by: John Taylor-Johnston 322331 by: John Taylor-Johnston 322332 by: Bastien 322336 by: Ashley Sheridan 322339 by: Tedd Sperling Re: Switch Statement 322333 by: German Geek Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On Sat, 2013-10-19 at 18:57 -0400, Joey J wrote: Hello All, I just wanted to see the best way to securely accomplish this task. when we want to update a DB we upload to a writable directory instead of writing it directly to MySQL, I don't like having writable directories if possible. Is there a right or better way to accomplish this? Thanks! There's nothing inherently wrong with having a directory writeable on your web server, but you should ensure it's running with the least privileges it requires to complete your task. So, make sure that the Apache user is also the owner of the directory, then you only need to give it 755 permissions (it's always unwise to use 777 on a production server). Another thing you can do is to place the upload directory outside your web root so that it's not accessible via a browser. I can see why you wouldn't want to import it directly into the database though. I recently had to fix a script of mine because someone thought it would be a good idea to change the order of a bunch of fields in a CSV, and added a new field in the middle rather than at the end. Having a script in between the CSV and the database can ensure some sort of data quality check is in-place before importing bad data. Thanks, Ash http://www.ashleysheridan.co.uk ---End Message--- ---BeginMessage--- On Oct 19, 2013, at 7:06 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Sat, 2013-10-19 at 18:57 -0400, Joey J wrote: Hello All, I just wanted to see the best way to securely accomplish this task. when we want to update a DB we upload to a writable directory instead of writing it directly to MySQL, I don't like having writable directories if possible. Is there a right or better way to accomplish this? Thanks! There's nothing inherently wrong with having a directory writeable on your web server, but you should ensure it's running with the least privileges it requires to complete your task. So, make sure that the Apache user is also the owner of the directory, then you only need to give it 755 permissions (it's always unwise to use 777 on a production server). Another thing you can do is to place the upload directory outside your web root so that it's not accessible via a browser. I can see why you wouldn't want to import it directly into the database though. I recently had to fix a script of mine because someone thought it would be a good idea to change the order of a bunch of fields in a CSV, and added a new field in the middle rather than at the end. Having a script in between the CSV and the database can ensure some sort of data quality check is in-place before importing bad data. Thanks, Ash http://www.ashleysheridan.co.uk Good points by Ash above. I'd like to mention that because this is user input make sure any database access is escaped correctly (prepared statements are good) and when/if you output it should all be HTML escaped. Best, -Josh ___ http://byjakt.com Currently mobile---End Message--- ---BeginMessage--- This is how I would approach/imagine it: https://docs.google.com/drawings/d/111RISgcHyAg8NXem4H1NXnxByRUydL8GiYlGkobJwus/edit Tom has been with Andrew 0 times. Tom has been with Shelly 1 time. Christine has been with Andrew 2 times. ... So the Graph maintains who has been with who how often. For 10 or even 20 kids you might be able to go through all links (brute force). The number of links (including the ones with 0 weight) is #links = n*(n-1)/2 which is the number of links you have to maintain and then check when you want to know who should go with whom. So, if n=10: #links = 10*9/2 = 45 n=20: #links = 20*19/2 = 190 n=30: #links = 30*29/2 = 435 I think even for reasonably large groups a computer can do the job easily. I would find it quite hard to do it on paper though, so I think you should program it. You could simply
Re: [PHP] If date is greater than
On Sun, 2013-10-20 at 00:00 -0400, Bastien wrote: Thanks, Bastien On Oct 19, 2013, at 10:44 PM, John Taylor-Johnston jt.johns...@usherbrooke.ca wrote: I have date strings in my mysql db. -mm-dd. I want to parse to see if the date is greater than november 2011 and less than december 2012. Is this the right approach? How bad is my syntax? |function dates_range($todaynow) { | |$date1=strtotime(2011-11-01); $date2=strtotime(2012-12-31); if (|||($|todaynow |= $date1) and |($|||todaynow| = $date2)||) || { || # do something } } ||| Easiest to convert to integers and then compare Yes, I was going to ask, why are you storing your dates as strings? MySQL has a perfectly good DATE type. It's also generally faster comparing dates within a MySQL query than PHP code. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Algorithm Help
Hi, Indeed making and maintaining the graph looks like the best approach here to tackle this problem , but what does not seem clear to me is this -- Suppose a family can host 5 children , then you need to find the set of 5 such nodes out of the total no. of nodes(assume 10) such that the total weight of all edges connecting the 5*4 nodes is minimum , how do you go about finding this set once you have constructed and maintained this graph and what will be the complexity?? On Sun, Oct 20, 2013 at 11:49 AM, German Geek geek...@gmail.com wrote: Oh and it also assumes that you don't do $graph-together('A','B'); // ... $graph-together('B', 'A'); //!! NO! If this has to be catered for you could simply sort them when inserting: public function together($who, $with) { $sorted = array($who, $with); sort($sorted); $who = $sorted[0]; $with = $sorted[1]; if (!isset($this-data[$who])) { $this-data[$who] = array(); } if (!isset($this-data[$who][$with])) { $this-data[$who][$with] = 1; return; } $this-data[$who][$with]++; } for the together function. Tim-Hinnerk Heuer Twitter: @geekdenz Blog: http://www.thheuer.com On 20 October 2013 19:13, German Geek geek...@gmail.com wrote: Try this class: ?php // ASSUMES NAMES DON'T HAVE | IN THEM!! YOU COULD USE ANOTHER // CHARACTER COMBO IF NEEDED AND explode ON THAT class Graph { protected $data = null; public function __construct($init = array()) { $this-data = $init; } public function together($who, $with) { if (!isset($this-data[$who])) { $this-data[$who] = array(); } if (!isset($this-data[$who][$with])) { $this-data[$who][$with] = 1; return; } $this-data[$who][$with]++; } public function getLeast($n = 1) { $values = array(); foreach ($this-data as $who = $withs) { foreach ($withs as $kwith = $vwith) { $values[$who .'|'. $kwith] = $vwith; } } asort($values); $nvalues = array_slice($values, 0, $n); $pairs = array(); foreach ($nvalues as $k = $v) { $parts = explode('|', $k); $pairs[] = array($parts[0], $parts[1]); } return $pairs; } public function __toString() { return print_r($this-data, true); } } $graph = new Graph(); $graph-together('A', 'B'); $graph-together('A', 'B'); $graph-together('B', 'C'); $graph-together('A', 'C'); $graph-together('B', 'D'); $graph-together('B', 'D'); $graph-together('B', 'D'); $graph-together('B', 'D'); $graph-together('B', 'D'); echo $graph; $least = $graph-getLeast(2); print_r($least); Tim-Hinnerk Heuer Twitter: @geekdenz Blog: http://www.thheuer.com On 20 October 2013 15:33, German Geek geek...@gmail.com wrote: This is how I would approach/imagine it: https://docs.google.com/drawings/d/111RISgcHyAg8NXem4H1NXnxByRUydL8GiYlGkobJwus/edit Tom has been with Andrew 0 times. Tom has been with Shelly 1 time. Christine has been with Andrew 2 times. ... So the Graph maintains who has been with who how often. For 10 or even 20 kids you might be able to go through all links (brute force). The number of links (including the ones with 0 weight) is #links = n*(n-1)/2 which is the number of links you have to maintain and then check when you want to know who should go with whom. So, if n=10: #links = 10*9/2 = 45 n=20: #links = 20*19/2 = 190 n=30: #links = 30*29/2 = 435 I think even for reasonably large groups a computer can do the job easily. I would find it quite hard to do it on paper though, so I think you should program it. You could simply store the graph in an array, and then optionally persist it to a db or file: You would get e.g.: $graph = array( '0,1' = 0, '0,2' = 2, ... Edit: Actually, maybe you can do it in a two-dimensional array, where no node is connected to itself: $n=4; function init() { global $n; $graph = array(); for ($i = 0; $i $n; ++$i) { $graph[$i] = array(); for ($j = 0; $j $n; ++$j) { $graph[$i][$j] = 0; } } return $graph; } $graph = init(); Sorry, I might be running a bit out of time here... You can use an implementation of a graph, for example this one: http://pear.php.net/package/Structures_Graph/docs/latest/li_Structures_Graph.html But it might be overkill as the 2-dimensional array would even do the trick and there might be less overhead although you are requiring more space than needed (n*(n-1)/2+n cells more to be exact). You could store it in a hashmap/associative array like this: ?php $graph = array
Re: [PHP] Algorithm Help
You don't need to maintain the history of which kids stay where unless you want to for other reasons. You just need to find the children that have staid the least amount of time together, which this approach would do for you. So, when 4 children stay together you say 1 together with 2 1 together with 3 1 together with 4 2 together with 3 2 together with 4 3 together with 4 and that's it. And then you can find the ones that staid together the least amount of time. Tim-Hinnerk Heuer Twitter: @geekdenz Blog: http://www.thheuer.com On 20 October 2013 21:53, Ayush Ladia ayushladia.for...@gmail.com wrote: Hi, Indeed making and maintaining the graph looks like the best approach here to tackle this problem , but what does not seem clear to me is this -- Suppose a family can host 5 children , then you need to find the set of 5 such nodes out of the total no. of nodes(assume 10) such that the total weight of all edges connecting the 5*4 nodes is minimum , how do you go about finding this set once you have constructed and maintained this graph and what will be the complexity?? On Sun, Oct 20, 2013 at 11:49 AM, German Geek geek...@gmail.com wrote: Oh and it also assumes that you don't do $graph-together('A','B'); // ... $graph-together('B', 'A'); //!! NO! If this has to be catered for you could simply sort them when inserting: public function together($who, $with) { $sorted = array($who, $with); sort($sorted); $who = $sorted[0]; $with = $sorted[1]; if (!isset($this-data[$who])) { $this-data[$who] = array(); } if (!isset($this-data[$who][$with])) { $this-data[$who][$with] = 1; return; } $this-data[$who][$with]++; } for the together function. Tim-Hinnerk Heuer Twitter: @geekdenz Blog: http://www.thheuer.com On 20 October 2013 19:13, German Geek geek...@gmail.com wrote: Try this class: ?php // ASSUMES NAMES DON'T HAVE | IN THEM!! YOU COULD USE ANOTHER // CHARACTER COMBO IF NEEDED AND explode ON THAT class Graph { protected $data = null; public function __construct($init = array()) { $this-data = $init; } public function together($who, $with) { if (!isset($this-data[$who])) { $this-data[$who] = array(); } if (!isset($this-data[$who][$with])) { $this-data[$who][$with] = 1; return; } $this-data[$who][$with]++; } public function getLeast($n = 1) { $values = array(); foreach ($this-data as $who = $withs) { foreach ($withs as $kwith = $vwith) { $values[$who .'|'. $kwith] = $vwith; } } asort($values); $nvalues = array_slice($values, 0, $n); $pairs = array(); foreach ($nvalues as $k = $v) { $parts = explode('|', $k); $pairs[] = array($parts[0], $parts[1]); } return $pairs; } public function __toString() { return print_r($this-data, true); } } $graph = new Graph(); $graph-together('A', 'B'); $graph-together('A', 'B'); $graph-together('B', 'C'); $graph-together('A', 'C'); $graph-together('B', 'D'); $graph-together('B', 'D'); $graph-together('B', 'D'); $graph-together('B', 'D'); $graph-together('B', 'D'); echo $graph; $least = $graph-getLeast(2); print_r($least); Tim-Hinnerk Heuer Twitter: @geekdenz Blog: http://www.thheuer.com On 20 October 2013 15:33, German Geek geek...@gmail.com wrote: This is how I would approach/imagine it: https://docs.google.com/drawings/d/111RISgcHyAg8NXem4H1NXnxByRUydL8GiYlGkobJwus/edit Tom has been with Andrew 0 times. Tom has been with Shelly 1 time. Christine has been with Andrew 2 times. ... So the Graph maintains who has been with who how often. For 10 or even 20 kids you might be able to go through all links (brute force). The number of links (including the ones with 0 weight) is #links = n*(n-1)/2 which is the number of links you have to maintain and then check when you want to know who should go with whom. So, if n=10: #links = 10*9/2 = 45 n=20: #links = 20*19/2 = 190 n=30: #links = 30*29/2 = 435 I think even for reasonably large groups a computer can do the job easily. I would find it quite hard to do it on paper though, so I think you should program it. You could simply store the graph in an array, and then optionally persist it to a db or file: You would get e.g.: $graph = array( '0,1' = 0, '0,2' = 2, ... Edit: Actually, maybe you can do it in a two-dimensional array, where no node is connected to itself: $n=4; function init() { global $n; $graph = array(); for ($i = 0; $i $n; ++$i) { $graph[$i] = array
Re: [PHP] If date is greater than
On Oct 20, 2013, at 4:01 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: Yes, I was going to ask, why are you storing your dates as strings? MySQL has a perfectly good DATE type. It's also generally faster comparing dates within a MySQL query than PHP code. Thanks, Ash http://www.ashleysheridan.co.uk Agreed. Plus, there are many date functions provided by MySQL that are easier (possibility faster) than what you can do in PHP. Check these out: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date tedd ___ tedd sperling tedd.sperl...@gmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Trying to understand what is happening in this code
On 11 Oct 2013, at 16:20, Nathan Grey grey...@gmail.com wrote: Stuart, Jose - Thanks for your quick response. Are you saying that the processor echos all the html tags it sees. Is it doing something like this to the script: echo body echo h1The first twenty Fibonacci numbers:/h1 echo ul ?php $first = 0; $second = 1; for ($i = 0; $i 20; $i++) { ? echo li?php echo $first + $second ?/li ?php $temp = $first + $second; $first = $second; $second = $temp; } ? echo /ul echo /body Or is it just the line in question that is being echoed? I'm not sure exactly what it gets compiled to, but I also don't see why it matters. All that matters is that content outside of PHP tags will simply get echo'd. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php.ini
On 10/8/2013 11:13 AM, Simon Schick wrote: Hi, Jim I suggest to read this page of the tutorial. It seems, that it solves the questions, you posted here: http://www.php.net/manual/en/configuration.file.per-user.php Please be aware, that the ini-file is not re-read on every request, but after a defined time. Neither are all settings changeable in those per-user ini-files. Read also the other pages in this chapter, they're good to keep in mind ;) If you're now calling the script from a webserver, you called by requesting a page on a subdomain or a top-level-domain, doesn't matter. Bye, Simon On Tue, Oct 8, 2013 at 4:48 PM, Jim Giner jim.gi...@albanyhandball.comwrote: Can someone give me an understanding of how the .ini settings are located and combined? I am under the impression that there is a full settings .ini file somewhere up high in my host's server tree and that any settings I create in .ini files in each of my domain folders are appended/updated against the 'main' ini settings to give me a 'current' group of php.ini settings. What I'm looking to find out is does an ini setting established in a test subdomain of my site affect those ini settings outside of my test subdomain? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I need more! 1 - the doc you mentioned refers to 'user.ini'. Does that literally mean the file is called 'USER.ini'? I have been placing my .ini overrides/settings in each of my folders under the name 'php.ini'. Do I have to change them all because it seems that they are working fine. 2 - I didn't understand your last paragraph. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php.ini
re: changing ini settings. If my running script modifies an ini setting I currently believe that that changed setting will apply to that specific process and any others that run after that from that same folder (since i have an ini file in each folder currently). Correct? And if I do make a setting change as above, it only affects the ini file and processes in that folder, thus leaving the setting unchanged in any and all other folders above that one. Correct? And from the article pointed out to me, I get the impression that the search for ini files bubbles up from the executing folder. If that is so, then am I correct in assuming that settings in the lowest ini file take precedence over any found in 'bubbled-up' ini files? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php.ini
Hi, Jim I suggest to read this page of the tutorial. It seems, that it solves the questions, you posted here: http://www.php.net/manual/en/configuration.file.per-user.php Please be aware, that the ini-file is not re-read on every request, but after a defined time. Neither are all settings changeable in those per-user ini-files. Read also the other pages in this chapter, they're good to keep in mind ;) If you're now calling the script from a webserver, you called by requesting a page on a subdomain or a top-level-domain, doesn't matter. Bye, Simon On Tue, Oct 8, 2013 at 4:48 PM, Jim Giner jim.gi...@albanyhandball.comwrote: Can someone give me an understanding of how the .ini settings are located and combined? I am under the impression that there is a full settings .ini file somewhere up high in my host's server tree and that any settings I create in .ini files in each of my domain folders are appended/updated against the 'main' ini settings to give me a 'current' group of php.ini settings. What I'm looking to find out is does an ini setting established in a test subdomain of my site affect those ini settings outside of my test subdomain? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php.ini
On 10/9/2013 3:14 AM, Simon Schick wrote: On Tue, Oct 8, 2013 at 9:50 PM, Jim Giner jim.gi...@albanyhandball.comwrote: On 10/8/2013 2:42 PM, Simon Schick wrote: On Tue, Oct 8, 2013 at 5:25 PM, Jim Giner jim.gi...@albanyhandball.com* *wrote: re: changing ini settings. If my running script modifies an ini setting I currently believe that that changed setting will apply to that specific process and any others that run after that from that same folder (since i have an ini file in each folder currently). Correct? And if I do make a setting change as above, it only affects the ini file and processes in that folder, thus leaving the setting unchanged in any and all other folders above that one. Correct? And from the article pointed out to me, I get the impression that the search for ini files bubbles up from the executing folder. If that is so, then am I correct in assuming that settings in the lowest ini file take precedence over any found in 'bubbled-up' ini files? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi, Jim Never mind my last paragraph ... I was thinking the wrong way of what you wrote earlier. I haven't tested it properly in every detail, but from the perspective of what I know it's like you wrote. The file that's mentioned as php.ini is the main configuration file of your php-installation. It may be, that the user-ini file was renamed to php.ini as well, but if you read about php.ini, they always mean the configuration-file that you see listed in the output of phpinfo() as Configuration File (php.ini) Path. * You can rename the user-ini file by changing the user_ini.filename setting in the php.ini file (as written on the page I linked you to) * The php-settings are restored after/before each script-execution * The manual doesn't catch if a user-ini file was found ... just that it bubbles up to the document_root. Maybe the configuration found in user-ini files is merged, or just the first file is taken. * I don't know what happens to configuration you apply f.e. in nginx ... I know neither when settings in php-fpm are applied ... that's something left for testing, or until somebody finds the documentation explaining it (I know there is one ...), but I guess they're applied after the php.ini and before the user-ini files. Examples are listed here: http://php.net/manual/en/**install.fpm.configuration.php#**example-60http://php.net/manual/en/install.fpm.configuration.php#example-60 * What you set using set_ini() is just applied for the rest of the currently running script. Bye Simon I understand most of what you wrote and agree all except for one thing. You keep using the name user.ini and I asked for clarification on this earlier. Do I have to create files named EXACTLY that way, or are php.ini files correctly named? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi, Jim You can define the name for this file your configuration (php basic configuration file or in the webserver, calling the cgi/fcgi script). The configuration is called user_ini.filename, and it's default value is set to .user.ini. Of course, your provider (or you, if you're the administrator of the php-instance) may changed this setting to something like php.ini. Then the php-process will search for a php.ini file in the directories a user-ini file is searched in. When talking about configuration files, this may be misleading, as the basic configuration file is refered as php.ini over all in the documentation. I don't believe, that the PHP process would search for a file called php.ini, if the value is set to something like .user.ini - if that's what you mean. It may be, that you can change the setting later on, but it will have no effect (f.e. if you change it using set_ini() ... if it doesn't trigger a E_WARNING or something the like). Hope this answers the remaining question. If not, I kindly ask you to write some examples. Bye, Simon Ok - here is what I see happening now. PHPINFO shows a setting named 'user_ini.filename' set to '.user.ini' At the same time the setting loaded configuration file shows that a php.ini file was loaded from the current sub folder that this call to phpinfo was running in (as I expect!). So apparently my host has set php to look for user.ini files, but php.ini files are still accepted and loaded. I'm guessing that despite the user_ini filename setting, a PHP.ini file will still be read, which suits me just fine. Thanks for all the help Simon! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php.ini
Can someone give me an understanding of how the .ini settings are located and combined? I am under the impression that there is a full settings .ini file somewhere up high in my host's server tree and that any settings I create in .ini files in each of my domain folders are appended/updated against the 'main' ini settings to give me a 'current' group of php.ini settings. What I'm looking to find out is does an ini setting established in a test subdomain of my site affect those ini settings outside of my test subdomain? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
php-general Digest 7 Oct 2013 13:24:41 -0000 Issue 8388
php-general Digest 7 Oct 2013 13:24:41 - Issue 8388 Topics (messages 322243 through 322257): Re: date time problem 322243 by: Farzan Dalaee 322244 by: Jim Giner 322245 by: Farzan Dalaee 322247 by: Jim Giner 322248 by: Farzan Dalaee 322249 by: Jonathan Sundquist 322250 by: Aziz Saleh 322251 by: Jim Giner 322252 by: Aziz Saleh 322253 by: Ashley Sheridan 322254 by: Jim Giner 322255 by: Jim Giner 322256 by: Romain CIACCAFAVA After a PHP script timeout, Apache logs the error but may not cleanly exit the script 322246 by: Meta Seller Admin PHP Fatal error: Call to undefined function () 322257 by: Michael Alaimo Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. ---End Message--- ---BeginMessage--- Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try
[PHP] PHP Fatal error: Call to undefined function ()
We have a server that gets a large number of requests each month. After a period of time I began to see this error in our error logs this weekend. PHP Fatal error: Call to undefined function () It does not reference a function, so I found it odd. It did give a line to a function with array_merge on it. Has anyone seen this in the apache error logs? We are using PHP 5.3.3. Mike
Re: [PHP] PHP Fatal error: Call to undefined function ()
On 7 Oct 2013, at 14:24, Michael Alaimo malaimo...@gmail.com wrote: We have a server that gets a large number of requests each month. After a period of time I began to see this error in our error logs this weekend. PHP Fatal error: Call to undefined function () It does not reference a function, so I found it odd. It did give a line to a function with array_merge on it. Has anyone seen this in the apache error logs? We are using PHP 5.3.3. Show us the line, and a few lines around it. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Fatal error: Call to undefined function ()
public static function getInfo($params = array()) { $results = array(); $url = 'http://google.com'; $props = array ( 'key'= Yii::app()-params['param1'], 's'= Yii::app()-params['param2'] ); if (!empty($params)) { $props = array_merge($props, $params); $url = $url . http_build_query($props, '', '/'); It may be possible that params has unsafe data in it. The previous dev did not validate the data passed in via get. The code populating params looks like: $params = array ( 'd' = $_GET['d'], ); $job = Job::getInfo($params); On Mon, Oct 7, 2013 at 9:29 AM, Stuart Dallas stu...@3ft9.com wrote: On 7 Oct 2013, at 14:24, Michael Alaimo malaimo...@gmail.com wrote: We have a server that gets a large number of requests each month. After a period of time I began to see this error in our error logs this weekend. PHP Fatal error: Call to undefined function () It does not reference a function, so I found it odd. It did give a line to a function with array_merge on it. Has anyone seen this in the apache error logs? We are using PHP 5.3.3. Show us the line, and a few lines around it. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/
Re: [PHP] PHP Fatal error: Call to undefined function ()
On 7 Oct 2013, at 14:34, Michael Alaimo malaimo...@gmail.com wrote: On Mon, Oct 7, 2013 at 9:29 AM, Stuart Dallas stu...@3ft9.com wrote: On 7 Oct 2013, at 14:24, Michael Alaimo malaimo...@gmail.com wrote: We have a server that gets a large number of requests each month. After a period of time I began to see this error in our error logs this weekend. PHP Fatal error: Call to undefined function () It does not reference a function, so I found it odd. It did give a line to a function with array_merge on it. Has anyone seen this in the apache error logs? We are using PHP 5.3.3. Show us the line, and a few lines around it. public static function getInfo($params = array()) { $results = array(); $url = 'http://google.com'; $props = array ( 'key'= Yii::app()-params['param1'], 's'= Yii::app()-params['param2'] ); if (!empty($params)) { $props = array_merge($props, $params); $url = $url . http_build_query($props, '', '/'); It may be possible that params has unsafe data in it. The previous dev did not validate the data passed in via get. The code populating params looks like: $params = array ( 'd' = $_GET['d'], ); $job = Job::getInfo($params); My best guess is that either $props or $params contain a function reference or similar construct. Examine their contents with var_dump. As a check you could expand out the effect of array_merge and see if you still get the same with a PHP implementation. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
On 10/6/2013 11:21 PM, Romain CIACCAFAVA wrote: An easier way to do that would be using the diff() method of a DateTime object on another. Regards Romain Ciaccafava Romain - you were so right. A little less calculating to be done and I got the result I wished. For anyone interested here's the function I'm using to determine how much time there is until a cookie expires. The cookie in question contains the expiration datetime that was used to create a paired cookie. function GetTimeLeft($applid) { if (isset($_COOKIE[$applid])) { if (isset($_COOKIE[$applid.expire])) { $curr_time = new datetime(); $cookietime = $_COOKIE[$applid.expire]; $exp_time = new datetime(); $exp_time-setTimeStamp($cookietime); $diff = $curr_time-diff($exp_time); $days = $diff-format(%d); $days = ($days 1) ? $days days: ($days == 1) ? $days day : ''; $hms = $diff-format(%h:%i:%s); return Time left: $days $hms; } else return '?'; } else return '0'; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] date time problem
I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] After a PHP script timeout, Apache logs the error but may not cleanly exit the script
Hi. I'm wondering if anyone can help with this. We're using PHP and Apache, hosted on a dedicated server running Debian Linux. The specific versions in each case are mostly immaterial, as this problem has been around since Debian 6, and is still present in Debian 7; in the meantime we've been using the latest versions of all packages. We're having problems with PHP script timeouts, which although rare, are behaving erratically and causing severe problems when they do occur. The timeouts are always recorded in the Apache log, and sometimes the script and everything else may execute/terminate correctly, but often, various failures may be observed, such as: * timeouts not registered back to PHP - the script may not terminate as expected (the function registered with register_shutdown_function() - see code example below - may not be called); * after a timeout, Apache may run in the background indefinitely, using up CPU resources in one core; * Apache may fail altogether - no further requests serviced - Apache must be restarted. The exact cause of the fault has not been found. It is reproducible on all servers we deploy to. Example PHP script: //... function _on_shutdown() { if (connection_status() CONNECTION_TIMEOUT) { echo 'ERROR: TIMEOUT!'; //Do something else... } exit; } register_shutdown_function('_on_shutdown'); //...more code here... //(various potentially long running scripts which may timeout) The above was also posted here: http://serverfault.com/questions/542045/after-a-php-script-timeout-apache-logs-the-error-but-may-not-cleanly-exit-the-s Ric. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
This should help you out http://stackoverflow.com/questions/365191/how-to-get-time-difference-in-minutes-in-php On Oct 6, 2013 6:07 PM, Farzan Dalaee farzan.dal...@gmail.com wrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
Look at my code. The inputs are all timestamps so date should work, no? My question why am i getting an hour value in this case? jg On Oct 6, 2013, at 7:14 PM, Aziz Saleh azizsa...@gmail.com wrote: Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.com wrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
The resulting subtraction is not a valid timestamp, but rather the difference between the two timestamps in seconds . The resulting diff can be 1 if the timestamps are 1 seconds apart. The linkhttp://stackoverflow.com/questions/365191/how-to-get-time-difference-in-minutes-in-phpJonathan sent out contains functions that does the division for you with results. Another link you can check out: http://stackoverflow.com/a/9143387/1935500 On Sun, Oct 6, 2013 at 7:29 PM, Jim Giner jim.gi...@albanyhandball.comwrote: Look at my code. The inputs are all timestamps so date should work, no? My question why am i getting an hour value in this case? jg On Oct 6, 2013, at 7:14 PM, Aziz Saleh azizsa...@gmail.com wrote: Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
On Sun, 2013-10-06 at 19:14 -0400, Aziz Saleh wrote: Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Aziz, please try not to top post :) It's true that the date() function takes in a timestamp as its argument, but a timestamp is a number representing the number of seconds since 00:00:00 1st January 1970, so passing in a very small number of seconds is perfectly valid. The only thing that would account for the 7 hours difference is the time zone, which would also be part of the timestamp. http://en.wikipedia.org/wiki/Unix_time gives more details. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] date time problem
On 10/6/2013 7:40 PM, Aziz Saleh wrote: The resulting subtraction is not a valid timestamp, but rather the difference between the two timestamps in seconds . The resulting diff can be 1 if the timestamps are 1 seconds apart. The linkhttp://stackoverflow.com/questions/365191/how-to-get-time-difference-in-minutes-in-phpJonathan sent out contains functions that does the division for you with results. Another link you can check out: http://stackoverflow.com/a/9143387/1935500 On Sun, Oct 6, 2013 at 7:29 PM, Jim Giner jim.gi...@albanyhandball.comwrote: Look at my code. The inputs are all timestamps so date should work, no? My question why am i getting an hour value in this case? jg On Oct 6, 2013, at 7:14 PM, Aziz Saleh azizsa...@gmail.com wrote: Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Good Point! I never looked at it that way. I guess the Date function can't be relied on in that case. So now I'll have to calculate my time in a mathematical way instead of letting Date translate it for me. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
On 10/6/2013 7:55 PM, Ashley Sheridan wrote: On Sun, 2013-10-06 at 19:14 -0400, Aziz Saleh wrote: Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Aziz, please try not to top post :) It's true that the date() function takes in a timestamp as its argument, but a timestamp is a number representing the number of seconds since 00:00:00 1st January 1970, so passing in a very small number of seconds is perfectly valid. The only thing that would account for the 7 hours difference is the time zone, which would also be part of the timestamp. http://en.wikipedia.org/wiki/Unix_time gives more details. Thanks, Ash http://www.ashleysheridan.co.uk Thanks Ash, but the previous (top) post explained my dilemma just as you have done here. My attempt to use a function to avoid doing the math has now been resolved. Guess I'll have to do it the old-fashioned way. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
An easier way to do that would be using the diff() method of a DateTime object on another. Regards Romain Ciaccafava Le 7 oct. 2013 à 03:10, Jim Giner jim.gi...@albanyhandball.com a écrit : On 10/6/2013 7:55 PM, Ashley Sheridan wrote: On Sun, 2013-10-06 at 19:14 -0400, Aziz Saleh wrote: Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Aziz, please try not to top post :) It's true that the date() function takes in a timestamp as its argument, but a timestamp is a number representing the number of seconds since 00:00:00 1st January 1970, so passing in a very small number of seconds is perfectly valid. The only thing that would account for the 7 hours difference is the time zone, which would also be part of the timestamp. http://en.wikipedia.org/wiki/Unix_time gives more details. Thanks, Ash http://www.ashleysheridan.co.uk Thanks Ash, but the previous (top) post explained my dilemma just as you have done here. My attempt to use a function to avoid doing the math has now been resolved. Guess I'll have to do it the old-fashioned way. -- 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 Digest 3 Oct 2013 12:47:41 -0000 Issue 8386
php-general Digest 3 Oct 2013 12:47:41 - Issue 8386 Topics (messages 322235 through 322240): Re: Algorithm Help 322235 by: Stuart Dallas 322236 by: Serge Fonville 322237 by: Floyd Resler 322238 by: Marc Guay 322239 by: Tamara Temple 322240 by: Floyd Resler Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On 1 Oct 2013, at 19:51, Floyd Resler fres...@adex-intl.com wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Sounds like a job for a directed graph data structure. I wish I had time to knock up a solution but I don't right now. This article should help you get started: http://www.codediesel.com/algorithms/building-a-graph-data-structure-in-php/ -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/---End Message--- ---BeginMessage--- It also depends on the amount of kids, families and stays. If the numbers are low, by hand may be a lot easier and faster Kind regards/met vriendelijke groet, Serge Fonville http://www.sergefonville.nl 2013/10/2 Tamara Temple tamouse.li...@gmail.com On Oct 1, 2013, at 1:51 PM, Floyd Resler fres...@adex-intl.com wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php While definitely a tempting coding exercise, I just want to say that if this is urgent in any way, shuffling cards with the kids' names on them by hand might just be faster and less frustrating :) OTOH, if this is something you're going to have to figure out week after week, then a software solution might be handy. This is also not an *easy* problem to solve; there isn't a simple approach to optimizing this sort of thing because you're building a net between all the various kids based on past stays, in addition to the constraints of host family capacity. Thus your previous code attempts might in fact be the end result. Obviously, structuring the data is the key here. I'm thinking of 3 primary models: Kids, Hosts, and Stays. Kids and Hosts seem pretty obvious. Stays is the interesing model, and needs to have joining tables with Kids and Hosts. A Stay will have one Host, and have many Kids and a date. The algorithm then needs to make the graph where it can pull out the number of times any particular kid has stayed with another, looking something like this: Amy: Ben: 10 Jill: 3 Carlos: 7 Chen: 2 Ben: Amy: 10 Jill: 5 Carlos: 8 Chen: 3 Jill: … and so on Then you be able to pull through that graph and find the smallest number of stays for each kid. Not simple, but I hope this helps. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- On Oct 2, 2013, at 9:51 AM, Tamara Temple tamouse.li...@gmail.com wrote: On Oct 1, 2013, at 1:51 PM, Floyd Resler fres...@adex-intl.com wrote: Here's my task: A group
Re: [PHP] Algorithm Help
On Oct 2, 2013, at 6:23 PM, Tamara Temple tamouse.li...@gmail.com wrote: On Oct 2, 2013, at 9:05 AM, Marc Guay marc.g...@gmail.com wrote: If you have the technology handy, it could also just be easier to wipe the children's memories after each stay. Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Well played! (.. eying the black suit…. What's that funny stick you're hol….) I love it! Our director loved it too! Too funny! Thanks! Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Algorithm Help
Round Robin algorithm should solve this and is a fairly quick alogrithm ... http://en.wikipedia.org/wiki/Round-robin An example can be found http://forrst.com/posts/PHP_Round_Robin_Algorithm-2zm On Tue, Oct 1, 2013 at 2:51 PM, Floyd Resler fres...@adex-intl.com wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Nickolas Whiting Freelance Consultant
php-general Digest 2 Oct 2013 13:52:00 -0000 Issue 8385
php-general Digest 2 Oct 2013 13:52:00 - Issue 8385 Topics (messages 38 through 322234): Re: delete S3 bucket with AWS PHP SDK 38 by: Aziz Saleh Re: Algorithm Help 39 by: John Meyer 322230 by: Aziz Saleh 322231 by: Ashley Sheridan 322232 by: Floyd Resler 322233 by: Serge Fonville 322234 by: Tamara Temple Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- Hey Tim, It seems that deleteObject takes in 2 params, and you are sending it 1 param. I would recommend you look at the documentation and make sure you are sending the right params. Aziz On Sun, Sep 29, 2013 at 10:29 PM, Tim Dunphy bluethu...@gmail.com wrote: Hi Aziz, Thank you for getting back to me! I appreciate you spotting that error. So I corrected that ?php require_once 'sdk.class.php'; if (isset($_POST['submit'])) { * $bucket_name = $_POST['bucket_name'];* // Create the S3 Object from the SDK $s3 = new AmazonS3(); * $result = $s3-deleteObject(array( 'Bucket' = $bucket_name ));* // The response comes back as a Simple XML Object // In this case we just want to know if everything was okay. // If not, report the message from the XML response. if ((int) $response-isOK()) { echo 'centerDeleted Bucket'; echo 'br /br /'; echo 'a href=listbuckets.phpList Buckets/a/center'; } else { echo (string) $response-body-Message; } //echo 'br /br /'; } ? body centerh3Delete S3 Bucket/h3 form name=delete_bucket method=post action=delete_bucket.php label for=bucket_nameBucket Name:/labelbr / * input type=text id=bucket_name name=bucket_name /br /br / * input type=submit name=submit value=Delete Bucket / /form/center script /body /html And this is the error I am currently getting: Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(72): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(72): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548 Not sure if I'm getting closer here... but definitely appreciate any advice anyone may have. Thanks! Tim On Sun, Sep 29, 2013 at 5:04 PM, Aziz Saleh azizsa...@gmail.com wrote: No Problem, the issue is that you referring to the invalid post element $bucket_name as opposed to the correct on bucket_name. *$bucket_name = $_POST['$bucket_name'];* Should be *$bucket_name = $_POST['bucket_name'];* Aziz On Sun, Sep 29, 2013 at 3:28 PM, Tim Dunphy bluethu...@gmail.com wrote: Hey guys, Sorry about that i should have posted the full code to give you some idea of context. Anyway, here it is: ?php require_once 'sdk.class.php'; if (isset($_POST['submit'])) { * $bucket_name = $_POST['$bucket_name'];* // Create the S3 Object from the SDK *$s3 = new AmazonS3();* * $result = $s3-deleteObject(array(* *'Bucket' = $bucket_name ));* // The response comes back as a Simple XML Object // In this case we just want to know if everything was okay. // If not, report the message from the XML response. if ((int) $response-isOK()) { echo 'centerDeleted Bucket'; echo 'br /br /'; echo 'a href=listbuckets.phpList Buckets/a/center'; } else { echo (string) $response-body-Message; } //echo 'br /br /'; } ? body centerh3Delete S3 Bucket/h3 form name=delete_bucket method=post action=delete_bucket.php label for=bucket_nameBucket Name:/labelbr / * input type=text id=bucket_name name=bucket_name /br /br /* input type=submit name=submit value=Delete Bucket / /form/center So, as you can see I am taking the 'bucket_value' from $_POST and passing it into the call to S3. When the form comes up on the web
Re: [PHP] Algorithm Help
On Oct 1, 2013, at 1:51 PM, Floyd Resler fres...@adex-intl.com wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php While definitely a tempting coding exercise, I just want to say that if this is urgent in any way, shuffling cards with the kids' names on them by hand might just be faster and less frustrating :) OTOH, if this is something you're going to have to figure out week after week, then a software solution might be handy. This is also not an *easy* problem to solve; there isn't a simple approach to optimizing this sort of thing because you're building a net between all the various kids based on past stays, in addition to the constraints of host family capacity. Thus your previous code attempts might in fact be the end result. Obviously, structuring the data is the key here. I'm thinking of 3 primary models: Kids, Hosts, and Stays. Kids and Hosts seem pretty obvious. Stays is the interesing model, and needs to have joining tables with Kids and Hosts. A Stay will have one Host, and have many Kids and a date. The algorithm then needs to make the graph where it can pull out the number of times any particular kid has stayed with another, looking something like this: Amy: Ben: 10 Jill: 3 Carlos: 7 Chen: 2 Ben: Amy: 10 Jill: 5 Carlos: 8 Chen: 3 Jill: … and so on Then you be able to pull through that graph and find the smallest number of stays for each kid. Not simple, but I hope this helps. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Algorithm Help
On 1 Oct 2013, at 19:51, Floyd Resler fres...@adex-intl.com wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Sounds like a job for a directed graph data structure. I wish I had time to knock up a solution but I don't right now. This article should help you get started: http://www.codediesel.com/algorithms/building-a-graph-data-structure-in-php/ -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Algorithm Help
It also depends on the amount of kids, families and stays. If the numbers are low, by hand may be a lot easier and faster Kind regards/met vriendelijke groet, Serge Fonville http://www.sergefonville.nl 2013/10/2 Tamara Temple tamouse.li...@gmail.com On Oct 1, 2013, at 1:51 PM, Floyd Resler fres...@adex-intl.com wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php While definitely a tempting coding exercise, I just want to say that if this is urgent in any way, shuffling cards with the kids' names on them by hand might just be faster and less frustrating :) OTOH, if this is something you're going to have to figure out week after week, then a software solution might be handy. This is also not an *easy* problem to solve; there isn't a simple approach to optimizing this sort of thing because you're building a net between all the various kids based on past stays, in addition to the constraints of host family capacity. Thus your previous code attempts might in fact be the end result. Obviously, structuring the data is the key here. I'm thinking of 3 primary models: Kids, Hosts, and Stays. Kids and Hosts seem pretty obvious. Stays is the interesing model, and needs to have joining tables with Kids and Hosts. A Stay will have one Host, and have many Kids and a date. The algorithm then needs to make the graph where it can pull out the number of times any particular kid has stayed with another, looking something like this: Amy: Ben: 10 Jill: 3 Carlos: 7 Chen: 2 Ben: Amy: 10 Jill: 5 Carlos: 8 Chen: 3 Jill: … and so on Then you be able to pull through that graph and find the smallest number of stays for each kid. Not simple, but I hope this helps. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Algorithm Help
On Oct 2, 2013, at 9:51 AM, Tamara Temple tamouse.li...@gmail.com wrote: On Oct 1, 2013, at 1:51 PM, Floyd Resler fres...@adex-intl.com wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php While definitely a tempting coding exercise, I just want to say that if this is urgent in any way, shuffling cards with the kids' names on them by hand might just be faster and less frustrating :) OTOH, if this is something you're going to have to figure out week after week, then a software solution might be handy. This is also not an *easy* problem to solve; there isn't a simple approach to optimizing this sort of thing because you're building a net between all the various kids based on past stays, in addition to the constraints of host family capacity. Thus your previous code attempts might in fact be the end result. Obviously, structuring the data is the key here. I'm thinking of 3 primary models: Kids, Hosts, and Stays. Kids and Hosts seem pretty obvious. Stays is the interesing model, and needs to have joining tables with Kids and Hosts. A Stay will have one Host, and have many Kids and a date. The algorithm then needs to make the graph where it can pull out the number of times any particular kid has stayed with another, looking something like this: Amy: Ben: 10 Jill: 3 Carlos: 7 Chen: 2 Ben: Amy: 10 Jill: 5 Carlos: 8 Chen: 3 Jill: … and so on Then you be able to pull through that graph and find the smallest number of stays for each kid. Not simple, but I hope this helps. That's the only approach I could think of. I may have to tell the director it may be a bit slow but at least she won't have to do it by hand! Thanks! Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Algorithm Help
If you have the technology handy, it could also just be easier to wipe the children's memories after each stay. Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Algorithm Help
On Oct 2, 2013, at 9:05 AM, Marc Guay marc.g...@gmail.com wrote: If you have the technology handy, it could also just be easier to wipe the children's memories after each stay. Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Well played! (.. eying the black suit…. What's that funny stick you're hol….) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
php-general Digest 1 Oct 2013 18:51:44 -0000 Issue 8384
php-general Digest 1 Oct 2013 18:51:44 - Issue 8384 Topics (messages 37 through 37): Algorithm Help 37 by: Floyd Resler Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd ---End Message---
[PHP] Algorithm Help
Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] delete S3 bucket with AWS PHP SDK
Hey Tim, It seems that deleteObject takes in 2 params, and you are sending it 1 param. I would recommend you look at the documentation and make sure you are sending the right params. Aziz On Sun, Sep 29, 2013 at 10:29 PM, Tim Dunphy bluethu...@gmail.com wrote: Hi Aziz, Thank you for getting back to me! I appreciate you spotting that error. So I corrected that ?php require_once 'sdk.class.php'; if (isset($_POST['submit'])) { * $bucket_name = $_POST['bucket_name'];* // Create the S3 Object from the SDK $s3 = new AmazonS3(); * $result = $s3-deleteObject(array( 'Bucket' = $bucket_name ));* // The response comes back as a Simple XML Object // In this case we just want to know if everything was okay. // If not, report the message from the XML response. if ((int) $response-isOK()) { echo 'centerDeleted Bucket'; echo 'br /br /'; echo 'a href=listbuckets.phpList Buckets/a/center'; } else { echo (string) $response-body-Message; } //echo 'br /br /'; } ? body centerh3Delete S3 Bucket/h3 form name=delete_bucket method=post action=delete_bucket.php label for=bucket_nameBucket Name:/labelbr / * input type=text id=bucket_name name=bucket_name /br /br / * input type=submit name=submit value=Delete Bucket / /form/center script /body /html And this is the error I am currently getting: Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(72): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(72): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548 Not sure if I'm getting closer here... but definitely appreciate any advice anyone may have. Thanks! Tim On Sun, Sep 29, 2013 at 5:04 PM, Aziz Saleh azizsa...@gmail.com wrote: No Problem, the issue is that you referring to the invalid post element $bucket_name as opposed to the correct on bucket_name. *$bucket_name = $_POST['$bucket_name'];* Should be *$bucket_name = $_POST['bucket_name'];* Aziz On Sun, Sep 29, 2013 at 3:28 PM, Tim Dunphy bluethu...@gmail.com wrote: Hey guys, Sorry about that i should have posted the full code to give you some idea of context. Anyway, here it is: ?php require_once 'sdk.class.php'; if (isset($_POST['submit'])) { * $bucket_name = $_POST['$bucket_name'];* // Create the S3 Object from the SDK *$s3 = new AmazonS3();* * $result = $s3-deleteObject(array(* *'Bucket' = $bucket_name ));* // The response comes back as a Simple XML Object // In this case we just want to know if everything was okay. // If not, report the message from the XML response. if ((int) $response-isOK()) { echo 'centerDeleted Bucket'; echo 'br /br /'; echo 'a href=listbuckets.phpList Buckets/a/center'; } else { echo (string) $response-body-Message; } //echo 'br /br /'; } ? body centerh3Delete S3 Bucket/h3 form name=delete_bucket method=post action=delete_bucket.php label for=bucket_nameBucket Name:/labelbr / * input type=text id=bucket_name name=bucket_name /br /br /* input type=submit name=submit value=Delete Bucket / /form/center So, as you can see I am taking the 'bucket_value' from $_POST and passing it into the call to S3. When the form comes up on the web I give it the name of one of my S3 buckets. The result is the following error: Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 67 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name
Re: [PHP] Algorithm Help
On 10/1/2013 12:51 PM, Floyd Resler wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd Whatever solution you're going with will probably involve a relational database of some sort. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Algorithm Help
DB or flatfile? I would create a matrix of all kids crossed with every kid. Everytime a kid is put in a home with another kid, ++ that index. When dispatching kids, sort by index ASC. Aziz On Tue, Oct 1, 2013 at 3:01 PM, John Meyer johnme...@pueblocomputing.comwrote: On 10/1/2013 12:51 PM, Floyd Resler wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd Whatever solution you're going with will probably involve a relational database of some sort. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Algorithm Help
On Tue, 2013-10-01 at 15:09 -0400, Aziz Saleh wrote: DB or flatfile? I would create a matrix of all kids crossed with every kid. Everytime a kid is put in a home with another kid, ++ that index. When dispatching kids, sort by index ASC. Aziz On Tue, Oct 1, 2013 at 3:01 PM, John Meyer johnme...@pueblocomputing.comwrote: On 10/1/2013 12:51 PM, Floyd Resler wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd Whatever solution you're going with will probably involve a relational database of some sort. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This sounds remarkably like homework, which we can't help you with unless you've got a specific problem that you're stuck with. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Algorithm Help
m 1375 GLENDALE MILFORD RD., CINCINNATI, OH 45215 On Oct 1, 2013, at 3:14 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2013-10-01 at 15:09 -0400, Aziz Saleh wrote: DB or flatfile? I would create a matrix of all kids crossed with every kid. Everytime a kid is put in a home with another kid, ++ that index. When dispatching kids, sort by index ASC. Aziz On Tue, Oct 1, 2013 at 3:01 PM, John Meyer johnme...@pueblocomputing.comwrote: On 10/1/2013 12:51 PM, Floyd Resler wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd Whatever solution you're going with will probably involve a relational database of some sort. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This sounds remarkably like homework, which we can't help you with unless you've got a specific problem that you're stuck with. Thanks, Ash http://www.ashleysheridan.co.uk Oh, no, this is definitely not homework! :) Although it certainly seems like a homework question. This is a real world problem. I'm keeping track of which kids stay with which host families in the database. My initial approach was to start with kid 1 and see how many times the other kids have stayed with kid 1. The move on to kid 2, and so it. This gives me a score for pairs of kids. However, if say three kids are staying at a host family, what is the best way to determine which set of three kids have stayed together the least? Thanks! Floyd
Re: [PHP] Algorithm Help
Assuming you don't have to be exact, somthing similar to this might work. Assign each kid to a host family randomly for each kid, check how frequently it has been combined with the kids in its assigned family. if it is too close, swap with a different family when all kids in that family are processed, move on to the next family and repeat, excluding the first family for swapping. do the same for all families excluding the previous families. when you have completed all families, do another iteration or two of the whole process. Kind regards/met vriendelijke groet, Serge Fonville http://www.sergefonville.nl 2013/10/1 Floyd Resler fres...@adex-intl.com m 1375 GLENDALE MILFORD RD., CINCINNATI, OH 45215 On Oct 1, 2013, at 3:14 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2013-10-01 at 15:09 -0400, Aziz Saleh wrote: DB or flatfile? I would create a matrix of all kids crossed with every kid. Everytime a kid is put in a home with another kid, ++ that index. When dispatching kids, sort by index ASC. Aziz On Tue, Oct 1, 2013 at 3:01 PM, John Meyer johnme...@pueblocomputing.comwrote: On 10/1/2013 12:51 PM, Floyd Resler wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd Whatever solution you're going with will probably involve a relational database of some sort. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This sounds remarkably like homework, which we can't help you with unless you've got a specific problem that you're stuck with. Thanks, Ash http://www.ashleysheridan.co.uk Oh, no, this is definitely not homework! :) Although it certainly seems like a homework question. This is a real world problem. I'm keeping track of which kids stay with which host families in the database. My initial approach was to start with kid 1 and see how many times the other kids have stayed with kid 1. The move on to kid 2, and so it. This gives me a score for pairs of kids. However, if say three kids are staying at a host family, what is the best way to determine which set of three kids have stayed together the least? Thanks! Floyd
php-general Digest 30 Sep 2013 18:03:46 -0000 Issue 8383
php-general Digest 30 Sep 2013 18:03:46 - Issue 8383 Topics (messages 322219 through 36): Re: delete S3 bucket with AWS PHP SDK 322219 by: Ashley Sheridan 31 by: Aziz Saleh 32 by: Tim Dunphy 33 by: Aziz Saleh 35 by: Tim Dunphy Re: Switch Statement 30 by: mrfroasty Re: Sending PHP mail with Authentication 34 by: Paul M Foster Re: Is correct to override XML standards? 36 by: buzon.alejandro.ceballos.info Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On Sun, 2013-09-29 at 12:30 -0400, Tim Dunphy wrote: Hi All, I am attempting to delete an empty S3 bucket using the AWS PHP SDK. Here's how they describe the process in the docs: $result = $client-deleteBucket(array( // Bucket is required 'Bucket' = 'string', )); You can find the full entry here: AWS PHP SDK Delete Bucket Docshttp://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket Here's how I approached it in my code: $s3 = new AmazonS3(); $result = $s3-deleteObject(array( 'Bucket' = $bucket_name )); But when I run it, this is the error I get: 'Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(10): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(10): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548' This is line 548 in the above referenced file: // Validate the S3 bucket name if (!$this-validate_bucketname_support($bucket)) { // @codeCoverageIgnoreStart throw new S3_Exception('S3 does not support ' . $bucket . ' as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.'); // @codeCoverageIgnoreEnd } Has anyone played around enough with the AWS SDK to know what I'm doing wrong here? Would anyone else be able to hazard a guess? Thanks Tim Your code is failing because $bucket_name, I suspect, is null. Where do you define this variable before you use it in this bit of code: $result = $s3-deleteObject(array( 'Bucket' = $bucket_name )); Thanks, Ash http://www.ashleysheridan.co.uk ---End Message--- ---BeginMessage--- Hi Tim, Is the call working? Does it actually get deleted? This could just be an issue (which I see alot) where developers do not check for variables or preset them before usage, causing those notices to come up (pretty harmless most of the times). Aziz On Sun, Sep 29, 2013 at 12:30 PM, Tim Dunphy bluethu...@gmail.com wrote: Hi All, I am attempting to delete an empty S3 bucket using the AWS PHP SDK. Here's how they describe the process in the docs: $result = $client-deleteBucket(array( // Bucket is required 'Bucket' = 'string', )); You can find the full entry here: AWS PHP SDK Delete Bucket Docs http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket Here's how I approached it in my code: $s3 = new AmazonS3(); $result = $s3-deleteObject(array( 'Bucket' = $bucket_name )); But when I run it, this is the error I get: 'Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services
[PHP] SOAP: Is correct to override XML standards?
I am working with some WSDL call for a provider. The strange thing is that the SOAP used (for me, as client) should include an 'xml' element, and it is supported by the Php constructor, even that is not correct under XML syntaxis. Why? Is somekind of not validation? This works: ?php $client = new SoapClient($url_wsdl); $params = array( xml = $xml_content, login = $login ); $response = $client-__soapCall(wsdl_method, array($params)); ? But W3 standards: All SOAP messages are encoded using XML (see [W3C Recommendation The XML Specification] for more information on XML). Source: http://www.w3.org/TR/2000/NOTE-SOAP-2508/#_Toc478383492 (Relation with SOAP) Names beginning with the string xml, or with any string which would match (('X'|'x') ('M'|'m') ('L'|'l')), are reserved for standardization in this or future versions of this specification. Source: http://www.w3.org/TR/REC-xml/#sec-common-syn (Common Syntactic Constructs) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
php-general Digest 29 Sep 2013 16:30:23 -0000 Issue 8382
php-general Digest 29 Sep 2013 16:30:23 - Issue 8382 Topics (messages 322207 through 322218): Re: Switch Statement 322207 by: Aziz Saleh 322209 by: Jim Giner 322210 by: Jim Giner 322212 by: Ethan Rosenberg 322213 by: Ethan Rosenberg 322214 by: Jim Giner 322215 by: Jim Giner 322217 by: Aziz Saleh Re: create a local temp table in local machine 322208 by: Bastien 322211 by: iccsi Running a command without shell 322216 by: vitalif.yourcmc.ru delete S3 bucket with AWS PHP SDK 322218 by: Tim Dunphy Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- Ethan, can you do a var_dump instead of print_r. It might be that next_step has spaces in it causing the switch to not match. Aziz On Sat, Sep 28, 2013 at 10:33 PM, Ethan Rosenberg erosenb...@hygeiabiomedical.com wrote: Dear List - I have a working program. I made one change in a switch statement, and it does not work. I'm probably missing something fundamental. Here are some code SNIPPETS... [please note that all my debug statements are at the left margin] Setup... ?php session_start(); session_name(STORE); set_time_limit(2400); ini_set('display_errors', 'on'); ini_set('display_startup_**errors', 'on'); error_reporting(-2); ini_set('error_reporting', 'E_ALL | E_STRICT'); ini_set('html_errors', 'On'); ini_set('log_errors', 'On'); require '/home/ethan/P/wk.inc'; //password file $db = Store; $cxn =mysqli_connect($host,$user,$**password,$db); if (!$cxn) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); }// no error if($_REQUEST['welcome_already_**seen']!= already_seen) show_welcome(); //end setup function show_welcome() //this is the input screen { snip echo input type='hidden' name='welcome_already_seen' value='already_seen'; echo input type='hidden' name='next_step' value='step20' /; snip } //end input screen //Switch statement echo 'before'; print_r($_POST); //post#1 switch ( $_POST['next_step'] ) { case 'step20': { pint_r($_POST); //post#2 echo 'step20'; if(!empty($_POST['Cust_Num'])) good(); if(empty($_POST['Cust_Num'])) bad(); break; } //end step20 snip } //end switch post#1 beforeArray ( [Cust_Num] = 123 [Fname] = [Lname] = [Street] = [City] = [state] = NY [Zip] = 10952 [PH1] = [PH2] = [PH3] = [Date] = [welcome_already_seen] = already_seen [next_step] = step20 ) Cust_Num state and Zip are as entered. The switch statement is never entered, since post#2 is never displayed, and neither good() or bad() functions are entered. TIA Ethan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- On 9/28/2013 10:33 PM, Ethan Rosenberg wrote: Dear List - I have a working program. I made one change in a switch statement, and it does not work. I'm probably missing something fundamental. Here are some code SNIPPETS... [please note that all my debug statements are at the left margin] Setup... ?php session_start(); session_name(STORE); set_time_limit(2400); ini_set('display_errors', 'on'); ini_set('display_startup_errors', 'on'); error_reporting(-2); ini_set('error_reporting', 'E_ALL | E_STRICT'); ini_set('html_errors', 'On'); ini_set('log_errors', 'On'); require '/home/ethan/P/wk.inc'; //password file $db = Store; $cxn =mysqli_connect($host,$user,$password,$db); if (!$cxn) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); }// no error if($_REQUEST['welcome_already_seen']!= already_seen) show_welcome(); //end setup function show_welcome() //this is the input screen { snip echo input type='hidden' name='welcome_already_seen' value='already_seen'; echo input type='hidden' name='next_step' value='step20' /; snip } //end input screen //Switch statement echo 'before'; print_r($_POST); //post#1 switch
[PHP] Running a command without shell
Hi! Is it possible to run a command and capture its output via an FD (like in proc_open()), but without using the shell? As far as I can see now there is no way to do it. I think that's a simple feature, maybe just add it to proc_open()? (for example run command directly using exec() if the first argument is an array?) it would be rational because there is already such option for Windows... -- With best regards, Vitaliy Filippov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Switch Statement
What is the output? On Sun, Sep 29, 2013 at 1:34 AM, Ethan Rosenberg erosenb...@hygeiabiomedical.com wrote: On 09/28/2013 10:53 PM, Aziz Saleh wrote: Ethan, can you do a var_dump instead of print_r. It might be that next_step has spaces in it causing the switch to not match. Aziz snip Aziz - Used var_dump no further information Ethan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] delete S3 bucket with AWS PHP SDK
Hi All, I am attempting to delete an empty S3 bucket using the AWS PHP SDK. Here's how they describe the process in the docs: $result = $client-deleteBucket(array( // Bucket is required 'Bucket' = 'string', )); You can find the full entry here: AWS PHP SDK Delete Bucket Docshttp://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket Here's how I approached it in my code: $s3 = new AmazonS3(); $result = $s3-deleteObject(array( 'Bucket' = $bucket_name )); But when I run it, this is the error I get: 'Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(10): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(10): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548' This is line 548 in the above referenced file: // Validate the S3 bucket name if (!$this-validate_bucketname_support($bucket)) { // @codeCoverageIgnoreStart throw new S3_Exception('S3 does not support ' . $bucket . ' as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.'); // @codeCoverageIgnoreEnd } Has anyone played around enough with the AWS SDK to know what I'm doing wrong here? Would anyone else be able to hazard a guess? Thanks Tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
Re: [PHP] delete S3 bucket with AWS PHP SDK
On Sun, 2013-09-29 at 12:30 -0400, Tim Dunphy wrote: Hi All, I am attempting to delete an empty S3 bucket using the AWS PHP SDK. Here's how they describe the process in the docs: $result = $client-deleteBucket(array( // Bucket is required 'Bucket' = 'string', )); You can find the full entry here: AWS PHP SDK Delete Bucket Docshttp://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket Here's how I approached it in my code: $s3 = new AmazonS3(); $result = $s3-deleteObject(array( 'Bucket' = $bucket_name )); But when I run it, this is the error I get: 'Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(10): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(10): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548' This is line 548 in the above referenced file: // Validate the S3 bucket name if (!$this-validate_bucketname_support($bucket)) { // @codeCoverageIgnoreStart throw new S3_Exception('S3 does not support ' . $bucket . ' as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.'); // @codeCoverageIgnoreEnd } Has anyone played around enough with the AWS SDK to know what I'm doing wrong here? Would anyone else be able to hazard a guess? Thanks Tim Your code is failing because $bucket_name, I suspect, is null. Where do you define this variable before you use it in this bit of code: $result = $s3-deleteObject(array( 'Bucket' = $bucket_name )); Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Switch Statement
Hello, I suggest you put default in that switch statement and var_dump the $_POST.That should be enough for a programmer to pin point what goes wrong. P:S **You might want to consider versioning your codes to go back into its history to see what has changed. Muhsin On 09/29/2013 04:33 AM, Ethan Rosenberg wrote: Dear List - I have a working program. I made one change in a switch statement, and it does not work. I'm probably missing something fundamental. Here are some code SNIPPETS... [please note that all my debug statements are at the left margin] Setup... ?php session_start(); session_name(STORE); set_time_limit(2400); ini_set('display_errors', 'on'); ini_set('display_startup_errors', 'on'); error_reporting(-2); ini_set('error_reporting', 'E_ALL | E_STRICT'); ini_set('html_errors', 'On'); ini_set('log_errors', 'On'); require '/home/ethan/P/wk.inc'; //password file $db = Store; $cxn =mysqli_connect($host,$user,$password,$db); if (!$cxn) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); }// no error if($_REQUEST['welcome_already_seen']!= already_seen) show_welcome(); //end setup function show_welcome() //this is the input screen { snip echo input type='hidden' name='welcome_already_seen' value='already_seen'; echo input type='hidden' name='next_step' value='step20' /; snip } //end input screen //Switch statement echo 'before'; print_r($_POST); //post#1 switch ( $_POST['next_step'] ) { case 'step20': { pint_r($_POST);//post#2 echo 'step20'; if(!empty($_POST['Cust_Num'])) good(); if(empty($_POST['Cust_Num'])) bad(); break; } //end step20 snip } //end switch post#1 beforeArray ( [Cust_Num] = 123 [Fname] = [Lname] = [Street] = [City] = [state] = NY [Zip] = 10952 [PH1] = [PH2] = [PH3] = [Date] = [welcome_already_seen] = already_seen [next_step] = step20 ) Cust_Num state and Zip are as entered. The switch statement is never entered, since post#2 is never displayed, and neither good() or bad() functions are entered. TIA Ethan -- Extra details: OSS:Gentoo Linux profile:x86 Hardware:msi geforce 8600GT asus p5k-se location:/home/muhsin language(s):C/C++,PHP Typo:40WPM url:http://www.mzalendo.net url:http://www.zanbytes.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] delete S3 bucket with AWS PHP SDK
Hi Tim, Is the call working? Does it actually get deleted? This could just be an issue (which I see alot) where developers do not check for variables or preset them before usage, causing those notices to come up (pretty harmless most of the times). Aziz On Sun, Sep 29, 2013 at 12:30 PM, Tim Dunphy bluethu...@gmail.com wrote: Hi All, I am attempting to delete an empty S3 bucket using the AWS PHP SDK. Here's how they describe the process in the docs: $result = $client-deleteBucket(array( // Bucket is required 'Bucket' = 'string', )); You can find the full entry here: AWS PHP SDK Delete Bucket Docs http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket Here's how I approached it in my code: $s3 = new AmazonS3(); $result = $s3-deleteObject(array( 'Bucket' = $bucket_name )); But when I run it, this is the error I get: 'Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(10): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(10): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548' This is line 548 in the above referenced file: // Validate the S3 bucket name if (!$this-validate_bucketname_support($bucket)) { // @codeCoverageIgnoreStart throw new S3_Exception('S3 does not support ' . $bucket . ' as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.'); // @codeCoverageIgnoreEnd } Has anyone played around enough with the AWS SDK to know what I'm doing wrong here? Would anyone else be able to hazard a guess? Thanks Tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
Re: [PHP] delete S3 bucket with AWS PHP SDK
Hey guys, Sorry about that i should have posted the full code to give you some idea of context. Anyway, here it is: ?php require_once 'sdk.class.php'; if (isset($_POST['submit'])) { * $bucket_name = $_POST['$bucket_name'];* // Create the S3 Object from the SDK *$s3 = new AmazonS3();* * $result = $s3-deleteObject(array(* *'Bucket' = $bucket_name ));* // The response comes back as a Simple XML Object // In this case we just want to know if everything was okay. // If not, report the message from the XML response. if ((int) $response-isOK()) { echo 'centerDeleted Bucket'; echo 'br /br /'; echo 'a href=listbuckets.phpList Buckets/a/center'; } else { echo (string) $response-body-Message; } //echo 'br /br /'; } ? body centerh3Delete S3 Bucket/h3 form name=delete_bucket method=post action=delete_bucket.php label for=bucket_nameBucket Name:/labelbr / * input type=text id=bucket_name name=bucket_name /br /br /* input type=submit name=submit value=Delete Bucket / /form/center So, as you can see I am taking the 'bucket_value' from $_POST and passing it into the call to S3. When the form comes up on the web I give it the name of one of my S3 buckets. The result is the following error: Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 67 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(72): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(72): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548 I hope that clarifies my situation a bit. Sorry for not providing that sooner! Thanks Tim On Sun, Sep 29, 2013 at 1:09 PM, Aziz Saleh azizsa...@gmail.com wrote: Hi Tim, Is the call working? Does it actually get deleted? This could just be an issue (which I see alot) where developers do not check for variables or preset them before usage, causing those notices to come up (pretty harmless most of the times). Aziz On Sun, Sep 29, 2013 at 12:30 PM, Tim Dunphy bluethu...@gmail.com wrote: Hi All, I am attempting to delete an empty S3 bucket using the AWS PHP SDK. Here's how they describe the process in the docs: $result = $client-deleteBucket(array( // Bucket is required 'Bucket' = 'string', )); You can find the full entry here: AWS PHP SDK Delete Bucket Docs http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket Here's how I approached it in my code: $s3 = new AmazonS3(); $result = $s3-deleteObject(array( 'Bucket' = $bucket_name )); But when I run it, this is the error I get: 'Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(10): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(10): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548' This is line 548 in the above referenced file: // Validate the S3 bucket name if (!$this-validate_bucketname_support($bucket
Re: [PHP] delete S3 bucket with AWS PHP SDK
No Problem, the issue is that you referring to the invalid post element $bucket_name as opposed to the correct on bucket_name. *$bucket_name = $_POST['$bucket_name'];* Should be *$bucket_name = $_POST['bucket_name'];* Aziz On Sun, Sep 29, 2013 at 3:28 PM, Tim Dunphy bluethu...@gmail.com wrote: Hey guys, Sorry about that i should have posted the full code to give you some idea of context. Anyway, here it is: ?php require_once 'sdk.class.php'; if (isset($_POST['submit'])) { * $bucket_name = $_POST['$bucket_name'];* // Create the S3 Object from the SDK *$s3 = new AmazonS3();* * $result = $s3-deleteObject(array(* *'Bucket' = $bucket_name ));* // The response comes back as a Simple XML Object // In this case we just want to know if everything was okay. // If not, report the message from the XML response. if ((int) $response-isOK()) { echo 'centerDeleted Bucket'; echo 'br /br /'; echo 'a href=listbuckets.phpList Buckets/a/center'; } else { echo (string) $response-body-Message; } //echo 'br /br /'; } ? body centerh3Delete S3 Bucket/h3 form name=delete_bucket method=post action=delete_bucket.php label for=bucket_nameBucket Name:/labelbr / * input type=text id=bucket_name name=bucket_name /br /br / * input type=submit name=submit value=Delete Bucket / /form/center So, as you can see I am taking the 'bucket_value' from $_POST and passing it into the call to S3. When the form comes up on the web I give it the name of one of my S3 buckets. The result is the following error: Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 67 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(72): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(72): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548 I hope that clarifies my situation a bit. Sorry for not providing that sooner! Thanks Tim On Sun, Sep 29, 2013 at 1:09 PM, Aziz Saleh azizsa...@gmail.com wrote: Hi Tim, Is the call working? Does it actually get deleted? This could just be an issue (which I see alot) where developers do not check for variables or preset them before usage, causing those notices to come up (pretty harmless most of the times). Aziz On Sun, Sep 29, 2013 at 12:30 PM, Tim Dunphy bluethu...@gmail.comwrote: Hi All, I am attempting to delete an empty S3 bucket using the AWS PHP SDK. Here's how they describe the process in the docs: $result = $client-deleteBucket(array( // Bucket is required 'Bucket' = 'string', )); You can find the full entry here: AWS PHP SDK Delete Bucket Docs http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket Here's how I approached it in my code: $s3 = new AmazonS3(); $result = $s3-deleteObject(array( 'Bucket' = $bucket_name )); But when I run it, this is the error I get: 'Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(10
Re: [PHP] Re: Sending PHP mail with Authentication
On Fri, Sep 27, 2013 at 12:06:30AM +0200, Maciek Sokolewicz wrote: [snip] I'm sure I'm going to annoy people with this, but I would advise to never use PEAR. It's the biggest load of extremely badly coded PHP you'll ever find. Creating an SMTP client (with the purpose of just sending mail) is very easy to do yourself (and also a good challenge if you're not yet very skilled with PHP). Alternatively, you can indeed use a package such as PHPMailer; it's not perfect, and quite bloated for what you want probably, but it works rather well. I have to agree on the code bloat. Unless your requirements are extraordinary (which the OP's are), the native PHP mail() function is generally quite adequate. Never thought about creating a PHP email client. Interesting idea... Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] delete S3 bucket with AWS PHP SDK
Hi Aziz, Thank you for getting back to me! I appreciate you spotting that error. So I corrected that ?php require_once 'sdk.class.php'; if (isset($_POST['submit'])) { * $bucket_name = $_POST['bucket_name'];* // Create the S3 Object from the SDK $s3 = new AmazonS3(); * $result = $s3-deleteObject(array( 'Bucket' = $bucket_name ));* // The response comes back as a Simple XML Object // In this case we just want to know if everything was okay. // If not, report the message from the XML response. if ((int) $response-isOK()) { echo 'centerDeleted Bucket'; echo 'br /br /'; echo 'a href=listbuckets.phpList Buckets/a/center'; } else { echo (string) $response-body-Message; } //echo 'br /br /'; } ? body centerh3Delete S3 Bucket/h3 form name=delete_bucket method=post action=delete_bucket.php label for=bucket_nameBucket Name:/labelbr / * input type=text id=bucket_name name=bucket_name /br /br /* input type=submit name=submit value=Delete Bucket / /form/center script /body /html And this is the error I am currently getting: Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(72): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(72): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548 Not sure if I'm getting closer here... but definitely appreciate any advice anyone may have. Thanks! Tim On Sun, Sep 29, 2013 at 5:04 PM, Aziz Saleh azizsa...@gmail.com wrote: No Problem, the issue is that you referring to the invalid post element $bucket_name as opposed to the correct on bucket_name. *$bucket_name = $_POST['$bucket_name'];* Should be *$bucket_name = $_POST['bucket_name'];* Aziz On Sun, Sep 29, 2013 at 3:28 PM, Tim Dunphy bluethu...@gmail.com wrote: Hey guys, Sorry about that i should have posted the full code to give you some idea of context. Anyway, here it is: ?php require_once 'sdk.class.php'; if (isset($_POST['submit'])) { * $bucket_name = $_POST['$bucket_name'];* // Create the S3 Object from the SDK *$s3 = new AmazonS3();* * $result = $s3-deleteObject(array(* *'Bucket' = $bucket_name ));* // The response comes back as a Simple XML Object // In this case we just want to know if everything was okay. // If not, report the message from the XML response. if ((int) $response-isOK()) { echo 'centerDeleted Bucket'; echo 'br /br /'; echo 'a href=listbuckets.phpList Buckets/a/center'; } else { echo (string) $response-body-Message; } //echo 'br /br /'; } ? body centerh3Delete S3 Bucket/h3 form name=delete_bucket method=post action=delete_bucket.php label for=bucket_nameBucket Name:/labelbr / * input type=text id=bucket_name name=bucket_name /br /br /* input type=submit name=submit value=Delete Bucket / /form/center So, as you can see I am taking the 'bucket_value' from $_POST and passing it into the call to S3. When the form comes up on the web I give it the name of one of my S3 buckets. The result is the following error: Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 67 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436
php-general Digest 28 Sep 2013 12:26:53 -0000 Issue 8380
php-general Digest 28 Sep 2013 12:26:53 - Issue 8380 Topics (messages 322200 through 322200): Re: How to capture uploaded file data 322200 by: Bastien Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- Thanks, Bastien On Sep 27, 2013, at 12:56 AM, Mariusz Drozdowski scheme...@wp.pl wrote: Hi all php experts, I would like to ask you all a question, I hope this is the right place to ask it. I'm writing a PHP extension now in c/c++. User uploads a file (could be POST or PUT method, but I can limit it to POST only). I need to capture the file data while being uploaded, without writing it to disk on the server. I need to process the data and (maybe, depending on a situation) send it somewhere else or save it to disk. Of course I know, that I can process the file after it has been uploaded (saved on disk on the server), but I would like to avoid it. I also need to do something opposite: I need to generate a file on the fly and send it to the user. All metadata of the generated file is known beforehand (e.g. size, name). I've been searching around for some time now and I could not find anything even close to the solution. Is there any example(s) or existing PHP extension that do(es) something like this (at least something simmilar) ? If you could give me any pointers that would be awesome. Thanks for your help The question I have is why? Should your upload fail for any reason you've got a half processed file that is non-recoverable. No do-overs. If you stick to the standard processes with out the extension, Upload Save somewhere (or leave in temp upload folder) Process Send result back to user Unlink file Generating the file and sending it to the user is also pretty standard Create your dataset Send appropriate headers Send data Close connection For this, there usually isn't a need to save the file. You may run into issues streaming the data to certain browsers. Also one of the main downsides to your upload is high load situations or large file situations (where file size exceeds php's upload limit). My personal preference is to save that file to disk so that if needed I can work with it later ( if say the server load is high) and email the results to the user. ---End Message---
php-general Digest 29 Sep 2013 02:33:32 -0000 Issue 8381
php-general Digest 29 Sep 2013 02:33:32 - Issue 8381 Topics (messages 322201 through 322206): create a local temp table in local machine 322201 by: iccsi 322202 by: Bastien 322203 by: iccsi 322204 by: Bastien 322205 by: iccsi Switch Statement 322206 by: Ethan Rosenberg Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- I need create a local table on the local machine. I would like to know is it possible to down on server side or client side or jQuery to do the work. Your information and help is great appreciated, regards, Iccsi, ---End Message--- ---BeginMessage--- Thanks, Bastien On Sep 28, 2013, at 3:24 PM, iccsi inu...@gmail.com wrote: I need create a local table on the local machine. I would like to know is it possible to down on server side or client side or jQuery to do the work. Your information and help is great appreciated, regards, Iccsi If you're looking to create a SQl table then most but not all browsers can use SQLite locally for data storage ( it does require newer browsers). You haven't stated the goal for this so other options could include sending csv or json data down to the browser and using jquery, angular or some other JS framework to manipulate that data may also be an option ---End Message--- ---BeginMessage--- Thanks for the message and help, because I use jQuery autocomplete which has performance issue for thousands records due to network load data. I want to load the data to local table to resolve performance issue, if it possible I can load to an array in the memory. Thanks again for helping, Regards, iccsi, Bastien wrote in message news:2fd3037d-f68d-47b3-ac4f-007d9559d...@gmail.com... Thanks, Bastien On Sep 28, 2013, at 3:24 PM, iccsi inu...@gmail.com wrote: I need create a local table on the local machine. I would like to know is it possible to down on server side or client side or jQuery to do the work. Your information and help is great appreciated, regards, Iccsi If you're looking to create a SQl table then most but not all browsers can use SQLite locally for data storage ( it does require newer browsers). You haven't stated the goal for this so other options could include sending csv or json data down to the browser and using jquery, angular or some other JS framework to manipulate that data may also be an option ---End Message--- ---BeginMessage--- On Sep 28, 2013, at 6:00 PM, iccsi inu...@gmail.com wrote: Thanks for the message and help, because I use jQuery autocomplete which has performance issue for thousands records due to network load data. I want to load the data to local table to resolve performance issue, if it possible I can load to an array in the memory. Thanks again for helping, Regards, iccsi, Bastien wrote in message news:2fd3037d-f68d-47b3-ac4f-007d9559d...@gmail.com... Thanks, Bastien On Sep 28, 2013, at 3:24 PM, iccsi inu...@gmail.com wrote: I need create a local table on the local machine. I would like to know is it possible to down on server side or client side or jQuery to do the work. Your information and help is great appreciated, regards, Iccsi If you're looking to create a SQl table then most but not all browsers can use SQLite locally for data storage ( it does require newer browsers). You haven't stated the goal for this so other options could include sending csv or json data down to the browser and using jquery, angular or some other JS framework to manipulate that data may also be an option I had exactly this situation, large list with the autocomplete. I cached the list to a JS file and ran the autocomplete from that. It works well if the list is relatively static which mine was. It will be tougher if the list is dynamic, but you could send the data down after the initial page load. HTH Bastien---End Message--- ---BeginMessage--- Thanks for the information and help, Yes, my data is pretty much static, Can you please give me some link for the solution? It is the solution I am looking for my current situation, Thanks a million for helping, Regards, Iccsi, Bastien wrote in message news:deb5dfe9-ec7f-4bc5-9e2e-acfb85039...@gmail.com... On Sep 28, 2013, at 6:00 PM, iccsi inu...@gmail.com wrote: Thanks for the message and help, because I use jQuery autocomplete which has performance issue for thousands records due to network load data. I want to load the data to local table to resolve performance issue, if it possible I can load to an array in the memory. Thanks again for helping, Regards, iccsi, Bastien wrote in message news
Re: [PHP] How to capture uploaded file data
Thanks, Bastien On Sep 27, 2013, at 12:56 AM, Mariusz Drozdowski scheme...@wp.pl wrote: Hi all php experts, I would like to ask you all a question, I hope this is the right place to ask it. I'm writing a PHP extension now in c/c++. User uploads a file (could be POST or PUT method, but I can limit it to POST only). I need to capture the file data while being uploaded, without writing it to disk on the server. I need to process the data and (maybe, depending on a situation) send it somewhere else or save it to disk. Of course I know, that I can process the file after it has been uploaded (saved on disk on the server), but I would like to avoid it. I also need to do something opposite: I need to generate a file on the fly and send it to the user. All metadata of the generated file is known beforehand (e.g. size, name). I've been searching around for some time now and I could not find anything even close to the solution. Is there any example(s) or existing PHP extension that do(es) something like this (at least something simmilar) ? If you could give me any pointers that would be awesome. Thanks for your help The question I have is why? Should your upload fail for any reason you've got a half processed file that is non-recoverable. No do-overs. If you stick to the standard processes with out the extension, Upload Save somewhere (or leave in temp upload folder) Process Send result back to user Unlink file Generating the file and sending it to the user is also pretty standard Create your dataset Send appropriate headers Send data Close connection For this, there usually isn't a need to save the file. You may run into issues streaming the data to certain browsers. Also one of the main downsides to your upload is high load situations or large file situations (where file size exceeds php's upload limit). My personal preference is to save that file to disk so that if needed I can work with it later ( if say the server load is high) and email the results to the user. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] create a local temp table in local machine
I need create a local table on the local machine. I would like to know is it possible to down on server side or client side or jQuery to do the work. Your information and help is great appreciated, regards, Iccsi, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] create a local temp table in local machine
Thanks, Bastien On Sep 28, 2013, at 3:24 PM, iccsi inu...@gmail.com wrote: I need create a local table on the local machine. I would like to know is it possible to down on server side or client side or jQuery to do the work. Your information and help is great appreciated, regards, Iccsi If you're looking to create a SQl table then most but not all browsers can use SQLite locally for data storage ( it does require newer browsers). You haven't stated the goal for this so other options could include sending csv or json data down to the browser and using jquery, angular or some other JS framework to manipulate that data may also be an option -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] create a local temp table in local machine
Thanks for the message and help, because I use jQuery autocomplete which has performance issue for thousands records due to network load data. I want to load the data to local table to resolve performance issue, if it possible I can load to an array in the memory. Thanks again for helping, Regards, iccsi, Bastien wrote in message news:2fd3037d-f68d-47b3-ac4f-007d9559d...@gmail.com... Thanks, Bastien On Sep 28, 2013, at 3:24 PM, iccsi inu...@gmail.com wrote: I need create a local table on the local machine. I would like to know is it possible to down on server side or client side or jQuery to do the work. Your information and help is great appreciated, regards, Iccsi If you're looking to create a SQl table then most but not all browsers can use SQLite locally for data storage ( it does require newer browsers). You haven't stated the goal for this so other options could include sending csv or json data down to the browser and using jquery, angular or some other JS framework to manipulate that data may also be an option -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] create a local temp table in local machine
On Sep 28, 2013, at 6:00 PM, iccsi inu...@gmail.com wrote: Thanks for the message and help, because I use jQuery autocomplete which has performance issue for thousands records due to network load data. I want to load the data to local table to resolve performance issue, if it possible I can load to an array in the memory. Thanks again for helping, Regards, iccsi, Bastien wrote in message news:2fd3037d-f68d-47b3-ac4f-007d9559d...@gmail.com... Thanks, Bastien On Sep 28, 2013, at 3:24 PM, iccsi inu...@gmail.com wrote: I need create a local table on the local machine. I would like to know is it possible to down on server side or client side or jQuery to do the work. Your information and help is great appreciated, regards, Iccsi If you're looking to create a SQl table then most but not all browsers can use SQLite locally for data storage ( it does require newer browsers). You haven't stated the goal for this so other options could include sending csv or json data down to the browser and using jquery, angular or some other JS framework to manipulate that data may also be an option I had exactly this situation, large list with the autocomplete. I cached the list to a JS file and ran the autocomplete from that. It works well if the list is relatively static which mine was. It will be tougher if the list is dynamic, but you could send the data down after the initial page load. HTH Bastien -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] create a local temp table in local machine
Thanks for the information and help, Yes, my data is pretty much static, Can you please give me some link for the solution? It is the solution I am looking for my current situation, Thanks a million for helping, Regards, Iccsi, Bastien wrote in message news:deb5dfe9-ec7f-4bc5-9e2e-acfb85039...@gmail.com... On Sep 28, 2013, at 6:00 PM, iccsi inu...@gmail.com wrote: Thanks for the message and help, because I use jQuery autocomplete which has performance issue for thousands records due to network load data. I want to load the data to local table to resolve performance issue, if it possible I can load to an array in the memory. Thanks again for helping, Regards, iccsi, Bastien wrote in message news:2fd3037d-f68d-47b3-ac4f-007d9559d...@gmail.com... Thanks, Bastien On Sep 28, 2013, at 3:24 PM, iccsi inu...@gmail.com wrote: I need create a local table on the local machine. I would like to know is it possible to down on server side or client side or jQuery to do the work. Your information and help is great appreciated, regards, Iccsi If you're looking to create a SQl table then most but not all browsers can use SQLite locally for data storage ( it does require newer browsers). You haven't stated the goal for this so other options could include sending csv or json data down to the browser and using jquery, angular or some other JS framework to manipulate that data may also be an option I had exactly this situation, large list with the autocomplete. I cached the list to a JS file and ran the autocomplete from that. It works well if the list is relatively static which mine was. It will be tougher if the list is dynamic, but you could send the data down after the initial page load. HTH Bastien= -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Switch Statement
Dear List - I have a working program. I made one change in a switch statement, and it does not work. I'm probably missing something fundamental. Here are some code SNIPPETS... [please note that all my debug statements are at the left margin] Setup... ?php session_start(); session_name(STORE); set_time_limit(2400); ini_set('display_errors', 'on'); ini_set('display_startup_errors', 'on'); error_reporting(-2); ini_set('error_reporting', 'E_ALL | E_STRICT'); ini_set('html_errors', 'On'); ini_set('log_errors', 'On'); require '/home/ethan/P/wk.inc'; //password file $db = Store; $cxn =mysqli_connect($host,$user,$password,$db); if (!$cxn) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); }// no error if($_REQUEST['welcome_already_seen']!= already_seen) show_welcome(); //end setup function show_welcome() //this is the input screen { snip echo input type='hidden' name='welcome_already_seen' value='already_seen'; echo input type='hidden' name='next_step' value='step20' /; snip } //end input screen //Switch statement echo 'before'; print_r($_POST); //post#1 switch ( $_POST['next_step'] ) { case 'step20': { pint_r($_POST); //post#2 echo 'step20'; if(!empty($_POST['Cust_Num'])) good(); if(empty($_POST['Cust_Num'])) bad(); break; } //end step20 snip } //end switch post#1 beforeArray ( [Cust_Num] = 123 [Fname] = [Lname] = [Street] = [City] = [state] = NY [Zip] = 10952 [PH1] = [PH2] = [PH3] = [Date] = [welcome_already_seen] = already_seen [next_step] = step20 ) Cust_Num state and Zip are as entered. The switch statement is never entered, since post#2 is never displayed, and neither good() or bad() functions are entered. TIA Ethan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Switch Statement
Ethan, can you do a var_dump instead of print_r. It might be that next_step has spaces in it causing the switch to not match. Aziz On Sat, Sep 28, 2013 at 10:33 PM, Ethan Rosenberg erosenb...@hygeiabiomedical.com wrote: Dear List - I have a working program. I made one change in a switch statement, and it does not work. I'm probably missing something fundamental. Here are some code SNIPPETS... [please note that all my debug statements are at the left margin] Setup... ?php session_start(); session_name(STORE); set_time_limit(2400); ini_set('display_errors', 'on'); ini_set('display_startup_**errors', 'on'); error_reporting(-2); ini_set('error_reporting', 'E_ALL | E_STRICT'); ini_set('html_errors', 'On'); ini_set('log_errors', 'On'); require '/home/ethan/P/wk.inc'; //password file $db = Store; $cxn =mysqli_connect($host,$user,$**password,$db); if (!$cxn) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); }// no error if($_REQUEST['welcome_already_**seen']!= already_seen) show_welcome(); //end setup function show_welcome() //this is the input screen { snip echo input type='hidden' name='welcome_already_seen' value='already_seen'; echo input type='hidden' name='next_step' value='step20' /; snip } //end input screen //Switch statement echo 'before'; print_r($_POST); //post#1 switch ( $_POST['next_step'] ) { case 'step20': { pint_r($_POST); //post#2 echo 'step20'; if(!empty($_POST['Cust_Num'])) good(); if(empty($_POST['Cust_Num'])) bad(); break; } //end step20 snip } //end switch post#1 beforeArray ( [Cust_Num] = 123 [Fname] = [Lname] = [Street] = [City] = [state] = NY [Zip] = 10952 [PH1] = [PH2] = [PH3] = [Date] = [welcome_already_seen] = already_seen [next_step] = step20 ) Cust_Num state and Zip are as entered. The switch statement is never entered, since post#2 is never displayed, and neither good() or bad() functions are entered. TIA Ethan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] create a local temp table in local machine
Thanks, Bastien On Sep 28, 2013, at 8:24 PM, iccsi inu...@gmail.com wrote: Thanks for the information and help, Yes, my data is pretty much static, Can you please give me some link for the solution? It is the solution I am looking for my current situation, Thanks a million for helping, Regards, Iccsi, I don't have a link unfortunately. The system I did it for is proprietary. But I do recall it was a pretty switch in the JS to view the list from the static file. The JS file with the static data was just an array and the autocomplete looked at that as the data source Sorry Bastien -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Switch Statement
On 9/28/2013 10:33 PM, Ethan Rosenberg wrote: Dear List - I have a working program. I made one change in a switch statement, and it does not work. I'm probably missing something fundamental. Here are some code SNIPPETS... [please note that all my debug statements are at the left margin] Setup... ?php session_start(); session_name(STORE); set_time_limit(2400); ini_set('display_errors', 'on'); ini_set('display_startup_errors', 'on'); error_reporting(-2); ini_set('error_reporting', 'E_ALL | E_STRICT'); ini_set('html_errors', 'On'); ini_set('log_errors', 'On'); require '/home/ethan/P/wk.inc'; //password file $db = Store; $cxn =mysqli_connect($host,$user,$password,$db); if (!$cxn) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); }// no error if($_REQUEST['welcome_already_seen']!= already_seen) show_welcome(); //end setup function show_welcome() //this is the input screen { snip echo input type='hidden' name='welcome_already_seen' value='already_seen'; echo input type='hidden' name='next_step' value='step20' /; snip } //end input screen //Switch statement echo 'before'; print_r($_POST); //post#1 switch ( $_POST['next_step'] ) { case 'step20': { pint_r($_POST);//post#2 echo 'step20'; if(!empty($_POST['Cust_Num'])) good(); if(empty($_POST['Cust_Num'])) bad(); break; } //end step20 snip } //end switch post#1 beforeArray ( [Cust_Num] = 123 [Fname] = [Lname] = [Street] = [City] = [state] = NY [Zip] = 10952 [PH1] = [PH2] = [PH3] = [Date] = [welcome_already_seen] = already_seen [next_step] = step20 ) Cust_Num state and Zip are as entered. The switch statement is never entered, since post#2 is never displayed, and neither good() or bad() functions are entered. TIA Ethan Once again you are posting code that has no chance of running. And since you are DISABLING error reporting with that -2 value you won't even know you have bad code. Try again. Post#2 will never display since you aren't printing it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php