Re: [PHP] Split/Group date together.
If I understand you correctly, I call what you're trying to do PHP group by, and did a write up on it a few years back: http://www.garfieldtech.com/blog/php-group-by-with-arrays --Larry Garfield On 7/18/13 8:43 AM, Karl-Arne Gjersøyen wrote: Hello again. In my program I have this: mysql SELECT * FROM transportdokument WHERE dato = '16/7/2013' AND dato = '18/7/2013'; This list all reccrds for 3 days. I need a way to split it up for every day even when the requst is as above and don't know in what way I can do it. I like to have all records for day 16 in one table in PHP/HTML and all records for day 17 in another table. i.e, Day 16 have 5 rows and day 17th and 18th have 7 and 8 rows. I hope for your help and advice to do also this correct. Thank you for your time and effort! Karl -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I am completely lost and need an advice (beginner)
On Fri, Jul 19, 2013 at 1:08 AM, php colos phpco...@gmail.com wrote: Am I reading the wrong books for a beginner? Do you just read the book or also do what it says to do? If you just read but dont code along with it, you may not learn anything. After reading a lot of book you'll feel you have understand a lot of things. But thats true when you read. Not when you code. Just follow the instructions on the book. I hope you'll be able to write a lot of code. -- Shiplu.Mokadd.im ImgSign.com | A dynamic signature machine Innovation distinguishes between follower and leader
Re: [PHP] I am completely lost and need an advice (beginner)
On Thu, Jul 18, 2013 at 3:08 PM, php colos phpco...@gmail.com wrote: Hello world! I'm trying to learn PHP ( first programming language that I learn) and I feel kinda lost. I've read PHP programming 3rd edition( O'reilly), 'getting good with PHP' by Andrew Burgees and some tutorials on the internet but can't code something more complex than 'hello world'. I do understand functions/values/operators/control structures, etc but as I said, I feel that I can't use the language. Am I reading the wrong books for a beginner? Any advices? *Apologies if this email might seem confusing. :) Perhaps I'm biased, but I think other folks will agree --- the official documentation is your best source of learning second only to your own experiences with the language. Check through the user notes as well, as they often provide very valuable insight and other developers' personal experiences. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I am completely lost and need an advice (beginner)
On 07/18/2013 09:08 PM, php colos wrote: Hello world! I'm trying to learn PHP ( first programming language that I learn) and I feel kinda lost. I've read PHP programming 3rd edition( O'reilly), 'getting good with PHP' by Andrew Burgees and some tutorials on the internet but can't code something more complex than 'hello world'. I do understand functions/values/operators/control structures, etc but as I said, I feel that I can't use the language. Am I reading the wrong books for a beginner? Any advices? *Apologies if this email might seem confusing. :) Richard As others have mentioned, reading only isn't a good thing. You'll need to code alongside reading. You also might need to have a goal/project to motivate you to code. Starting small is a good thing. Or you could help out some of the smaller php projects that have only a few coders. Fixing bugs in a project can be a great help, and you'll learn a lot. If you don't have any project in mind, you can go to codecademy.com or some of the other interactive learning sites to start coding. I just checked, they've implemented PHP now, I haven't tried this. But the javascript course is great. cheers Carsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I am completely lost and need an advice (beginner)
2013/7/18 Carsten Jensen to...@tomse.dk On 07/18/2013 09:08 PM, php colos wrote: Hello world! I'm trying to learn PHP ( first programming language that I learn) and I feel kinda lost. I've read PHP programming 3rd edition( O'reilly), 'getting good with PHP' by Andrew Burgees and some tutorials on the internet but can't code something more complex than 'hello world'. I do understand functions/values/operators/control structures, etc but as I said, I feel that I can't use the language. Am I reading the wrong books for a beginner? Any advices? *Apologies if this email might seem confusing. :) Richard As others have mentioned, reading only isn't a good thing. You'll need to code alongside reading. You also might need to have a goal/project to motivate you to code. Starting small is a good thing. Or you could help out some of the smaller php projects that have only a few coders. Fixing bugs in a project can be a great help, and you'll learn a lot. If you don't have any project in mind, you can go to codecademy.com or some of the other interactive learning sites to start coding. I just checked, they've implemented PHP now, I haven't tried this. But the javascript course is great. cheers Carsten Same here: Just reading doesn't help you very much. You should also consider reading books about programming in general, or even better get in contact with more (or less ;)) experienced programmers, because in my experience learning the syntax and writing code is just a very minor part. Its more important to know how to solve the problems (in a way, that works tomorrow too ;)) is more important. And as a side effect getting help can prevent frustration, if you are stuck in a problem ;) Regards, Sebastian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- github.com/KingCrunch
Re: [PHP] pass parameter from client to server
On Thu, Jul 18, 2013 at 6:04 PM, iccsi inu...@gmail.com wrote: I have a select control on the form and need to pass value user select to my query parameter. I just realized that user entry value is client side and query parameter is server side. Are there any way to read client parameter to pass to server? You information and help is great appreciated, Not from PHP unless you pass it via GET or POST, or as a cookie. You may want to look into JavaScript, jQuery, and AJAX for your specific needs, but that all gets beyond the scope of this list. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] pass parameter from client to server
On Jul 18, 2013, at 6:07 PM, Daniel Brown danbr...@php.net wrote: On Thu, Jul 18, 2013 at 6:04 PM, iccsi inu...@gmail.com wrote: I have a select control on the form and need to pass value user select to my query parameter. I just realized that user entry value is client side and query parameter is server side. Are there any way to read client parameter to pass to server? You information and help is great appreciated, Not from PHP unless you pass it via GET or POST, or as a cookie. You may want to look into JavaScript, jQuery, and AJAX for your specific needs, but that all gets beyond the scope of this list. Daniel is right. Here's my way to do what you are asking: http://php1.net/a/ajax/ Please examine the javascript that accompanies the demo. It simply sends GET values to a php script that changes the values in the GET Array without a refresh. However, I would not provide such access to a db query without a great deal of cleaning. Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] pass parameter from client to server
One additional comment. Please change the javascript onclick to onchange -- that way the demo will work for Chrome as well as other Browsers. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] pass parameter from client to server
Could also use jquery instead Best, -Josh ___ http://byjakt.com Currently mobile On Jul 19, 2013, at 4:08, Tedd Sperling t...@sperling.com wrote: One additional comment. Please change the javascript onclick to onchange -- that way the demo will work for Chrome as well as other Browsers. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Premature end of script
On Wed, Jul 17, 2013 at 11:22 AM, R B rbp...@gmail.com wrote: Hello, 5 years ago, y developed a php system and was working fine. But 20 days ago, when y try to access to some pages (not all the pages), in the log appears this message and the page is not displayed: == /usr/local/apache/logs/error_log == [Wed Jul 3 02:36:58 2013] [error] [client 10.30.6.161] Premature end of script headers: /home/capitale/public_html/miembros/myscript.php Can you help me please with this error? It's the vaguest of all errors and the bane of the existence of any developer who comes across it (at least it's rarer in PHP than it was in Perl years ago). Essentially, it would require a lot more information that what's been provided for us to help you debug. What things have changed in the last month? Have you upgraded PHP? Made any changes to the code or any of the dependencies? Is the server out of available disk space? Is something causing it to run out of memory? What happens when you run the same script from the CLI? What do you see when you enable all errors and error reporting? -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Error checking ON
On Wed, Jul 17, 2013 at 11:49 AM, Tedd Sperling t...@sperling.com wrote: Hi gang: Considering: On Jul 17, 2013, at 11:41 AM, Jim Giner jim.gi...@albanyhandball.com wrote: Since you state that you haven't made any changes to the system (in general), I'm going to guess that you modified an 'included' file and it has an error in it, such as an unmatched curly brace. As Dan said, turn on all error checking and reporting and see what message you get. This is what I do for error checking: ini_set('error_reporting', E_ALL | E_STRICT); ini_set('display_errors', 'On'); ini_set('log_errors', 'On'); ini_set('error_log', 'error_log'); Is this: 1. Sufficient? 2. An overkill? 3. OK? 4. OR, better served with this (and provide an example). That's standard practice. Sometimes, though, it isn't enough, and we find ourselves using Derick's Xdebug, mod_top, or performing an strace on either the execution or attached to a process. For nearly all cases, though, that's sufficient without being overkill (except for production cases). -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Error checking ON
On Jul 17, 2013, at 11:55 AM, Daniel Brown danbr...@php.net wrote: On Wed, Jul 17, 2013 at 11:49 AM, Tedd Sperling t...@sperling.com wrote: This is what I do for error checking: ini_set('error_reporting', E_ALL | E_STRICT); ini_set('display_errors', 'On'); ini_set('log_errors', 'On'); ini_set('error_log', 'error_log'); Is this: 1. Sufficient? 2. An overkill? 3. OK? 4. OR, better served with this (and provide an example). That's standard practice. Sometimes, though, it isn't enough, and we find ourselves using Derick's Xdebug, mod_top, or performing an strace on either the execution or attached to a process. For nearly all cases, though, that's sufficient without being overkill (except for production cases). Daniel: Thanks -- I always wondered about that. Cheers, tedd PS: Of course, turned OFF for production. :-) _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Error checking ON
On 07/17/2013 09:28 AM, Tedd Sperling wrote: On Jul 17, 2013, at 11:55 AM, Daniel Brown danbr...@php.net wrote: On Wed, Jul 17, 2013 at 11:49 AM, Tedd Sperling t...@sperling.com wrote: This is what I do for error checking: ini_set('error_reporting', E_ALL | E_STRICT); ini_set('display_errors', 'On'); ini_set('log_errors', 'On'); ini_set('error_log', 'error_log'); Is this: 1. Sufficient? 2. An overkill? 3. OK? 4. OR, better served with this (and provide an example). That's standard practice. Sometimes, though, it isn't enough, and we find ourselves using Derick's Xdebug, mod_top, or performing an strace on either the execution or attached to a process. For nearly all cases, though, that's sufficient without being overkill (except for production cases). Daniel: Thanks -- I always wondered about that. Cheers, tedd PS: Of course, turned OFF for production. :-) _ t...@sperling.com http://sperling.com But... It won't work in all cases. I find it best to set these settings in the server itself. Not in code. Sometimes, if you have broken code that cannot be parsed, your commands listed above will never be executed. Therefor they will never do any good. -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to read PHP-FPM config values using phpinfo
Hi there, Just a question, do you have Apache configured to use the PHP-FPM and not the Apache module? That something that people can mess up on. Thanks :) On Wed, Jul 17, 2013 at 9:58 AM, Amiya Maji am...@purdue.edu wrote: Hi all, I am using PHP-FPM with Apache 2.4. I periodically change my php-fpm.conf and reload it by sending USR2 signal to the FPM process. Is there a way to print the updated parameters in FPM using phpinfo(). At present I am not seeing any FPM specific parameters in phpinfo. Any suggestion is appreciated. Thanks! Amiya. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to read PHP-FPM config values using phpinfo
Daniel, thanks for asking. I do have Apache correctly configured to use fpm, in fact, phpinfo shows php-fpm as the cgi module. Only problem is to read (or dump) the Fpm configs from phpinfo. Regards, Amiya. Original message From: Daniel danielx...@gmail.com Date: 07/16/2013 9:48 PM (GMT-05:00) To: Amiya Maji am...@purdue.edu Cc: php-general@lists.php.net Subject: Re: [PHP] How to read PHP-FPM config values using phpinfo Hi there, Just a question, do you have Apache configured to use the PHP-FPM and not the Apache module? That something that people can mess up on. Thanks :) On Wed, Jul 17, 2013 at 9:58 AM, Amiya Maji am...@purdue.edu wrote: Hi all, I am using PHP-FPM with Apache 2.4. I periodically change my php-fpm.conf and reload it by sending USR2 signal to the FPM process. Is there a way to print the updated parameters in FPM using phpinfo(). At present I am not seeing any FPM specific parameters in phpinfo. Any suggestion is appreciated. Thanks! Amiya. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] COM - Assigning to method.
Hi Andrew Thanks for this. But I'm still getting errors. I think I need to explain a bit more. Unfortunately there isn't a PHP API for this application I'm trying to interact with, my goal really is to be able to expose the COM functionality over a web-service such as SOAP so I can use it in a CMS. The application I'm trying to integrate with is Blackbuad's Raiser's Edge - API documentation here: https://www.blackbaud.com/files/support/guides/re7ent/api.pdf I think part of the problem is that the field names are also represented by an integer. So to get data out I would do: $oBank-Fields(22); // which maps to BANK_fld_BRANCH_NAME. When I do: $oBank-22 = 'blah blah'; I get an error because a property can't be numeric, it has to start as alpha character. If I use: $oBank-BANK_fld_BRANCH_NAME = 'blah blah blah'; I get the following error: Fatal error: Uncaught exception 'com_exception' with message 'Unable to lookup `BANK_fld_BRANCH_NAME': Unknown name. I've also tried using your Value property returned by Fields(): $oBank-Fields(22)-Value = 'Blah Blah blah blah'; Which I then get: PHP Warning: Creating default object from empty value in [C:\Users] Fatal error: Call to undefined method variant::Save() Soo seems nearly impossible to implement a safe way to write to the COM API. At the moment, I'm still in the scoping/prototype stage of my project, so I'm beginning to think that using this COM API for this project is a no-go, which is unfortunate. I'm also guessing even if we did implement this API, exposing it as a Web Service is going to be tricky for performance sake (given that I've read that COM doesn't multithread very well??) Many Thanks Adam. On 14 July 2013 22:16, Andrew Ballard aball...@gmail.com wrote: On Sun, Jul 14, 2013 at 3:18 PM, Adam Nicholls inkysp...@gmail.com wrote: Richard - I've tried that I get an error about it not being defined as property of the object. Andrew - do you mean try using the method Richard has shown? Cheers Adam. On 13 July 2013 17:11, Richard Quadling rquadl...@gmail.com wrote: On 13 July 2013 01:24, Andrew Ballard aball...@gmail.com wrote: On Jul 12, 2013 4:53 AM, Adam Nicholls inkysp...@gmail.com wrote: Hi Guys/Gals, I'm doing some integration work with a COM API and according to their documentation to save data in the API, you have to assign to the method. This is their example in Visual Basic: - Set oBank = New CBank oBank.Init Application.SessionContext With oBank .Fields(BANK_fld_ACCOUNT_NAME) = Test account .Fields(BANK_fld_ACCOUNT_NO) = 12345 .Fields(BANK_fld_BANK) = Bank of the Nation .Fields(BANK_fld_BRANCH_NAME) = State Street Branch End With oBank.Save - Obviously in PHP is isn't possible to assign to a method in this way (thats what parameters are for!) So I'm at a bit of a loose end. I'm wondering if anyone else has come across this? Or am I missing something obvious in PHP's implementation of the COM that allows me to work around this? My PHP Code is looks like this: - $API = new COM('API7.API'); $API-Init($SerialNo, $Login, '', 1, '', 1); $API-SignOutOnTerminate = True; $Record = new COM(Data.Record); $Record-Init($API-SessionContext); $Record-Fields('BANK_fld_ACCOUNT_NAME') = 'Test Account';//doesn't work - I've also tried (below) but the API says wrong number of parameters $Record-Fields('BANK_fld_ACCOUNT_NAME', 'Test Account'); I've also tried something crazy like this (below) but that overwrites the $Record object. $_R = $Record-Fields('BANK_fld_ACCOUNT_NAME'); $_R = 'Test Account'; Any ideas? Is it possible? Many Thanks Adam Nicholls That example isn't assigning values to method return value. Fields is a collection of ADO Field objects. The default property of a Field object is its Value property, so the shorthand is simply assigning the values of the variables to the value of each field in a record within a Recordset. Andrew So .. $oBank-BANK_fld_ACCOUNT_NAME = Test account; sort of thing. -- Richard Quadling Twitter : @RQuadling -- Adam Nicholls Richard has the general idea correct, but as I recall it is a little more involved because it's COM. I've never done that much with COM in PHP because it was always such a pain. The example you posted probably used to require com_set() in PHP 4, although it looks like that has been deprecated in favor of a more typical OO syntax in PHP 5. Is there any
Re: [PHP] COM - Assigning to method.
Hello, did you tried var_dump or print_r the $oBank object to see his structure ? Also you can try: $BANK_fld_BRANCH_NAME = 22; $oBank-$BANK_fld_BRANCH_NAME = 'something'; Premek. On Mon, 15 Jul 2013 10:21:48 +0200, Adam Nicholls inkysp...@gmail.com wrote: Hi Andrew Thanks for this. But I'm still getting errors. I think I need to explain a bit more. Unfortunately there isn't a PHP API for this application I'm trying to interact with, my goal really is to be able to expose the COM functionality over a web-service such as SOAP so I can use it in a CMS. The application I'm trying to integrate with is Blackbuad's Raiser's Edge - API documentation here: https://www.blackbaud.com/files/support/guides/re7ent/api.pdf I think part of the problem is that the field names are also represented by an integer. So to get data out I would do: $oBank-Fields(22); // which maps to BANK_fld_BRANCH_NAME. When I do: $oBank-22 = 'blah blah'; I get an error because a property can't be numeric, it has to start as alpha character. If I use: $oBank-BANK_fld_BRANCH_NAME = 'blah blah blah'; I get the following error: Fatal error: Uncaught exception 'com_exception' with message 'Unable to lookup `BANK_fld_BRANCH_NAME': Unknown name. I've also tried using your Value property returned by Fields(): $oBank-Fields(22)-Value = 'Blah Blah blah blah'; Which I then get: PHP Warning: Creating default object from empty value in [C:\Users] Fatal error: Call to undefined method variant::Save() Soo seems nearly impossible to implement a safe way to write to the COM API. At the moment, I'm still in the scoping/prototype stage of my project, so I'm beginning to think that using this COM API for this project is a no-go, which is unfortunate. I'm also guessing even if we did implement this API, exposing it as a Web Service is going to be tricky for performance sake (given that I've read that COM doesn't multithread very well??) Many Thanks Adam. On 14 July 2013 22:16, Andrew Ballard aball...@gmail.com wrote: On Sun, Jul 14, 2013 at 3:18 PM, Adam Nicholls inkysp...@gmail.com wrote: Richard - I've tried that I get an error about it not being defined as property of the object. Andrew - do you mean try using the method Richard has shown? Cheers Adam. On 13 July 2013 17:11, Richard Quadling rquadl...@gmail.com wrote: On 13 July 2013 01:24, Andrew Ballard aball...@gmail.com wrote: On Jul 12, 2013 4:53 AM, Adam Nicholls inkysp...@gmail.com wrote: Hi Guys/Gals, I'm doing some integration work with a COM API and according to their documentation to save data in the API, you have to assign to the method. This is their example in Visual Basic: - Set oBank = New CBank oBank.Init Application.SessionContext With oBank .Fields(BANK_fld_ACCOUNT_NAME) = Test account .Fields(BANK_fld_ACCOUNT_NO) = 12345 .Fields(BANK_fld_BANK) = Bank of the Nation .Fields(BANK_fld_BRANCH_NAME) = State Street Branch End With oBank.Save - Obviously in PHP is isn't possible to assign to a method in this way (thats what parameters are for!) So I'm at a bit of a loose end. I'm wondering if anyone else has come across this? Or am I missing something obvious in PHP's implementation of the COM that allows me to work around this? My PHP Code is looks like this: - $API = new COM('API7.API'); $API-Init($SerialNo, $Login, '', 1, '', 1); $API-SignOutOnTerminate = True; $Record = new COM(Data.Record); $Record-Init($API-SessionContext); $Record-Fields('BANK_fld_ACCOUNT_NAME') = 'Test Account';//doesn't work - I've also tried (below) but the API says wrong number of parameters $Record-Fields('BANK_fld_ACCOUNT_NAME', 'Test Account'); I've also tried something crazy like this (below) but that overwrites the $Record object. $_R = $Record-Fields('BANK_fld_ACCOUNT_NAME'); $_R = 'Test Account'; Any ideas? Is it possible? Many Thanks Adam Nicholls That example isn't assigning values to method return value. Fields is a collection of ADO Field objects. The default property of a Field object is its Value property, so the shorthand is simply assigning the values of the variables to the value of each field in a record within a Recordset. Andrew So .. $oBank-BANK_fld_ACCOUNT_NAME = Test account; sort of thing. -- Richard Quadling Twitter : @RQuadling -- Adam Nicholls Richard has the general idea correct, but as I recall it is a little more involved because it's COM. I've never done that much with COM in
Re: [PHP] COM - Assigning to method.
On Mon, Jul 15, 2013 at 4:21 AM, Adam Nicholls inkysp...@gmail.com wrote: Hi Andrew Thanks for this. But I'm still getting errors. I think I need to explain a bit more. Unfortunately there isn't a PHP API for this application I'm trying to interact with, my goal really is to be able to expose the COM functionality over a web-service such as SOAP so I can use it in a CMS. The application I'm trying to integrate with is Blackbuad's Raiser's Edge - API documentation here: https://www.blackbaud.com/files/support/guides/re7ent/api.pdf I think part of the problem is that the field names are also represented by an integer. So to get data out I would do: $oBank-Fields(22); // which maps to BANK_fld_BRANCH_NAME. When I do: $oBank-22 = 'blah blah'; I get an error because a property can't be numeric, it has to start as alpha character. If I use: $oBank-BANK_fld_BRANCH_NAME = 'blah blah blah'; I get the following error: Fatal error: Uncaught exception 'com_exception' with message 'Unable to lookup `BANK_fld_BRANCH_NAME': Unknown name. I've also tried using your Value property returned by Fields(): $oBank-Fields(22)-Value = 'Blah Blah blah blah'; Which I then get: PHP Warning: Creating default object from empty value in [C:\Users] Fatal error: Call to undefined method variant::Save() Soo seems nearly impossible to implement a safe way to write to the COM API. At the moment, I'm still in the scoping/prototype stage of my project, so I'm beginning to think that using this COM API for this project is a no-go, which is unfortunate. I'm also guessing even if we did implement this API, exposing it as a Web Service is going to be tricky for performance sake (given that I've read that COM doesn't multithread very well??) Many Thanks Adam. It's definitely possible to do, once you figure out the syntax you need for this object. I'm guessing you must have gotten past the $oBank-Init() method call without issues. What happens if you just use this for the value assignment? $oBank-Fields(BANK_fld_ACCOUNT_NAME) = Test account; $oBank-Fields(BANK_fld_ACCOUNT_NO) = 12345; $oBank-Fields(BANK_fld_BANK) = Bank of the Nation; $oBank-Fields(BANK_fld_BRANCH_NAME) = State Street Branch; It also looks like you're getting errors from the call to $oBank-Save() saying that the method is not defined. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Kickstarter Project on Massive Log data Aggregation and Processing with Open Source Software
On Jul 15, 2013 11:29 PM, Israel Ekpo israele...@gmail.com wrote: Hi Everyone, [snip!] No. Good luck with your endeavor, but please do not broadcast it to this list.
Re: [PHP] COM - Assigning to method.
Richard - I've tried that I get an error about it not being defined as property of the object. Andrew - do you mean try using the method Richard has shown? Cheers Adam. On 13 July 2013 17:11, Richard Quadling rquadl...@gmail.com wrote: On 13 July 2013 01:24, Andrew Ballard aball...@gmail.com wrote: On Jul 12, 2013 4:53 AM, Adam Nicholls inkysp...@gmail.com wrote: Hi Guys/Gals, I'm doing some integration work with a COM API and according to their documentation to save data in the API, you have to assign to the method. This is their example in Visual Basic: - Set oBank = New CBank oBank.Init Application.SessionContext With oBank .Fields(BANK_fld_ACCOUNT_NAME) = Test account .Fields(BANK_fld_ACCOUNT_NO) = 12345 .Fields(BANK_fld_BANK) = Bank of the Nation .Fields(BANK_fld_BRANCH_NAME) = State Street Branch End With oBank.Save - Obviously in PHP is isn't possible to assign to a method in this way (thats what parameters are for!) So I'm at a bit of a loose end. I'm wondering if anyone else has come across this? Or am I missing something obvious in PHP's implementation of the COM that allows me to work around this? My PHP Code is looks like this: - $API = new COM('API7.API'); $API-Init($SerialNo, $Login, '', 1, '', 1); $API-SignOutOnTerminate = True; $Record = new COM(Data.Record); $Record-Init($API-SessionContext); $Record-Fields('BANK_fld_ACCOUNT_NAME') = 'Test Account';//doesn't work - I've also tried (below) but the API says wrong number of parameters $Record-Fields('BANK_fld_ACCOUNT_NAME', 'Test Account'); I've also tried something crazy like this (below) but that overwrites the $Record object. $_R = $Record-Fields('BANK_fld_ACCOUNT_NAME'); $_R = 'Test Account'; Any ideas? Is it possible? Many Thanks Adam Nicholls That example isn't assigning values to method return value. Fields is a collection of ADO Field objects. The default property of a Field object is its Value property, so the shorthand is simply assigning the values of the variables to the value of each field in a record within a Recordset. Andrew So .. $oBank-BANK_fld_ACCOUNT_NAME = Test account; sort of thing. -- Richard Quadling Twitter : @RQuadling -- Adam Nicholls -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] COM - Assigning to method.
On Sun, Jul 14, 2013 at 3:18 PM, Adam Nicholls inkysp...@gmail.com wrote: Richard - I've tried that I get an error about it not being defined as property of the object. Andrew - do you mean try using the method Richard has shown? Cheers Adam. On 13 July 2013 17:11, Richard Quadling rquadl...@gmail.com wrote: On 13 July 2013 01:24, Andrew Ballard aball...@gmail.com wrote: On Jul 12, 2013 4:53 AM, Adam Nicholls inkysp...@gmail.com wrote: Hi Guys/Gals, I'm doing some integration work with a COM API and according to their documentation to save data in the API, you have to assign to the method. This is their example in Visual Basic: - Set oBank = New CBank oBank.Init Application.SessionContext With oBank .Fields(BANK_fld_ACCOUNT_NAME) = Test account .Fields(BANK_fld_ACCOUNT_NO) = 12345 .Fields(BANK_fld_BANK) = Bank of the Nation .Fields(BANK_fld_BRANCH_NAME) = State Street Branch End With oBank.Save - Obviously in PHP is isn't possible to assign to a method in this way (thats what parameters are for!) So I'm at a bit of a loose end. I'm wondering if anyone else has come across this? Or am I missing something obvious in PHP's implementation of the COM that allows me to work around this? My PHP Code is looks like this: - $API = new COM('API7.API'); $API-Init($SerialNo, $Login, '', 1, '', 1); $API-SignOutOnTerminate = True; $Record = new COM(Data.Record); $Record-Init($API-SessionContext); $Record-Fields('BANK_fld_ACCOUNT_NAME') = 'Test Account';//doesn't work - I've also tried (below) but the API says wrong number of parameters $Record-Fields('BANK_fld_ACCOUNT_NAME', 'Test Account'); I've also tried something crazy like this (below) but that overwrites the $Record object. $_R = $Record-Fields('BANK_fld_ACCOUNT_NAME'); $_R = 'Test Account'; Any ideas? Is it possible? Many Thanks Adam Nicholls That example isn't assigning values to method return value. Fields is a collection of ADO Field objects. The default property of a Field object is its Value property, so the shorthand is simply assigning the values of the variables to the value of each field in a record within a Recordset. Andrew So .. $oBank-BANK_fld_ACCOUNT_NAME = Test account; sort of thing. -- Richard Quadling Twitter : @RQuadling -- Adam Nicholls Richard has the general idea correct, but as I recall it is a little more involved because it's COM. I've never done that much with COM in PHP because it was always such a pain. The example you posted probably used to require com_set() in PHP 4, although it looks like that has been deprecated in favor of a more typical OO syntax in PHP 5. Is there any chance there is a PHP version of the library that you can work with to avoid COM? If not, hopefully what follows will help start you on the right direction. A more explicit version of your original VBScript example looks like this: Set oBank = New CBank oBank.Init Application.SessionContext Set oField = oBank.Fields(BANK_fld_ACCOUNT_NAME) oField.Value = Test account Set oField = oBank.Fields(BANK_fld_ACCOUNT_NO) oField.Value = 12345 Set oField = oBank.Fields(BANK_fld_BANK) oField.Value = Bank of the Nation Set oField = oBank.Fields(BANK_fld_BRANCH_NAME) oField.Value = State Street Branch oBank.Save I'm not familiar with your CBank COM class, but the rest of it looks like it is similar to the COM('ADODB.Recordset'). If so, a rough translation of your original example should resemble this: ?php // I'm not familiar with this object, so I'm guessing on the call to instantiate it here. $oBank = new COM('CBank'); /** Application.SessionContext in the original refers to an object that is global to every request in an application. PHP does not have such a global registry, so I'm not sure where you're $config needs to come from. */ $oBank-Init($config); /** I am assuming that BANK_fld_ACCOUNT_NAME and such are constant names that were already defined with the names of the actual column names in a recordset returned by $oBank. */ $oBank-Fields(BANK_fld_ACCOUNT_NAME)-Value = Test account; $oBank-Fields(BANK_fld_ACCOUNT_NO)-Value = 12345; $oBank-Fields(BANK_fld_BANK)-Value = Bank of the Nation; $oBank-Fields(BANK_fld_BRANCH_NAME)-Value = State Street Branch; $oBank-Save(); ? I don't know if you could leave out the -Value part of the syntax in PHP like you can in the VBScript example you posted. If so, then Richard's syntax would have been pretty
Re: [PHP] COM - Assigning to method.
On 13 July 2013 01:24, Andrew Ballard aball...@gmail.com wrote: On Jul 12, 2013 4:53 AM, Adam Nicholls inkysp...@gmail.com wrote: Hi Guys/Gals, I'm doing some integration work with a COM API and according to their documentation to save data in the API, you have to assign to the method. This is their example in Visual Basic: - Set oBank = New CBank oBank.Init Application.SessionContext With oBank .Fields(BANK_fld_ACCOUNT_NAME) = Test account .Fields(BANK_fld_ACCOUNT_NO) = 12345 .Fields(BANK_fld_BANK) = Bank of the Nation .Fields(BANK_fld_BRANCH_NAME) = State Street Branch End With oBank.Save - Obviously in PHP is isn't possible to assign to a method in this way (thats what parameters are for!) So I'm at a bit of a loose end. I'm wondering if anyone else has come across this? Or am I missing something obvious in PHP's implementation of the COM that allows me to work around this? My PHP Code is looks like this: - $API = new COM('API7.API'); $API-Init($SerialNo, $Login, '', 1, '', 1); $API-SignOutOnTerminate = True; $Record = new COM(Data.Record); $Record-Init($API-SessionContext); $Record-Fields('BANK_fld_ACCOUNT_NAME') = 'Test Account';//doesn't work - I've also tried (below) but the API says wrong number of parameters $Record-Fields('BANK_fld_ACCOUNT_NAME', 'Test Account'); I've also tried something crazy like this (below) but that overwrites the $Record object. $_R = $Record-Fields('BANK_fld_ACCOUNT_NAME'); $_R = 'Test Account'; Any ideas? Is it possible? Many Thanks Adam Nicholls That example isn't assigning values to method return value. Fields is a collection of ADO Field objects. The default property of a Field object is its Value property, so the shorthand is simply assigning the values of the variables to the value of each field in a record within a Recordset. Andrew So .. $oBank-BANK_fld_ACCOUNT_NAME = Test account; sort of thing. -- Richard Quadling Twitter : @RQuadling
Re: [PHP] COM - Assigning to method.
On Jul 12, 2013 4:53 AM, Adam Nicholls inkysp...@gmail.com wrote: Hi Guys/Gals, I'm doing some integration work with a COM API and according to their documentation to save data in the API, you have to assign to the method. This is their example in Visual Basic: - Set oBank = New CBank oBank.Init Application.SessionContext With oBank .Fields(BANK_fld_ACCOUNT_NAME) = Test account .Fields(BANK_fld_ACCOUNT_NO) = 12345 .Fields(BANK_fld_BANK) = Bank of the Nation .Fields(BANK_fld_BRANCH_NAME) = State Street Branch End With oBank.Save - Obviously in PHP is isn't possible to assign to a method in this way (thats what parameters are for!) So I'm at a bit of a loose end. I'm wondering if anyone else has come across this? Or am I missing something obvious in PHP's implementation of the COM that allows me to work around this? My PHP Code is looks like this: - $API = new COM('API7.API'); $API-Init($SerialNo, $Login, '', 1, '', 1); $API-SignOutOnTerminate = True; $Record = new COM(Data.Record); $Record-Init($API-SessionContext); $Record-Fields('BANK_fld_ACCOUNT_NAME') = 'Test Account';//doesn't work - I've also tried (below) but the API says wrong number of parameters $Record-Fields('BANK_fld_ACCOUNT_NAME', 'Test Account'); I've also tried something crazy like this (below) but that overwrites the $Record object. $_R = $Record-Fields('BANK_fld_ACCOUNT_NAME'); $_R = 'Test Account'; Any ideas? Is it possible? Many Thanks Adam Nicholls That example isn't assigning values to method return value. Fields is a collection of ADO Field objects. The default property of a Field object is its Value property, so the shorthand is simply assigning the values of the variables to the value of each field in a record within a Recordset. Andrew
Re: [PHP] strlen ?
Try with mb_strlen see http://www.php.net/manual/en/function.mb-strlen.php 2013/7/5 Jim Giner jim.gi...@albanyhandball.com Trying to manage line breaks in some output I'm generating and using strlen to measure the lengths of the strings I'm printing. Discovered something strange (to me!) in that strlen is returning +1 more than it should. The strings are from a query of my database - simple name fields. But everyone of them is coming back with a length that is one more than I see. Ex. Mike Hall comes back as 10, not 9 F.B. comes back as 5, not 4. I've looked at my data and counted the chars - there is no extra space at the beginning or end in my table. Anyone have an explanation? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax question
Hello, is an alternative syntax. http://php.net/manual/en/control-structures.alternative-syntax.php Premek. On Wed, 10 Jul 2013 13:15:22 +0200, Jim Giner jim.gi...@albanyhandball.com wrote: Can someone tell me what this syntax is? I looked around but don't see any mention of it. while(condition) : (statement); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax question
Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Fwd: Hmmm.. I think I need your advice here to get in correct direction...
2013/7/10 Jim Giner jim.gi...@albanyhandball.com On 7/10/2013 8:37 AM, Karl-Arne Gjersøyen wrote: Sorry, the first mail in this subject run out for me. This is an updated one. I am almost ready with my learning project in PHP/MySQL. I can register new product in stock. Add and increase the number and weight. I can move products between different storehouses I can also transfer products from store and onto a truck document but that's it and here I need some advice. I like to register new products and the amount in number (for example 4) and weight in kg. I like to write it in this way: Dynamite - package 4 - Weight 200 kg Lunt - Package 10 - Weight 10kg Then I like to 4+10 = 14 and 200+10 = 210. It shall looks like this: ==** Dynamite | 4 | 200 Lunt | 10 | 10 --**--**-- TOTAL| 14 | 210 It is easy to register this product by product on their own row. but in what way can I multiply them? ned products be stored in arrays? I think it will be similar to shopping cart in online store but i have no clue about how to do this. If you have links to pages were i can learn am i Happy for it. If you can help me here is even better. Thanks for your time and effort to learn me programming. Karl Ahhh. So - you should run a query that selects the products and information that you want. Then you start by creating an html table header and then loop through your query results and echo a table row for each result row. // start the table echo table border=1; echo trthProduct/thth**Amount/th/tr; // loop thru each item found while ($results = $qrslts-fetch(PDO::FETCH_**ASSOC)) { echo trtd.$results['product_**name']./tdtd.$results['** product_amt']./td/tr; } // finish the table html echo /table; Yes that part is OK. I do have problem to add total weight and package at bottom of the table like this: Product_one 40kg Product_two 60kg - Total: 100kg === Because sometimes it is only a few products and other times many products. I then need to summing them at bottom. One timer only 3 rows, other times 20 rows. The program need a way to add every singel product and see if it's a few or many, Karl
Re: [PHP] Re: Fwd: Hmmm.. I think I need your advice here to get incorrect direction...
On 7/10/2013 9:07 AM, Karl-Arne Gjersøyen wrote: 2013/7/10 Jim Giner jim.gi...@albanyhandball.com On 7/10/2013 8:37 AM, Karl-Arne Gjersøyen wrote: Sorry, the first mail in this subject run out for me. This is an updated one. I am almost ready with my learning project in PHP/MySQL. I can register new product in stock. Add and increase the number and weight. I can move products between different storehouses I can also transfer products from store and onto a truck document but that's it and here I need some advice. I like to register new products and the amount in number (for example 4) and weight in kg. I like to write it in this way: Dynamite - package 4 - Weight 200 kg Lunt - Package 10 - Weight 10kg Then I like to 4+10 = 14 and 200+10 = 210. It shall looks like this: ==** Dynamite | 4 | 200 Lunt | 10 | 10 --**--**-- TOTAL| 14 | 210 It is easy to register this product by product on their own row. but in what way can I multiply them? ned products be stored in arrays? I think it will be similar to shopping cart in online store but i have no clue about how to do this. If you have links to pages were i can learn am i Happy for it. If you can help me here is even better. Thanks for your time and effort to learn me programming. Karl Ahhh. So - you should run a query that selects the products and information that you want. Then you start by creating an html table header and then loop through your query results and echo a table row for each result row. // start the table echo table border=1; echo trthProduct/thth**Amount/th/tr; // loop thru each item found while ($results = $qrslts-fetch(PDO::FETCH_**ASSOC)) { echo trtd.$results['product_**name']./tdtd.$results['** product_amt']./td/tr; } // finish the table html echo /table; Yes that part is OK. I do have problem to add total weight and package at bottom of the table like this: Product_one 40kg Product_two 60kg - Total: 100kg === Because sometimes it is only a few products and other times many products. I then need to summing them at bottom. One timer only 3 rows, other times 20 rows. The program need a way to add every singel product and see if it's a few or many, Karl So - as you loop thru the results, accumulate your totals and then at the end before you close the table generate one last row with those amounts in it. Simple! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Fwd: Hmmm.. I think I need your advice here to get in correct direction...
Karl-Arne Gjersøyen wrote: // start the table $total = 0; echo table border=1; echo trthProduct/thth**Amount/th/tr; // loop thru each item found while ($results = $qrslts-fetch(PDO::FETCH_**ASSOC)) { echo trtd.$results['product_**name']./tdtd.$results['** product_amt']./td/tr; $total += $results['product_amt'] } echo trtdTotal:/tdtd.$total./td/tr; // finish the table html echo /table; Yes that part is OK. I do have problem to add total weight and package at bottom of the table like this: Product_one 40kg Product_two 60kg - Total: 100kg === -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Fwd: Hmmm.. I think I need your advice here to get in correct direction...
2013/7/10 Lester Caine les...@lsces.co.uk Karl-Arne Gjersøyen wrote: // start the table $total = 0; echo table border=1; echo trthProduct/ththAmount/th/tr; // loop thru each item found while ($results = $qrslts-fetch(PDO::FETCH_ASSOC)) { echo trtd.$results['product_name']./tdtd.$results[' product_amt']./td/tr; $total += $results['product_amt'] } echo trtdTotal:/tdtd.$**total./td/tr; // finish the table html echo /table; Yes that part is OK. I do have problem to add total weight and package at bottom of the table like this: Product_one 40kg Product_two 60kg - Total: 100kg === Thank you very Much, Both of you Jim and Lester! You are amazing, folks! Karl
Re: [PHP] Query regarding temporarily-uploaded files
On Wed, Jul 10, 2013 at 7:21 PM, Ajay Garg ajaygargn...@gmail.com wrote: Hi all. I have a requirement, wherein I need to allow vanilla uploads of files to a HTTPD server. Any client can upload any number of files (one at a time). Also, there is just one directory, where the files get stored finally (that is, after being copied from the temporary location, via move_uploaded_file) Also, I have been able to get the simple file uploading running via PHP, by picking up one of the numerous Hello World examples available :) Now, I am facing the following use-case :: 1) User 1 starts uploading a large file, say big_file.avi. 2) Meanwhile, user 2 also starts uploading a (different) file, but with the same name big_file.avi. In an ideal scenario, user 2 should be prompted with a message, that a file of the same name is already being uploaded by someone else somewhere. Is there a way to do this? ( Note that, had the user 2 started uploading AFTER user 1 had finished with the upload, we could probably modify the PHP-script at the sever-side, to let user-2 know that a file of the same name already exits. But I am failing to find a solution, when the user 2 starts the upload WHILE the large file of user 1 is in the process of completing uploading). Any way the issue may be solved? I will be grateful for any pointers :) Regards, Ajay Hi, This is not possible with PHP, PHP will not know about the file until the upload is completed. You can use HTML5 or flash(not recommended) for an alternative way of uploading, and then you can check the file name in advance. - Matijn
Re: [PHP] Query regarding temporarily-uploaded files
Thanks Jim and Matijn for the quick replies. I will try to have a workaround. On Wed, Jul 10, 2013 at 11:09 PM, Matijn Woudt tijn...@gmail.com wrote: On Wed, Jul 10, 2013 at 7:21 PM, Ajay Garg ajaygargn...@gmail.com wrote: Hi all. I have a requirement, wherein I need to allow vanilla uploads of files to a HTTPD server. Any client can upload any number of files (one at a time). Also, there is just one directory, where the files get stored finally (that is, after being copied from the temporary location, via move_uploaded_file) Also, I have been able to get the simple file uploading running via PHP, by picking up one of the numerous Hello World examples available :) Now, I am facing the following use-case :: 1) User 1 starts uploading a large file, say big_file.avi. 2) Meanwhile, user 2 also starts uploading a (different) file, but with the same name big_file.avi. In an ideal scenario, user 2 should be prompted with a message, that a file of the same name is already being uploaded by someone else somewhere. Is there a way to do this? ( Note that, had the user 2 started uploading AFTER user 1 had finished with the upload, we could probably modify the PHP-script at the sever-side, to let user-2 know that a file of the same name already exits. But I am failing to find a solution, when the user 2 starts the upload WHILE the large file of user 1 is in the process of completing uploading). Any way the issue may be solved? I will be grateful for any pointers :) Regards, Ajay Hi, This is not possible with PHP, PHP will not know about the file until the upload is completed. You can use HTML5 or flash(not recommended) for an alternative way of uploading, and then you can check the file name in advance. - Matijn -- Regards, Ajay
Re: [PHP] Query regarding temporarily-uploaded files
On 7/10/2013 2:15 PM, Ajay Garg wrote: Thanks Jim and Matijn for the quick replies. I will try to have a workaround. On Wed, Jul 10, 2013 at 11:09 PM, Matijn Woudt tijn...@gmail.com wrote: On Wed, Jul 10, 2013 at 7:21 PM, Ajay Garg ajaygargn...@gmail.com wrote: Hi all. I have a requirement, wherein I need to allow vanilla uploads of files to a HTTPD server. Any client can upload any number of files (one at a time). Also, there is just one directory, where the files get stored finally (that is, after being copied from the temporary location, via move_uploaded_file) Also, I have been able to get the simple file uploading running via PHP, by picking up one of the numerous Hello World examples available :) Now, I am facing the following use-case :: 1) User 1 starts uploading a large file, say big_file.avi. 2) Meanwhile, user 2 also starts uploading a (different) file, but with the same name big_file.avi. In an ideal scenario, user 2 should be prompted with a message, that a file of the same name is already being uploaded by someone else somewhere. Is there a way to do this? ( Note that, had the user 2 started uploading AFTER user 1 had finished with the upload, we could probably modify the PHP-script at the sever-side, to let user-2 know that a file of the same name already exits. But I am failing to find a solution, when the user 2 starts the upload WHILE the large file of user 1 is in the process of completing uploading). Any way the issue may be solved? I will be grateful for any pointers :) Regards, Ajay Hi, This is not possible with PHP, PHP will not know about the file until the upload is completed. You can use HTML5 or flash(not recommended) for an alternative way of uploading, and then you can check the file name in advance. - Matijn As Matijn said, you don't know the name until your php processes the file that has been uploaded alreaday. But my solution will work for you - you just have to save it under the temp name until the user responds to your message and request for a new title. You may have to run a periodic script to clean up any files with your temp names that the user declined to re-name for you. I'd make up a temp name with some special prefix so that you can find and delete them. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Query regarding temporarily-uploaded files
Thanks Jim and Anthony. Jim, You are right, your solution is doable. But one thing I am a little skeptical about, is what would be the percentage of the people willing to suggest a new name immediately, versus the percentage of people who would like to cancel the current upload, and come back later after walking and coming up with a new name. Anyhow, let me sleep over it :) Anthony, your solution is really a special case of Jim's solution :) Thanks guys for the quick replies; I am obliged, really. On Thu, Jul 11, 2013 at 12:59 AM, Anthony Wlodarski ant92...@gmail.comwrote: Is there anything that would prevent you from somehow uniquely knowing who the user is uploading the file. For example you mentioned client'. If you know who the client is you can append that to the filename or prepend it, for the destination string (second parameter to the function call). That way it is unique to that client. -Anthony On Wed, Jul 10, 2013 at 2:15 PM, Ajay Garg ajaygargn...@gmail.com wrote: Thanks Jim and Matijn for the quick replies. I will try to have a workaround. On Wed, Jul 10, 2013 at 11:09 PM, Matijn Woudt tijn...@gmail.com wrote: On Wed, Jul 10, 2013 at 7:21 PM, Ajay Garg ajaygargn...@gmail.com wrote: Hi all. I have a requirement, wherein I need to allow vanilla uploads of files to a HTTPD server. Any client can upload any number of files (one at a time). Also, there is just one directory, where the files get stored finally (that is, after being copied from the temporary location, via move_uploaded_file) Also, I have been able to get the simple file uploading running via PHP, by picking up one of the numerous Hello World examples available :) Now, I am facing the following use-case :: 1) User 1 starts uploading a large file, say big_file.avi. 2) Meanwhile, user 2 also starts uploading a (different) file, but with the same name big_file.avi. In an ideal scenario, user 2 should be prompted with a message, that a file of the same name is already being uploaded by someone else somewhere. Is there a way to do this? ( Note that, had the user 2 started uploading AFTER user 1 had finished with the upload, we could probably modify the PHP-script at the sever-side, to let user-2 know that a file of the same name already exits. But I am failing to find a solution, when the user 2 starts the upload WHILE the large file of user 1 is in the process of completing uploading). Any way the issue may be solved? I will be grateful for any pointers :) Regards, Ajay Hi, This is not possible with PHP, PHP will not know about the file until the upload is completed. You can use HTML5 or flash(not recommended) for an alternative way of uploading, and then you can check the file name in advance. - Matijn -- Regards, Ajay -- Anthony W. ant92...@gmail.com -- Regards, Ajay
Re: [PHP] Query regarding temporarily-uploaded files
On 7/10/2013 3:37 PM, Ajay Garg wrote: Thanks Jim and Anthony. Jim, You are right, your solution is doable. But one thing I am a little skeptical about, is what would be the percentage of the people willing to suggest a new name immediately, versus the percentage of people who would like to cancel the current upload, and come back later after walking and coming up with a new name. Anyhow, let me sleep over it :) Anthony, your solution is really a special case of Jim's solution :) Thanks guys for the quick replies; I am obliged, really. On Thu, Jul 11, 2013 at 12:59 AM, Anthony Wlodarski ant92...@gmail.comwrote: Is there anything that would prevent you from somehow uniquely knowing who the user is uploading the file. For example you mentioned client'. If you know who the client is you can append that to the filename or prepend it, for the destination string (second parameter to the function call). That way it is unique to that client. -Anthony On Wed, Jul 10, 2013 at 2:15 PM, Ajay Garg ajaygargn...@gmail.com wrote: Thanks Jim and Matijn for the quick replies. I will try to have a workaround. On Wed, Jul 10, 2013 at 11:09 PM, Matijn Woudt tijn...@gmail.com wrote: On Wed, Jul 10, 2013 at 7:21 PM, Ajay Garg ajaygargn...@gmail.com wrote: Hi all. I have a requirement, wherein I need to allow vanilla uploads of files to a HTTPD server. Any client can upload any number of files (one at a time). Also, there is just one directory, where the files get stored finally (that is, after being copied from the temporary location, via move_uploaded_file) Also, I have been able to get the simple file uploading running via PHP, by picking up one of the numerous Hello World examples available :) Now, I am facing the following use-case :: 1) User 1 starts uploading a large file, say big_file.avi. 2) Meanwhile, user 2 also starts uploading a (different) file, but with the same name big_file.avi. In an ideal scenario, user 2 should be prompted with a message, that a file of the same name is already being uploaded by someone else somewhere. Is there a way to do this? ( Note that, had the user 2 started uploading AFTER user 1 had finished with the upload, we could probably modify the PHP-script at the sever-side, to let user-2 know that a file of the same name already exits. But I am failing to find a solution, when the user 2 starts the upload WHILE the large file of user 1 is in the process of completing uploading). Any way the issue may be solved? I will be grateful for any pointers :) Regards, Ajay Hi, This is not possible with PHP, PHP will not know about the file until the upload is completed. You can use HTML5 or flash(not recommended) for an alternative way of uploading, and then you can check the file name in advance. - Matijn -- Regards, Ajay -- Anthony W. ant92...@gmail.com That's why I said you would have to do a cleanup periodically. People who walk away could lose their session perhaps and the page wiht the hidden temp name buried in it, so they would have to do their upload from the beginning again. If they didn't lose their session and therefore that screen, then they could still respond and things would flow smoothly. so - who is scanning these files for viruses and what not? It's one thing to host them but if you are going to let users view them on their clients you could be spreading things. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Query regarding temporarily-uploaded files
Is there anything that would prevent you from somehow uniquely knowing who the user is uploading the file. For example you mentioned client'. If you know who the client is you can append that to the filename or prepend it, for the destination string (second parameter to the function call). That way it is unique to that client. -Anthony On Wed, Jul 10, 2013 at 2:15 PM, Ajay Garg ajaygargn...@gmail.com wrote: Thanks Jim and Matijn for the quick replies. I will try to have a workaround. On Wed, Jul 10, 2013 at 11:09 PM, Matijn Woudt tijn...@gmail.com wrote: On Wed, Jul 10, 2013 at 7:21 PM, Ajay Garg ajaygargn...@gmail.com wrote: Hi all. I have a requirement, wherein I need to allow vanilla uploads of files to a HTTPD server. Any client can upload any number of files (one at a time). Also, there is just one directory, where the files get stored finally (that is, after being copied from the temporary location, via move_uploaded_file) Also, I have been able to get the simple file uploading running via PHP, by picking up one of the numerous Hello World examples available :) Now, I am facing the following use-case :: 1) User 1 starts uploading a large file, say big_file.avi. 2) Meanwhile, user 2 also starts uploading a (different) file, but with the same name big_file.avi. In an ideal scenario, user 2 should be prompted with a message, that a file of the same name is already being uploaded by someone else somewhere. Is there a way to do this? ( Note that, had the user 2 started uploading AFTER user 1 had finished with the upload, we could probably modify the PHP-script at the sever-side, to let user-2 know that a file of the same name already exits. But I am failing to find a solution, when the user 2 starts the upload WHILE the large file of user 1 is in the process of completing uploading). Any way the issue may be solved? I will be grateful for any pointers :) Regards, Ajay Hi, This is not possible with PHP, PHP will not know about the file until the upload is completed. You can use HTML5 or flash(not recommended) for an alternative way of uploading, and then you can check the file name in advance. - Matijn -- Regards, Ajay -- Anthony W. ant92...@gmail.com
Re: [PHP] Query regarding temporarily-uploaded files
Bastien Koert On 2013-07-10, at 3:29 PM, Anthony Wlodarski ant92...@gmail.com wrote: Is there anything that would prevent you from somehow uniquely knowing who the user is uploading the file. For example you mentioned client'. If you know who the client is you can append that to the filename or prepend it, for the destination string (second parameter to the function call). That way it is unique to that client. -Anthony Another option is that you name the files yourself. Numerically for example and then just switch it back to the uploaded file name when either displaying it or sending it back to the user. You should also place all files outside the web root so it's harder to execute bad files. And prolly filter for files types. Allow only images ( png jpg gif ) for example Bastien -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Making a Timeout Expiration Length to Session Variables
Hi, On 07/08/2013 05:10 AM, dealTek wrote: Hi all, I would like to make a timeout length to session variables, so that if a user didn't use the browser page for let's say 5 minutes - the session variables would expire and the user would need to login again. Q: What's the best way to implement this functionality? You can either use cookies or do something like that: http://stackoverflow.com/questions/3068744/php-session-timeout In your case is would be if ($_SESSION['timeout'] + 5 * 60 time()) { // session timed out } else { // session ok } Karim -- Karim Geiger Auszubildender Fachinformatiker AE B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537 signature.asc Description: OpenPGP digital signature
Re: [PHP] phpdocumentor with PHP5.4
You can simply update phpdocumentor Am 07.07.2013 17:10 schrieb Lester Caine les...@lsces.co.uk: Anybody have phpdocumentor running with PHP5.4? I'm convinced that the errors my copy is throwing are due to e_strict, but I've confirmed that I have the right ini file ( all the needed extensions load ) and I'm getting error_reporting showing 22527 with e_strict off and 24575 with e_strict on - so at least it is changing the setting? Once again I'm wasting hours getting something which I have had running fine on the older servers to actually work in a new setup. In this case phpdocumentor seems to suggesting *IT* needs PHP5.3 but the main script also switched e_strict off anyway, so 5.4 should work as well? -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=**contacthttp://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.**ukhttp://rainbowdigitalmedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] phpdocumentor with PHP5.4
It's a clean install via PEAR a couple of hours ago! Sent from my android device. -Original Message- From: Sebastian Krebs krebs@gmail.com To: Lester Caine les...@lsces.co.uk Cc: PHP General List php-general@lists.php.net Sent: Sun, 07 Jul 2013 16:41 Subject: Re: [PHP] phpdocumentor with PHP5.4 You can simply update phpdocumentor Am 07.07.2013 17:10 schrieb Lester Caine les...@lsces.co.uk: Anybody have phpdocumentor running with PHP5.4? I'm convinced that the errors my copy is throwing are due to e_strict, but I've confirmed that I have the right ini file ( all the needed extensions load ) and I'm getting error_reporting showing 22527 with e_strict off and 24575 with e_strict on - so at least it is changing the setting? Once again I'm wasting hours getting something which I have had running fine on the older servers to actually work in a new setup. In this case phpdocumentor seems to suggesting *IT* needs PHP5.3 but the main script also switched e_strict off anyway, so 5.4 should work as well? -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=**contacthttp://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.**ukhttp://rainbowdigitalmedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] phpdocumentor with PHP5.4
I meant: PhpDocumentor 2 Am 07.07.2013 17:44 schrieb les...@lsces.co.uk: It's a clean install via PEAR a couple of hours ago! Sent from my android device. -Original Message- From: Sebastian Krebs krebs@gmail.com To: Lester Caine les...@lsces.co.uk Cc: PHP General List php-general@lists.php.net Sent: Sun, 07 Jul 2013 16:41 Subject: Re: [PHP] phpdocumentor with PHP5.4 You can simply update phpdocumentor Am 07.07.2013 17 0707201317:10 schrieb Lester Caine les...@lsces.co.uk: Anybody have phpdocumentor running with PHP5.4? I'm convinced that the errors my copy is throwing are due to e_strict, but I've confirmed that I have the right ini file ( all the needed extensions load ) and I'm getting error_reporting showing 22527 with e_strict off and 24575 with e_strict on - so at least it is changing the setting? Once again I'm wasting hours getting something which I have had running fine on the older servers to actually work in a new setup. In this case phpdocumentor seems to suggesting *IT* needs PHP5.3 but the main script also switched e_strict off anyway, so 5.4 should work as well? -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=**contact http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.**uk http://rainbowdigitalmedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] phpdocumentor with PHP5.4
Sebastian Krebs wrote: I meant: PhpDocumentor 2 Problem solved ... Notes on https://github.com/phpDocumentor/phpDocumentor2 need a little update to correct the installation notes to use the beta builds rather than alpha ones. -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] phpdocumentor with PHP5.4
You can submit a pull request for that 2013/7/7 Lester Caine les...@lsces.co.uk Sebastian Krebs wrote: I meant: PhpDocumentor 2 Problem solved ... Notes on https://github.com/**phpDocumentor/phpDocumentor2https://github.com/phpDocumentor/phpDocumentor2need a little update to correct the installation notes to use the beta builds rather than alpha ones. -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=**contacthttp://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.**ukhttp://rainbowdigitalmedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- github.com/KingCrunch
Re: [PHP] htaccess
On 8/07/2013, at 8:06, Tedd Sperling t...@sperling.com wrote: Hi gang: I have a client who has an account with GoDaddy (I know). GoDaddy says they have PHP v 5.3 installed on the client's account, but phpinfo() says different, namely it reports 5.2.17. After calling GoDaddy, they said the client has an htaccess file that makes everything 5.2 instead of 5.3. Now, I'm not an expert on these things and the reason why I am asking here, but here are the two htaccess files I find at root level: 1. Named: .htaccess.bak_hosting_company_Apache24_compatibility_fix Options +ExecCGI AddType application/x-httpd-php .php .htm .html AddHandler x-httpd-php5-cgi .php .htm .html # AddHandler php5-script .php .html # AddHandler x-httpd-php5 .php .html ErrorDocument 404 /404.html ErrorDocument 403 /403.html AND 2. Named: .htacess # The below FilesMatch stanza was added by your # hosting provider on 2013-06-27 11:05:33 # to resolve a potential Apache 2.4 # compatibility issue with your custom AddHandler(s) # for PHP. If you feel this was in error, please # contact support and we will work to resolve the # issue. Thanks! FilesMatch \.(htm|html)$ Options +ExecCGI /FilesMatch Options +ExecCGI AddType application/x-httpd-php .php .htm .html AddHandler x-httpd-php5-cgi .php .htm .html Does anyone see a problem here? OR -- a way to get PHP to version 5.3? Cheers, tedd I don’t use GoDaddy, so this may not be entirely accurate. I’m guessing that it’s these two lines in .htaccess: AddType application/x-httpd-php .php .htm .html AddHandler x-httpd-php5-cgi .php .htm .html They’re changing the handler from PHP files from the default ones to x-httpd-php5-cgi, which would cause PHP 5.2 to be used instead. Try commenting out these two lines. --- Simon Welsh Admin of http://simon.geek.nz/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] htaccess
Simon: Confirmed. Those two lines cause the problem. However, commenting out those lines causes other problems. Are there similar statements to these: AddType application/x-httpd-php .php .htm .html AddHandler x-httpd-php5-cgi .php .htm .html That will allow for their function (whatever that may be), but not reduce PHP to version 5.2.17? If these statement are for only the php interpreter to consider html prefixes, then I use the following on my main site: # handler for phpsuexec. -- this makes these prefixes considered for php FilesMatch \.(htm|html|css)$ SetHandler application/x-httpd-php /FilesMatch And it works for me without the PHP version reduction. What do you say? And thanks... Cheers, tedd On Jul 7, 2013, at 4:10 PM, Simon J Welsh si...@simon.geek.nz wrote: On 8/07/2013, at 8:06, Tedd Sperling t...@sperling.com wrote: Hi gang: I have a client who has an account with GoDaddy (I know). GoDaddy says they have PHP v 5.3 installed on the client's account, but phpinfo() says different, namely it reports 5.2.17. After calling GoDaddy, they said the client has an htaccess file that makes everything 5.2 instead of 5.3. Now, I'm not an expert on these things and the reason why I am asking here, but here are the two htaccess files I find at root level: 1. Named: .htaccess.bak_hosting_company_Apache24_compatibility_fix Options +ExecCGI AddType application/x-httpd-php .php .htm .html AddHandler x-httpd-php5-cgi .php .htm .html # AddHandler php5-script .php .html # AddHandler x-httpd-php5 .php .html ErrorDocument 404 /404.html ErrorDocument 403 /403.html AND 2. Named: .htacess # The below FilesMatch stanza was added by your # hosting provider on 2013-06-27 11:05:33 # to resolve a potential Apache 2.4 # compatibility issue with your custom AddHandler(s) # for PHP. If you feel this was in error, please # contact support and we will work to resolve the # issue. Thanks! FilesMatch \.(htm|html)$ Options +ExecCGI /FilesMatch Options +ExecCGI AddType application/x-httpd-php .php .htm .html AddHandler x-httpd-php5-cgi .php .htm .html Does anyone see a problem here? OR -- a way to get PHP to version 5.3? Cheers, tedd I don’t use GoDaddy, so this may not be entirely accurate. I’m guessing that it’s these two lines in .htaccess: AddType application/x-httpd-php .php .htm .html AddHandler x-httpd-php5-cgi .php .htm .html They’re changing the handler from PHP files from the default ones to x-httpd-php5-cgi, which would cause PHP 5.2 to be used instead. Try commenting out these two lines. --- Simon Welsh Admin of http://simon.geek.nz/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strlen ?
Jim Giner wrote: And the answer is - yes, there is a LF char at the end of my data in my whole table. Now the question is - how the heck did I put that in there? Certainly not intentionally. The data is captured from a d/e screen I wrote and it simply grabs the post value and inserts a new record with that value along with some other values. And I don't see anything concatenating a LF to my string. The obvious question that comes to mind is 'What OS'? Having seen this sort of niggle many times I tend to find it relates to something working 'cross-os' a bit like windows ignoring case in file name and linux then complaining it can't find a file. It's probably worth checking the sting length back through your code just to confirm what added it? -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strlen ?
On 7/6/2013 2:59 AM, Lester Caine wrote: Jim Giner wrote: And the answer is - yes, there is a LF char at the end of my data in my whole table. Now the question is - how the heck did I put that in there? Certainly not intentionally. The data is captured from a d/e screen I wrote and it simply grabs the post value and inserts a new record with that value along with some other values. And I don't see anything concatenating a LF to my string. The obvious question that comes to mind is 'What OS'? Having seen this sort of niggle many times I tend to find it relates to something working 'cross-os' a bit like windows ignoring case in file name and linux then complaining it can't find a file. It's probably worth checking the sting length back through your code just to confirm what added it? The best I can figure is that I did a preload of many of the names from a csv file. Apparently when I do that it stores the LF at the end of the csv line. Have to remember that the next time. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strlen ?
Jim Giner wrote: It's probably worth checking the sting length back through your code just to confirm what added it? The best I can figure is that I did a preload of many of the names from a csv file. Apparently when I do that it stores the LF at the end of the csv line. Have to remember that the next time. AH - I use that to flag the end of line when I pulled the data apart - so it gets stripped ;) Then I found fgetcsv() which replaced the manual code and gave just the data as an array. -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mongo usage
Could the comma after the last element in your array be causing the problem? Date: Sat, 6 Jul 2013 14:42:07 -0400 From: bluethu...@gmail.com To: php-general@lists.php.net Subject: [PHP] mongo usage Hey all, I'm trying to pick up some basic use of MongoDB using PHP. I seem to have hit an early obstacle that I'd like your opinion on. I try to pass an array to the mongo insert function, but for some reason the function does not recognize the array I'm passing. Even though I can perform a var_dump() on the array and see the contents. Here's the output I'm seeing (with error): Mongo Test Page array(6) { [first_name]= string(5) Peter [last_name]= string(6) Parker [address]= string(16) 175 Fifth Avenue [city]= string(8) New York [state]= string(2) NY [zip]= string(5) 10010 } *Notice*: Undefined variable: addresses in */var/www/mongomaven/index.php* on line *36* *Fatal error*: Call to a member function insert() on a non-object in * /var/www/mongomaven/index.php* on line *36* * * And here's the code: html head titleMongo Test/title /head body Mongo Test Page ?php $connection = new Mongo(); $db = $connection-jfdb; $collection = $db-addresses; //$adresses = $connection-jfdb-adresses; $address = array( 'first_name' = 'Peter', 'last_name' = 'Parker', 'address' = '175 Fifth Avenue', 'city' = 'New York', 'state' = 'NY', 'zip' = '10010',); var_dump($address); echo 'br /'; $addresses-insert($address); ? /body /html I'd appreciate any advice you might have. Thanks, Tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
Re: [PHP] mongo usage
You commented out the setting of yhe addresses variable On Jul 6, 2013 1:42 PM, Tim Dunphy bluethu...@gmail.com wrote: Hey all, I'm trying to pick up some basic use of MongoDB using PHP. I seem to have hit an early obstacle that I'd like your opinion on. I try to pass an array to the mongo insert function, but for some reason the function does not recognize the array I'm passing. Even though I can perform a var_dump() on the array and see the contents. Here's the output I'm seeing (with error): Mongo Test Page array(6) { [first_name]= string(5) Peter [last_name]= string(6) Parker [address]= string(16) 175 Fifth Avenue [city]= string(8) New York [state]= string(2) NY [zip]= string(5) 10010 } *Notice*: Undefined variable: addresses in */var/www/mongomaven/index.php* on line *36* *Fatal error*: Call to a member function insert() on a non-object in * /var/www/mongomaven/index.php* on line *36* * * And here's the code: html head titleMongo Test/title /head body Mongo Test Page ?php $connection = new Mongo(); $db = $connection-jfdb; $collection = $db-addresses; //$adresses = $connection-jfdb-adresses; $address = array( 'first_name' = 'Peter', 'last_name' = 'Parker', 'address' = '175 Fifth Avenue', 'city' = 'New York', 'state' = 'NY', 'zip' = '10010',); var_dump($address); echo 'br /'; $addresses-insert($address); ? /body /html I'd appreciate any advice you might have. Thanks, Tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
Re: [PHP] mongo usage
| Could the comma after the last element in your array be causing the problem? I tried removing it, but there was no change. Thanks for the suggestion! On Sat, Jul 6, 2013 at 2:55 PM, Thomas Punt unassailable...@hotmail.comwrote: Could the comma after the last element in your array be causing the problem? Date: Sat, 6 Jul 2013 14:42:07 -0400 From: bluethu...@gmail.com To: php-general@lists.php.net Subject: [PHP] mongo usage Hey all, I'm trying to pick up some basic use of MongoDB using PHP. I seem to have hit an early obstacle that I'd like your opinion on. I try to pass an array to the mongo insert function, but for some reason the function does not recognize the array I'm passing. Even though I can perform a var_dump() on the array and see the contents. Here's the output I'm seeing (with error): Mongo Test Page array(6) { [first_name]= string(5) Peter [last_name]= string(6) Parker [address]= string(16) 175 Fifth Avenue [city]= string(8) New York [state]= string(2) NY [zip]= string(5) 10010 } *Notice*: Undefined variable: addresses in */var/www/mongomaven/index.php* on line *36* *Fatal error*: Call to a member function insert() on a non-object in * /var/www/mongomaven/index.php* on line *36* * * And here's the code: html head titleMongo Test/title /head body Mongo Test Page ?php $connection = new Mongo(); $db = $connection-jfdb; $collection = $db-addresses; //$adresses = $connection-jfdb-adresses; $address = array( 'first_name' = 'Peter', 'last_name' = 'Parker', 'address' = '175 Fifth Avenue', 'city' = 'New York', 'state' = 'NY', 'zip' = '10010', ); var_dump($address); echo 'br /'; $addresses-insert($address); ? /body /html I'd appreciate any advice you might have. Thanks, Tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
Re: [PHP] mongo usage
| You commented out the setting of yhe addresses variable Those were both equivalent ways of stating the same thing. I tried substituting the other statement but there was no change: $db = $connection-jfdb; //$collection = $db-addresses; $adresses = $connection-jfdb-adresses; Thanks again! On Sat, Jul 6, 2013 at 2:57 PM, Jonathan Sundquist jsundqu...@gmail.comwrote: You commented out the setting of yhe addresses variable On Jul 6, 2013 1:42 PM, Tim Dunphy bluethu...@gmail.com wrote: Hey all, I'm trying to pick up some basic use of MongoDB using PHP. I seem to have hit an early obstacle that I'd like your opinion on. I try to pass an array to the mongo insert function, but for some reason the function does not recognize the array I'm passing. Even though I can perform a var_dump() on the array and see the contents. Here's the output I'm seeing (with error): Mongo Test Page array(6) { [first_name]= string(5) Peter [last_name]= string(6) Parker [address]= string(16) 175 Fifth Avenue [city]= string(8) New York [state]= string(2) NY [zip]= string(5) 10010 } *Notice*: Undefined variable: addresses in */var/www/mongomaven/index.php* on line *36* *Fatal error*: Call to a member function insert() on a non-object in * /var/www/mongomaven/index.php* on line *36* * * And here's the code: html head titleMongo Test/title /head body Mongo Test Page ?php $connection = new Mongo(); $db = $connection-jfdb; $collection = $db-addresses; //$adresses = $connection-jfdb-adresses; $address = array( 'first_name' = 'Peter', 'last_name' = 'Parker', 'address' = '175 Fifth Avenue', 'city' = 'New York', 'state' = 'NY', 'zip' = '10010',); var_dump($address); echo 'br /'; $addresses-insert($address); ? /body /html I'd appreciate any advice you might have. Thanks, Tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
Re: [PHP] Guaranteed Way to Get Error Message Wanted
On 6 July 2013 19:50, Brian Smither bhsmit...@gmail.com wrote: It looks like you are running the thread-safe version with FastCGI, which I understand to be counter to the recommendations. Thank you for the comment. I switched to PHP5.4.17-NTS-VC9, but the application still crashes. And still no clue as to why. So, still looking for that magic method to get PHP to report what's happening on a 500 Internal Server Error when it's (presumably? not sure...) not the server's fault. Have you got all your extensions updated? Enable display_startup_errors. Try running the command line PHP ... php -r echo 1; With your config. Just to see if there is anything ultra obvious missing. -- Richard Quadling Twitter : @RQuadling
Re: [PHP] Guaranteed Way to Get Error Message Wanted
On 6 July 2013 21:45, Brian Smither bhsmit...@gmail.com wrote: Have you got all your extensions updated? I would think so. Just to state the required disclaimers: phpinfo.php with ? phpinfo() ? works. Liberally peppering a tracer routine throughout the application shows it is getting executed up until one spot. But there is nothing obviously wrong with the code. Nothing! That's why I need the guaranteed message delivery on why PHP does not like the code. Turn on all your error reporting/logging. Add a try/catch if appropriate. Turn off any unhandled exception processing. Load in XDebug and get a trace going, what is the code doing prior to failure? -- Richard Quadling Twitter : @RQuadling
Re: [PHP] mongo usage
On Sat, Jul 6, 2013 at 9:16 PM, Tim Dunphy bluethu...@gmail.com wrote: | You commented out the setting of yhe addresses variable Those were both equivalent ways of stating the same thing. I tried substituting the other statement but there was no change: $db = $connection-jfdb; //$collection = $db-addresses; $adresses = $connection-jfdb-adresses; Thanks again! You seem to spell the variable differently (1 'd' vs. 2 'd's)? - Matijn
Re: [PHP] mongo usage
| You seem to spell the variable differently (1 'd' vs. 2 'd's)? Thanks! Fixed the type-o. Still no change. $connection = new Mongo(); $db = $connection-jfdb; //$collection = $db-addresses; $adresses = $connection-jfdb-addresses; Any other suggestions? Appreciated. Tim On Sat, Jul 6, 2013 at 5:39 PM, Matijn Woudt tijn...@gmail.com wrote: On Sat, Jul 6, 2013 at 9:16 PM, Tim Dunphy bluethu...@gmail.com wrote: | You commented out the setting of yhe addresses variable Those were both equivalent ways of stating the same thing. I tried substituting the other statement but there was no change: $db = $connection-jfdb; //$collection = $db-addresses; $adresses = $connection-jfdb-adresses; Thanks again! You seem to spell the variable differently (1 'd' vs. 2 'd's)? - Matijn -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
Re: [PHP] Re: mongo usage
Thanks. Sorry to bug you guys with this. That did it. sigh On Sat, Jul 6, 2013 at 6:49 PM, Tim Streater t...@clothears.org.uk wrote: On 06 Jul 2013 at 23:27, Tim Dunphy bluethu...@gmail.com wrote: | You seem to spell the variable differently (1 'd' vs. 2 'd's)? Thanks! Fixed the type-o. Still no change. $connection = new Mongo(); $db = $connection-jfdb; //$collection = $db-addresses; $adresses = $connection-jfdb-addresses; ~ Any other suggestions? Appreciated. Fix the other typo. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
Re: [PHP] Web dev, DB and proper db design.
Tamara Temple wrote in message news:557a0092-2b7d-49f4-ae3d-593968dd3...@gmail.com... On Jul 4, 2013, at 8:02 AM, Jim Giner jim.gi...@albanyhandball.com wrote: On 7/4/2013 6:42 AM, Richard Quadling wrote: Hi. I've just had a conversation regarding DB, foreign keys and their benefits. I was told I've never worked on a web application where foreign keys were used in the database. As someone who has spent 25 years working on accounting/epos systems on MS SQL Server (yep, windows) and now in a web environment and hearing the above, ... well, ... slightly concerned. So, in the biggest broadest terms, what do you lot do? DBs with no foreign keys (constrainted or not). ORM builders with manual definition of relationships between the tables. Inline SQL where you have to just remember all the relationships. Views for simple lookups? How do you handle updatable views (does mysql support them?) etc. Is there a difference in those in 'startups' and web only situations, or those doing more traditional development (split that as you like - I'm just trying to get an understanding and not go off on one!). No definitive answers, and I hope I get some wide experiences here. Thanks for looking. Richard. Im going to guess that your source of such drivel never learned about such things. Probably thinks that a 'key' has to be defined as such in the db, whereas we know what a FK really is. Don't worry. As a former big iron guy and then a c/s guy and now a (new) web guy, things haven't changed. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php So, like Jim, I'm just going to speculate your correspondent has never actually designed anything very interesting. I can't really imagine how one does not use foreign keys, unless one does the entire relationship mapping between tables in the source… what a waste that would be. Tamara Temple wrote in message news:557a0092-2b7d-49f4-ae3d-593968dd3...@gmail.com... On Jul 4, 2013, at 8:02 AM, Jim Giner jim.gi...@albanyhandball.com wrote: On 7/4/2013 6:42 AM, Richard Quadling wrote: Hi. I've just had a conversation regarding DB, foreign keys and their benefits. I was told I've never worked on a web application where foreign keys were used in the database. As someone who has spent 25 years working on accounting/epos systems on MS SQL Server (yep, windows) and now in a web environment and hearing the above, ... well, ... slightly concerned. So, in the biggest broadest terms, what do you lot do? DBs with no foreign keys (constrainted or not). ORM builders with manual definition of relationships between the tables. Inline SQL where you have to just remember all the relationships. Views for simple lookups? How do you handle updatable views (does mysql support them?) etc. Is there a difference in those in 'startups' and web only situations, or those doing more traditional development (split that as you like - I'm just trying to get an understanding and not go off on one!). No definitive answers, and I hope I get some wide experiences here. Thanks for looking. Richard. Im going to guess that your source of such drivel never learned about such things. Probably thinks that a 'key' has to be defined as such in the db, whereas we know what a FK really is. Don't worry. As a former big iron guy and then a c/s guy and now a (new) web guy, things haven't changed. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php So, like Jim, I'm just going to speculate your correspondent has never actually designed anything very interesting. I can't really imagine how one does not use foreign keys, unless one does the entire relationship mapping between tables in the source… what a waste that would be.= I was designing and building database applications before relational databases became popular, and in those old hierarchical and network databases there were no such things as foreign key constraints. Database integrity had to be handled in the code, which is what we did. When I started working with relational databases there were features of the language, such as FK constraints, which were rarely used even though they were there. When I started working on web applications the predominant database was MySQL, and the vast majority of ISPs would only offer MyISAM and not Innodb, and MyISAM does not support FK constraints. There are some programmers who complain that without foreign keys being defined in the database, how do you recognise relationships to build into SELECT statements? Simple. Every primary key is in the format ‘tablename_id’, so if you see this format in a table, and tablename is a different table, then it’s a foreign key. This is actually easier to identify than having to look in a separate place. Remember that there is a difference between a foreign key and a foreign key constraint. Foreign keys can
Re: [PHP] Web dev, DB and proper db design.
Tony Marston wrote: I was designing and building database applications before relational databases became popular, and in those old hierarchical and network databases there were no such things as foreign key constraints. Database integrity had to be handled in the code, which is what we did. When I started working with relational databases there were features of the language, such as FK constraints, which were rarely used even though they were there. When I started working on web applications the predominant database was MySQL, and the vast majority of ISPs would only offer MyISAM and not Innodb, and MyISAM does not support FK constraints. This was my point about MySQL ... what database were you using before MySQL came along? There are some programmers who complain that without foreign keys being defined in the database, how do you recognise relationships to build into SELECT statements? Simple. Every primary key is in the format ‘tablename_id’, so if you see this format in a table, and tablename is a different table, then it’s a foreign key. This is actually easier to identify than having to look in a separate place. Remember that there is a difference between a foreign key and a foreign key constraint. Foreign keys can exist without constraints, so saying that you cannot use a field as a foreign key in a SELECT statement without having a constraint defined in the database is just plain wrong. Certainly in some instances then managing everything in code makes sense. Cross database working for instance. So everything works the same for each engine. But the main advantage of adding constraints in the database is that it protects the foreign entries from being deleted while they are still in use. One of the problems I end up having to recover is where a hickup in the PHP or user side of things has deleted an entry, or more usually the whole table! In this case a properly implemented constraint would have prevented the problem. While using a constraint to manage the deletion of detail elements has a place in reducing traffic between program and datbase, the protection of detail elements is the more useful reason for maintaining them. -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Web dev, DB and proper db design.
Lester Caine wrote in message news:51d6987c.9050...@lsces.co.uk... Tony Marston wrote: I was designing and building database applications before relational databases became popular, and in those old hierarchical and network databases there were no such things as foreign key constraints. Database integrity had to be handled in the code, which is what we did. When I started working with relational databases there were features of the language, such as FK constraints, which were rarely used even though they were there. When I started working on web applications the predominant database was MySQL, and the vast majority of ISPs would only offer MyISAM and not Innodb, and MyISAM does not support FK constraints. This was my point about MySQL ... what database were you using before MySQL came along? I used ORACLE and SOLID, and before that Hewlett Packard's IMAGE (network DB) and Data General's INFOS (hierarchical DB). There are some programmers who complain that without foreign keys being defined in the database, how do you recognise relationships to build into SELECT statements? Simple. Every primary key is in the format ‘tablename_id’, so if you see this format in a table, and tablename is a different table, then it’s a foreign key. This is actually easier to identify than having to look in a separate place. Remember that there is a difference between a foreign key and a foreign key constraint. Foreign keys can exist without constraints, so saying that you cannot use a field as a foreign key in a SELECT statement without having a constraint defined in the database is just plain wrong. Certainly in some instances then managing everything in code makes sense. Cross database working for instance. So everything works the same for each engine. But the main advantage of adding constraints in the database is that it protects the foreign entries from being deleted while they are still in use. One of the problems I end up having to recover is where a hickup in the PHP or user side of things has deleted an entry, or more usually the whole table! In this case a properly implemented constraint would have prevented the problem. While using a constraint to manage the deletion of detail elements has a place in reducing traffic between program and database, the protection of detail elements is the more useful reason for maintaining them. In my framework I define relationships and any constraints in my data dictionary, and these are enforced by a standard module in the framework. This means that any RESTRICTED constraints can be detected in the code without executing a DELETE and having it abort. -- Tony Marston http://www.tonymarston.net http://www.radicore.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Web dev, DB and proper db design.
Tony Marston wrote: Certainly in some instances then managing everything in code makes sense. Cross database working for instance. So everything works the same for each engine. But the main advantage of adding constraints in the database is that it protects the foreign entries from being deleted while they are still in use. One of the problems I end up having to recover is where a hickup in the PHP or user side of things has deleted an entry, or more usually the whole table! In this case a properly implemented constraint would have prevented the problem. While using a constraint to manage the deletion of detail elements has a place in reducing traffic between program and database, the protection of detail elements is the more useful reason for maintaining them. In my framework I define relationships and any constraints in my data dictionary, and these are enforced by a standard module in the framework. This means that any RESTRICTED constraints can be detected in the code without executing a DELETE and having it abort. My own database management framework pre-dates PHP switching from dBase originally, to Interbase and then Firebird as it was open sourced (just as we had paid for a large number of Interbase licenses :( ). So I've grown up using the tools in the database, but have to back pedal some of the time where a cross database solution is required. I'm much more comfortable with getting the database to manage things and will often drop triggers in rather than coding that in PHP. So proper db designis probably still geared around what we are used to rather than any had and fast rules? -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can this work?
On 5 Jul 2013, at 14:56, Karl-Arne Gjersøyen karlar...@gmail.com wrote: Hello. I have a form in HTML/PHP with for loops that generate a selected list like this: for($i = 1; $i 25;$i++ ){ option value=?php echo $i; ??php echo $i; ?/option } The lists look like this: form action=index.php view-source:http://localhost/%7Ekarl/kasen/io/kp/index.php method=postselect name=valgt_dynamit_polse_1-25kgoption value=1-25 selected=selected1-25/optionoption value=11/optionoption value=22/optionoption value=33/optionoption value=44/optionoption value=55/optionoption value=66/optionoption value=77/optionoption value=88/optionoption value=99/optionoption value=1010/optionoption value=/optionoption value=1212/optionoption value=1313/optionoption value=1414/optionoption value=1515/optionoption value=1616/optionoption value=1717/optionoption value=1818/optionoption value=1919/optionoption value=2020/optionoption value=2121/optionoption value=/optionoption value=2323/optionoption value=2424/optionoption value=2525/option/select Kgnbsp;select name=valgt_dynamit_polse_26-50kgoption value=26-50 selected=selected26-50/optionoption value=2626/optionoption value=2727/optionoption value=2828/optionoption value=2929/optionoption value=3030/optionoption value=3131/optionoption value=3232/optionoption value=/optionoption value=3434/optionoption value=3535/optionoption value=3636/optionoption value=3737/optionoption value=3838/optionoption value=3939/optionoption value=4040/optionoption value=4141/optionoption value=4242/optionoption value=4343/optionoption value=/optionoption value=4545/optionoption value=4646/optionoption value=4747/optionoption value=4848/optionoption value=4949/optionoption value=5050/option/select Kgnbsp; What I try to do with it is to register the selected value and do something with it. The lists is weight in KG. I hope to select only one value between 1-25kg OR 26-50kg. I don't know if this is possible? What do you think? If the range of acceptable values is 1-50, why do you have two select fields instead of one? ?php for ($i = 1; $i = 50; $i++) { ? option value=?php echo $i; ??php echo $i; ?/option ?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] Can this work?
On Jul 5, 2013, at 9:56 AM, Karl-Arne Gjersøyen karlar...@gmail.com wrote: The lists look like this: form action=index.php view-source:http://localhost/%7Ekarl/kasen/io/kp/index.php method=postselect name=valgt_dynamit_polse_1-25kgoption value=1-25 selected=selected1-25/optionoption value=11/optionoption value=22/optionoption Review this: http://sperling.com/php/select/ Also, omit 'multiple' in the select statement. Other than that, the demo shows how to gather the information you want. Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can this work?
2013/7/5 Stuart Dallas stu...@3ft9.com On 5 Jul 2013, at 14:56, Karl-Arne Gjersøyen karlar...@gmail.com wrote: Hello. I have a form in HTML/PHP with for loops that generate a selected list like this: for($i = 1; $i 25;$i++ ){ option value=?php echo $i; ??php echo $i; ?/option } The lists look like this: form action=index.php view-source:http://localhost/%7Ekarl/kasen/io/kp/index.php method=postselect name=valgt_dynamit_polse_1-25kgoption value=1-25 selected=selected1-25/optionoption value=11/optionoption value=22/optionoption value=33/optionoption value=44/optionoption value=55/optionoption value=66/optionoption value=77/optionoption value=88/optionoption value=99/optionoption value=1010/optionoption value=/optionoption value=1212/optionoption value=1313/optionoption value=1414/optionoption value=1515/optionoption value=1616/optionoption value=1717/optionoption value=1818/optionoption value=1919/optionoption value=2020/optionoption value=2121/optionoption value=/optionoption value=2323/optionoption value=2424/optionoption value=2525/option/select Kgnbsp;select name=valgt_dynamit_polse_26-50kgoption value=26-50 selected=selected26-50/optionoption value=2626/optionoption value=2727/optionoption value=2828/optionoption value=2929/optionoption value=3030/optionoption value=3131/optionoption value=3232/optionoption value=/optionoption value=3434/optionoption value=3535/optionoption value=3636/optionoption value=3737/optionoption value=3838/optionoption value=3939/optionoption value=4040/optionoption value=4141/optionoption value=4242/optionoption value=4343/optionoption value=/optionoption value=4545/optionoption value=4646/optionoption value=4747/optionoption value=4848/optionoption value=4949/optionoption value=5050/option/select Kgnbsp; What I try to do with it is to register the selected value and do something with it. The lists is weight in KG. I hope to select only one value between 1-25kg OR 26-50kg. I don't know if this is possible? What do you think? If the range of acceptable values is 1-50, why do you have two select fields instead of one? The select list has values between 1 and 200. Therefore I split it up for every 25th value. Karl
Re: [PHP] Can this work?
2013/7/5 Tedd Sperling tedd.sperl...@gmail.com On Jul 5, 2013, at 9:56 AM, Karl-Arne Gjersøyen karlar...@gmail.com wrote: The lists look like this: form action=index.php view-source:http://localhost/%7Ekarl/kasen/io/kp/index.php method=postselect name=valgt_dynamit_polse_1-25kgoption value=1-25 selected=selected1-25/optionoption value=11/optionoption value=22/optionoption Review this: http://sperling.com/php/select/ Also, omit 'multiple' in the select statement. Other than that, the demo shows how to gather the information you want. Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com Thank you very much! http://www.karl-arne.name/
Re: [PHP] Can this work?
On 5 Jul 2013, at 15:05, Karl-Arne Gjersøyen karlar...@gmail.com wrote: 2013/7/5 Stuart Dallas stu...@3ft9.com On 5 Jul 2013, at 14:56, Karl-Arne Gjersøyen karlar...@gmail.com wrote: Hello. I have a form in HTML/PHP with for loops that generate a selected list like this: for($i = 1; $i 25;$i++ ){ option value=?php echo $i; ??php echo $i; ?/option } The lists look like this: form action=index.php view-source:http://localhost/%7Ekarl/kasen/io/kp/index.php method=postselect name=valgt_dynamit_polse_1-25kgoption value=1-25 selected=selected1-25/optionoption value=11/optionoption value=22/optionoption value=33/optionoption value=44/optionoption value=55/optionoption value=66/optionoption value=77/optionoption value=88/optionoption value=99/optionoption value=1010/optionoption value=/optionoption value=1212/optionoption value=1313/optionoption value=1414/optionoption value=1515/optionoption value=1616/optionoption value=1717/optionoption value=1818/optionoption value=1919/optionoption value=2020/optionoption value=2121/optionoption value=/optionoption value=2323/optionoption value=2424/optionoption value=2525/option/select Kgnbsp;select name=valgt_dynamit_polse_26-50kgoption value=26-50 selected=selected26-50/optionoption value=2626/optionoption value=2727/optionoption value=2828/optionoption value=2929/optionoption value=3030/optionoption value=3131/optionoption value=3232/optionoption value=/optionoption value=3434/optionoption value=3535/optionoption value=3636/optionoption value=3737/optionoption value=3838/optionoption value=3939/optionoption value=4040/optionoption value=4141/optionoption value=4242/optionoption value=4343/optionoption value=/optionoption value=4545/optionoption value=4646/optionoption value=4747/optionoption value=4848/optionoption value=4949/optionoption value=5050/option/select Kgnbsp; What I try to do with it is to register the selected value and do something with it. The lists is weight in KG. I hope to select only one value between 1-25kg OR 26-50kg. I don't know if this is possible? What do you think? If the range of acceptable values is 1-50, why do you have two select fields instead of one? The select list has values between 1 and 200. Therefore I split it up for every 25th value. Ok, but why? -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] Can this work?
2013/7/5 Stuart Dallas stu...@3ft9.com On 5 Jul 2013, at 15:05, Karl-Arne Gjersøyen karlar...@gmail.com wrote: 2013/7/5 Stuart Dallas stu...@3ft9.com On 5 Jul 2013, at 14:56, Karl-Arne Gjersøyen karlar...@gmail.com wrote: Hello. I have a form in HTML/PHP with for loops that generate a selected list like this: for($i = 1; $i 25;$i++ ){ option value=?php echo $i; ??php echo $i; ?/option } The lists look like this: form action=index.php view-source:http://localhost/%7Ekarl/kasen/io/kp/index.php method=postselect name=valgt_dynamit_polse_1-25kgoption value=1-25 selected=selected1-25/optionoption value=11/optionoption value=22/optionoption value=33/optionoption value=44/optionoption value=55/optionoption value=66/optionoption value=77/optionoption value=88/optionoption value=99/optionoption value=1010/optionoption value=/optionoption value=1212/optionoption value=1313/optionoption value=1414/optionoption value=1515/optionoption value=1616/optionoption value=1717/optionoption value=1818/optionoption value=1919/optionoption value=2020/optionoption value=2121/optionoption value=/optionoption value=2323/optionoption value=2424/optionoption value=2525/option/select Kgnbsp;select name=valgt_dynamit_polse_26-50kgoption value=26-50 selected=selected26-50/optionoption value=2626/optionoption value=2727/optionoption value=2828/optionoption value=2929/optionoption value=3030/optionoption value=3131/optionoption value=3232/optionoption value=/optionoption value=3434/optionoption value=3535/optionoption value=3636/optionoption value=3737/optionoption value=3838/optionoption value=3939/optionoption value=4040/optionoption value=4141/optionoption value=4242/optionoption value=4343/optionoption value=/optionoption value=4545/optionoption value=4646/optionoption value=4747/optionoption value=4848/optionoption value=4949/optionoption value=5050/option/select Kgnbsp; What I try to do with it is to register the selected value and do something with it. The lists is weight in KG. I hope to select only one value between 1-25kg OR 26-50kg. I don't know if this is possible? What do you think? If the range of acceptable values is 1-50, why do you have two select fields instead of one? The select list has values between 1 and 200. Therefore I split it up for every 25th value. Ok, but why? I will use my application on iPad and find it more easy to use multiple select lists than one big list with all 200 values at once. Karl
Re: [PHP] Can this work?
On 5 Jul 2013, at 15:24, Karl-Arne Gjersøyen karlar...@gmail.com wrote: 2013/7/5 Stuart Dallas stu...@3ft9.com On 5 Jul 2013, at 15:05, Karl-Arne Gjersøyen karlar...@gmail.com wrote: 2013/7/5 Stuart Dallas stu...@3ft9.com On 5 Jul 2013, at 14:56, Karl-Arne Gjersøyen karlar...@gmail.com wrote: Hello. I have a form in HTML/PHP with for loops that generate a selected list like this: for($i = 1; $i 25;$i++ ){ option value=?php echo $i; ??php echo $i; ?/option } The lists look like this: form action=index.php view-source:http://localhost/%7Ekarl/kasen/io/kp/index.php method=postselect name=valgt_dynamit_polse_1-25kgoption value=1-25 selected=selected1-25/optionoption value=11/optionoption value=22/optionoption value=33/optionoption value=44/optionoption value=55/optionoption value=66/optionoption value=77/optionoption value=88/optionoption value=99/optionoption value=1010/optionoption value=/optionoption value=1212/optionoption value=1313/optionoption value=1414/optionoption value=1515/optionoption value=1616/optionoption value=1717/optionoption value=1818/optionoption value=1919/optionoption value=2020/optionoption value=2121/optionoption value=/optionoption value=2323/optionoption value=2424/optionoption value=2525/option/select Kgnbsp;select name=valgt_dynamit_polse_26-50kgoption value=26-50 selected=selected26-50/optionoption value=2626/optionoption value=2727/optionoption value=2828/optionoption value=2929/optionoption value=3030/optionoption value=3131/optionoption value=3232/optionoption value=/optionoption value=3434/optionoption value=3535/optionoption value=3636/optionoption value=3737/optionoption value=3838/optionoption value=3939/optionoption value=4040/optionoption value=4141/optionoption value=4242/optionoption value=4343/optionoption value=/optionoption value=4545/optionoption value=4646/optionoption value=4747/optionoption value=4848/optionoption value=4949/optionoption value=5050/option/select Kgnbsp; What I try to do with it is to register the selected value and do something with it. The lists is weight in KG. I hope to select only one value between 1-25kg OR 26-50kg. I don't know if this is possible? What do you think? If the range of acceptable values is 1-50, why do you have two select fields instead of one? The select list has values between 1 and 200. Therefore I split it up for every 25th value. Ok, but why? I will use my application on iPad and find it more easy to use multiple select lists than one big list with all 200 values at once. In that case I would recommend using a text input field and validate it with javascript and then validate it again on the server-side with PHP. With multiple select fields the only way you'll know which one the user (i.e. you) meant is by resetting the others to an empty value whenever one of them changes. -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] Can this work?
Can't you just use a number field, which is a hell of a lot easier (especially on an iPad) to use than a bunch of select lists. Karl-Arne Gjersøyen karlar...@gmail.com wrote: 2013/7/5 Stuart Dallas stu...@3ft9.com On 5 Jul 2013, at 15:05, Karl-Arne Gjersøyen karlar...@gmail.com wrote: 2013/7/5 Stuart Dallas stu...@3ft9.com On 5 Jul 2013, at 14:56, Karl-Arne Gjersøyen karlar...@gmail.com wrote: Hello. I have a form in HTML/PHP with for loops that generate a selected list like this: for($i = 1; $i 25;$i++ ){ option value=?php echo $i; ??php echo $i; ?/option } The lists look like this: form action=index.php view-source:http://localhost/%7Ekarl/kasen/io/kp/index.php method=postselect name=valgt_dynamit_polse_1-25kgoption value=1-25 selected=selected1-25/optionoption value=11/optionoption value=22/optionoption value=33/optionoption value=44/optionoption value=55/optionoption value=66/optionoption value=77/optionoption value=88/optionoption value=99/optionoption value=1010/optionoption value=/optionoption value=1212/optionoption value=1313/optionoption value=1414/optionoption value=1515/optionoption value=1616/optionoption value=1717/optionoption value=1818/optionoption value=1919/optionoption value=2020/optionoption value=2121/optionoption value=/optionoption value=2323/optionoption value=2424/optionoption value=2525/option/select Kgnbsp;select name=valgt_dynamit_polse_26-50kgoption value=26-50 selected=selected26-50/optionoption value=2626/optionoption value=2727/optionoption value=2828/optionoption value=2929/optionoption value=3030/optionoption value=3131/optionoption value=3232/optionoption value=/optionoption value=3434/optionoption value=3535/optionoption value=3636/optionoption value=3737/optionoption value=3838/optionoption value=3939/optionoption value=4040/optionoption value=4141/optionoption value=4242/optionoption value=4343/optionoption value=/optionoption value=4545/optionoption value=4646/optionoption value=4747/optionoption value=4848/optionoption value=4949/optionoption value=5050/option/select Kgnbsp; What I try to do with it is to register the selected value and do something with it. The lists is weight in KG. I hope to select only one value between 1-25kg OR 26-50kg. I don't know if this is possible? What do you think? If the range of acceptable values is 1-50, why do you have two select fields instead of one? The select list has values between 1 and 200. Therefore I split it up for every 25th value. Ok, but why? I will use my application on iPad and find it more easy to use multiple select lists than one big list with all 200 values at once. Karl Can't you just use a number field, which is a hell of a lot easier (especially on an iPad) to use than a bunch of select lists. Thanks, Ash -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strlen ?
Jim Giner wrote: Trying to manage line breaks in some output I'm generating and using strlen to measure the lengths of the strings I'm printing. Discovered something strange (to me!) in that strlen is returning +1 more than it should. The strings are from a query of my database - simple name fields. But everyone of them is coming back with a length that is one more than I see. Ex. Mike Hall comes back as 10, not 9 F.B. comes back as 5, not 4. I've looked at my data and counted the chars - there is no extra space at the beginning or end in my table. Anyone have an explanation? Does strlen count the line feed? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strlen ?
On Fri, Jul 5, 2013 at 11:10 PM, Jim Giner jim.gi...@albanyhandball.comwrote: Mike Hall comes back as 10, not 9 F.B. comes back as 5, not 4. Doesn't work for me. php var_dump(Mike Hall, strlen(Mike Hall)); string(9) Mike Hall int(9) Try trimming it first and then apply strlen. -- Shiplu.Mokadd.im ImgSign.com | A dynamic signature machine Innovation distinguishes between follower and leader
Re: [PHP] strlen ?
On 7/5/2013 1:32 PM, shiplu wrote: On Fri, Jul 5, 2013 at 11:10 PM, Jim Giner jim.gi...@albanyhandball.comwrote: Mike Hall comes back as 10, not 9 F.B. comes back as 5, not 4. Doesn't work for me. php var_dump(Mike Hall, strlen(Mike Hall)); string(9) Mike Hall int(9) Try trimming it first and then apply strlen. Why would I need to trim something that I can already see doesn't have any trailing or leading characters? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strlen ?
On Fri, Jul 5, 2013 at 8:33 PM, Jim Giner jim.gi...@albanyhandball.comwrote: On 7/5/2013 1:32 PM, shiplu wrote: On Fri, Jul 5, 2013 at 11:10 PM, Jim Giner jim.gi...@albanyhandball.com **wrote: Mike Hall comes back as 10, not 9 F.B. comes back as 5, not 4. Doesn't work for me. php var_dump(Mike Hall, strlen(Mike Hall)); string(9) Mike Hall int(9) Try trimming it first and then apply strlen. Why would I need to trim something that I can already see doesn't have any trailing or leading characters? Because there are characters you can't see?
Re: [PHP] strlen ?
On Fri, Jul 5, 2013 at 8:39 PM, Jim Giner jim.gi...@albanyhandball.comwrote: I checked them in the db manually. Clicked on the name, selected it, no extra space highlighted. Cursored through the length of the value - no extra movements. That does still not guarantee there are no extra characters. Some characters are just not visible (NUL, CR, LF, ..) On 7/5/2013 2:36 PM, Matijn Woudt wrote: On Fri, Jul 5, 2013 at 8:33 PM, Jim Giner jim.gi...@albanyhandball.comwrote: On 7/5/2013 1:32 PM, shiplu wrote: On Fri, Jul 5, 2013 at 11:10 PM, Jim Giner jim.gi...@albanyhandball.com wrote: Mike Hall comes back as 10, not 9 F.B. comes back as 5, not 4. Doesn't work for me. php var_dump(Mike Hall, strlen(Mike Hall)); string(9) Mike Hall int(9) Try trimming it first and then apply strlen. Why would I need to trim something that I can already see doesn't have any trailing or leading characters? Because there are characters you can't see?
Re: [PHP] strlen ?
On 7/5/2013 2:42 PM, Matijn Woudt wrote: On Fri, Jul 5, 2013 at 8:39 PM, Jim Giner jim.gi...@albanyhandball.comwrote: I checked them in the db manually. Clicked on the name, selected it, no extra space highlighted. Cursored through the length of the value - no extra movements. That does still not guarantee there are no extra characters. Some characters are just not visible (NUL, CR, LF, ..) On 7/5/2013 2:36 PM, Matijn Woudt wrote: On Fri, Jul 5, 2013 at 8:33 PM, Jim Giner jim.gi...@albanyhandball.comwrote: On 7/5/2013 1:32 PM, shiplu wrote: On Fri, Jul 5, 2013 at 11:10 PM, Jim Giner jim.gi...@albanyhandball.com wrote: Mike Hall comes back as 10, not 9 F.B. comes back as 5, not 4. Doesn't work for me. php var_dump(Mike Hall, strlen(Mike Hall)); string(9) Mike Hall int(9) Try trimming it first and then apply strlen. Why would I need to trim something that I can already see doesn't have any trailing or leading characters? Because there are characters you can't see? And the answer is - yes, there is a LF char at the end of my data in my whole table. Now the question is - how the heck did I put that in there? Certainly not intentionally. The data is captured from a d/e screen I wrote and it simply grabs the post value and inserts a new record with that value along with some other values. And I don't see anything concatenating a LF to my string. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strlen ?
On 13-07-05 02:50 PM, Jim Giner wrote: Now the question is - how the heck did I put that in there? Certainly not intentionally. The data is captured from a d/e screen I wrote and it simply grabs the post value and inserts a new record with that value along with some other values. And I don't see anything concatenating a LF to my string. Is this a browser being used for input? Never assume what a browser will do. It is good practice to validate and condition data before inserting into a database. Consider trimming the data before doing the INSERT. -- Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strlen ?
On 7/5/2013 3:02 PM, Stephen wrote: On 13-07-05 02:50 PM, Jim Giner wrote: Now the question is - how the heck did I put that in there? Certainly not intentionally. The data is captured from a d/e screen I wrote and it simply grabs the post value and inserts a new record with that value along with some other values. And I don't see anything concatenating a LF to my string. Is this a browser being used for input? Never assume what a browser will do. It is good practice to validate and condition data before inserting into a database. Consider trimming the data before doing the INSERT. I do validate my data by quoting it but I never expected to have to do a trim to remove a LF. Especially on an iphone for input, since it's not easy to enter a LF. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strlen ?
MOTS: never take any input on faith. Jim Giner wrote: On 7/5/2013 3:02 PM, Stephen wrote: On 13-07-05 02:50 PM, Jim Giner wrote: Now the question is - how the heck did I put that in there? Certainly not intentionally. The data is captured from a d/e screen I wrote and it simply grabs the post value and inserts a new record with that value along with some other values. And I don't see anything concatenating a LF to my string. Is this a browser being used for input? Never assume what a browser will do. It is good practice to validate and condition data before inserting into a database. Consider trimming the data before doing the INSERT. I do validate my data by quoting it but I never expected to have to do a trim to remove a LF. Especially on an iphone for input, since it's not easy to enter a LF. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Guaranteed Way to Get Error Message Wanted
Check the permissions on the files/directories involved. I get this on Linux when the files/directories are too open. Ken At 05:38 PM 7/5/2013, Brian Smither wrote: I have an application running under PHP-5.4.17-TS-VC9 (and .14 as of yesterday) with Aprelium's Abyss X1 v2.8 web server in FastCGI mode on WinXPSP3. An earlier version of this application works. The current version causes a 500 Internal Server Error. There is no entry in PHP's (fully active) error log. I cannot decipher Abyss's logging, so I cannot determine if a clue was reported by Abyss or not. The current version works on a different system (Server 2003, PHP 5.3.5-TS-VC6 (Apache module), Apache 2.2). What I would like to have is a method of getting PHP to report in some undeniable manner, short of total system failure, what it doesn't like about whatever killed it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strlen ?
Jim Giner jim.gi...@albanyhandball.com wrote: On 7/5/2013 3:02 PM, Stephen wrote: On 13-07-05 02:50 PM, Jim Giner wrote: Now the question is - how the heck did I put that in there? Certainly not intentionally. The data is captured from a d/e screen I wrote and it simply grabs the post value and inserts a new record with that value along with some other values. And I don't see anything concatenating a LF to my string. Is this a browser being used for input? Never assume what a browser will do. It is good practice to validate and condition data before inserting into a database. Consider trimming the data before doing the INSERT. I do validate my data by quoting it but I never expected to have to do a trim to remove a LF. Especially on an iphone for input, since it's not easy to enter a LF. Quoting the data is not the same thing as validating it. Thanks, Ash -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Web dev, DB and proper db design.
Richard Quadling wrote: Is there a difference in those in 'startups' and web only situations, or those doing more traditional development (split that as you like - I'm just trying to get an understanding and not go off on one!). Depends if you consider MySQL is any use as a real database :) Building the constraints and many other core database features into the code was essential before MySQL had many of the features that real databases have had from the start ... -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Web dev, DB and proper db design.
I think it depends on the application. A lot of small web apps simply don't need any kind of normalization, and it really does make sense to put everything in one table, or a couple of unlinked tables. Therefore, on those apps, there's no need for foreign keys. For instance: I used one in-house application that had two tables: A list of authorized users with their passwords and a couple of other things (administrative role, security level, things like that), and a table that contained information about computers used in the the department. Sure, some of the users had a computer in the department, but not all of them. So there was really no need to link the tables. And since the information stored about the computers was stuff like owner, name, MAC, and IP address, there was no need for foreign keys in that table either: it just wouldn't make sense. Now, anything much more complex then that there's going to be some value in using foreign keys, whether formally (constraints set in the DB) or informally (constraints imposed in the web interface), but it's quite possible the guy had never worked on something where they were needed. -Andy . On Thu, Jul 4, 2013 at 10:20 AM, Lester Caine les...@lsces.co.uk wrote: Richard Quadling wrote: Is there a difference in those in 'startups' and web only situations, or those doing more traditional development (split that as you like - I'm just trying to get an understanding and not go off on one!). Depends if you consider MySQL is any use as a real database :) Building the constraints and many other core database features into the code was essential before MySQL had many of the features that real databases have had from the start ... -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=**contacthttp://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.**ukhttp://rainbowdigitalmedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Web dev, DB and proper db design.
On Jul 4, 2013, at 8:02 AM, Jim Giner jim.gi...@albanyhandball.com wrote: On 7/4/2013 6:42 AM, Richard Quadling wrote: Hi. I've just had a conversation regarding DB, foreign keys and their benefits. I was told I've never worked on a web application where foreign keys were used in the database. As someone who has spent 25 years working on accounting/epos systems on MS SQL Server (yep, windows) and now in a web environment and hearing the above, ... well, ... slightly concerned. So, in the biggest broadest terms, what do you lot do? DBs with no foreign keys (constrainted or not). ORM builders with manual definition of relationships between the tables. Inline SQL where you have to just remember all the relationships. Views for simple lookups? How do you handle updatable views (does mysql support them?) etc. Is there a difference in those in 'startups' and web only situations, or those doing more traditional development (split that as you like - I'm just trying to get an understanding and not go off on one!). No definitive answers, and I hope I get some wide experiences here. Thanks for looking. Richard. Im going to guess that your source of such drivel never learned about such things. Probably thinks that a 'key' has to be defined as such in the db, whereas we know what a FK really is. Don't worry. As a former big iron guy and then a c/s guy and now a (new) web guy, things haven't changed. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php So, like Jim, I'm just going to speculate your correspondent has never actually designed anything very interesting. I can't really imagine how one does not use foreign keys, unless one does the entire relationship mapping between tables in the source… what a waste that would be. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Web dev, DB and proper db design.
On Thu, Jul 4, 2013 at 4:20 PM, Tamara Temple tamouse.li...@gmail.comwrote: On Jul 4, 2013, at 8:02 AM, Jim Giner jim.gi...@albanyhandball.com wrote: On 7/4/2013 6:42 AM, Richard Quadling wrote: Hi. I've just had a conversation regarding DB, foreign keys and their benefits. I was told I've never worked on a web application where foreign keys were used in the database. As someone who has spent 25 years working on accounting/epos systems on MS SQL Server (yep, windows) and now in a web environment and hearing the above, ... well, ... slightly concerned. So, in the biggest broadest terms, what do you lot do? DBs with no foreign keys (constrainted or not). ORM builders with manual definition of relationships between the tables. Inline SQL where you have to just remember all the relationships. Views for simple lookups? How do you handle updatable views (does mysql support them?) etc. Is there a difference in those in 'startups' and web only situations, or those doing more traditional development (split that as you like - I'm just trying to get an understanding and not go off on one!). No definitive answers, and I hope I get some wide experiences here. Thanks for looking. Richard. Im going to guess that your source of such drivel never learned about such things. Probably thinks that a 'key' has to be defined as such in the db, whereas we know what a FK really is. Don't worry. As a former big iron guy and then a c/s guy and now a (new) web guy, things haven't changed. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php So, like Jim, I'm just going to speculate your correspondent has never actually designed anything very interesting. I can't really imagine how one does not use foreign keys, unless one does the entire relationship mapping between tables in the source… what a waste that would be. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I completely agree.
Re: [PHP] Reseting the auto-increment number in a MySQL database.
On Jun 27, 2013, at 8:47 PM, Paul M Foster pa...@quillandmouse.com wrote: On Thu, Jun 27, 2013 at 11:47:28PM +0200, adriano wrote: holes in sequence of auto increment happen using transaction for insert new record but you don't commit transaction itself it seems that the autoincrement is incremented anyway at least this is my case. I think what Tedd was referring to was something else. The hole was quite large. I've seen this behavior myself, in PostgreSQL. From one transaction to the next, there were over 10,000 skipped numbers, and only me and my wife on the system. Some sort of bug, like a spinlock that wasn't interrupted the way it should have been. I remember the system taking forever to calm down before it gave the next transaction a number way forward of the last one. I waited in front of my browser for quite some time. But I couldn't explain why. Paul Yes, it was something like what Paul said -- it was not a transaction skip. I don't know what to think about it -- no explanation. But, the problem suddenly vanished -- very strange. Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with variables
Fernando A soporteallpurp...@gmail.com wrote: I am working with php and codeigniter, but I have not yet experienced. I need create a variable that is available throughout system. This variable contains the number of company and can change. as I can handle this? Hi, Fernando, welcome. I'm just a little unsure what you mean by number of company -- is this a count, as in 10 companies, or is it a phone number, or is it something else? Jim's reply is workable -- storing session values is quite useful, but sessions are tied to a specific browser client/ip, and I'm not sure that's what you want/need here. If you are looking for setting a global variable that will be available everywhere in your application, you can use $GLOBALS, or set it from the very top level context of the application. Given you're using CodeIgniter, which sadly I am not versed in, you may need to set it with $GLOBALS: $GLOBALS['my_var'] = 10; // whatever you need to do here When you say it changes, how and when exactly does it change? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reseting the auto-increment number in a MySQL database.
Tedd Sperling tedd.sperl...@gmail.com wrote: On Jun 27, 2013, at 8:47 PM, Paul M Foster pa...@quillandmouse.com wrote: On Thu, Jun 27, 2013 at 11:47:28PM +0200, adriano wrote: holes in sequence of auto increment happen using transaction for insert new record but you don't commit transaction itself it seems that the autoincrement is incremented anyway at least this is my case. I think what Tedd was referring to was something else. The hole was quite large. I've seen this behavior myself, in PostgreSQL. From one transaction to the next, there were over 10,000 skipped numbers, and only me and my wife on the system. Some sort of bug, like a spinlock that wasn't interrupted the way it should have been. I remember the system taking forever to calm down before it gave the next transaction a number way forward of the last one. I waited in front of my browser for quite some time. But I couldn't explain why. Paul Yes, it was something like what Paul said -- it was not a transaction skip. I don't know what to think about it -- no explanation. But, the problem suddenly vanished -- very strange. Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com I have no answers as to why the huge skip forward, the huge skip backwards though makes me think someone else is doing something in the database, and all the alarums and red flags are waving. I hope I'm wrong. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reseting the auto-increment number in a MySQL database.
holes in sequence of auto increment happen using transaction for insert new record but you don't commit transaction itself it seems that the autoincrement is incremented anyway at least this is my case. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reseting the auto-increment number in a MySQL database.
On Thu, Jun 27, 2013 at 11:47:28PM +0200, adriano wrote: holes in sequence of auto increment happen using transaction for insert new record but you don't commit transaction itself it seems that the autoincrement is incremented anyway at least this is my case. I think what Tedd was referring to was something else. The hole was quite large. I've seen this behavior myself, in PostgreSQL. From one transaction to the next, there were over 10,000 skipped numbers, and only me and my wife on the system. Some sort of bug, like a spinlock that wasn't interrupted the way it should have been. I remember the system taking forever to calm down before it gave the next transaction a number way forward of the last one. I waited in front of my browser for quite some time. But I couldn't explain why. 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] Reseting the auto-increment number in a MySQL database.
You can try this: *ALTER TABLE tbl AUTO_INCREMENT = 100;* * * *Source: *http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html (never did it myself, though) On Wed, Jun 26, 2013 at 2:07 PM, Tedd Sperling t...@sperling.com wrote: Hi gang: I have a client where their next auto-increment number just jumped from 2300 to 10 for reasons not understood. They want it set back. Options such as dropping the primary key and rebuilding the index is NOT possible -- this is a relational table thing. So, is there a way (programmatically) to set the next number in an auto-increment? Something like: alter table abc auto_increment = 2301; Any ideas of why this happened? Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reseting the auto-increment number in a MySQL database.
On Wednesday, 26 June 2013 at 18:07, Tedd Sperling wrote: Hi gang: I have a client where their next auto-increment number just jumped from 2300 to 10 for reasons not understood. They want it set back. Options such as dropping the primary key and rebuilding the index is NOT possible -- this is a relational table thing. So, is there a way (programmatically) to set the next number in an auto-increment? Something like: alter table abc auto_increment = 2301; ALTER TABLE tbl AUTO_INCREMENT = 2301; -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] Reseting the auto-increment number in a MySQL database.
On Jun 26, 2013, at 1:13 PM, Stuart Dallas stu...@3ft9.com wrote: On Wednesday, 26 June 2013 at 18:07, Tedd Sperling wrote: Hi gang: I have a client where their next auto-increment number just jumped from 2300 to 10 for reasons not understood. They want it set back. Options such as dropping the primary key and rebuilding the index is NOT possible -- this is a relational table thing. So, is there a way (programmatically) to set the next number in an auto-increment? Something like: alter table abc auto_increment = 2301; ALTER TABLE tbl AUTO_INCREMENT = 2301; -Stuart Thanks -- I needed confirmation on that. It is something that i don't want to do. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reseting the auto-increment number in a MySQL database.
On 6/26/2013 1:30 PM, Tedd Sperling wrote: On Jun 26, 2013, at 1:13 PM, Stuart Dallas stu...@3ft9.com wrote: On Wednesday, 26 June 2013 at 18:07, Tedd Sperling wrote: Hi gang: I have a client where their next auto-increment number just jumped from 2300 to 10 for reasons not understood. They want it set back. Options such as dropping the primary key and rebuilding the index is NOT possible -- this is a relational table thing. So, is there a way (programmatically) to set the next number in an auto-increment? Something like: alter table abc auto_increment = 2301; ALTER TABLE tbl AUTO_INCREMENT = 2301; -Stuart Thanks -- I needed confirmation on that. It is something that i don't want to do. Cheers, tedd _ t...@sperling.com http://sperling.com But more importantly - don't you need to figure out why it happened?? As well as correcting any inserts with the bogus id? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reseting the auto-increment number in a MySQL database.
On Jun 26, 2013, at 1:32 PM, Jim Giner jim.gi...@albanyhandball.com wrote: But more importantly - don't you need to figure out why it happened?? As well as correcting any inserts with the bogus id? Yes, I would like to know -- I'm open for suggestions. Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Last Record INSERT
Gang: Let me add, currently I am inserting an email address into a database. To find which record was created, I ask for the record number (ID) back. I am asking simply because mysql_insert_id() is deprecated. Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Last Record INSERT
On Wednesday, 26 June 2013 at 18:39, Tedd Sperling wrote: Let me add, currently I am inserting an email address into a database. To find which record was created, I ask for the record number (ID) back. I am asking simply because mysql_insert_id() is deprecated. How are you doing the insert? If you're inserting with mysql_query() then that's just as deprecated as mysql_insert_id(). -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] Last Record INSERT
On Jun 26, 2013, at 1:56 PM, Stuart Dallas stu...@3ft9.com wrote: On Wednesday, 26 June 2013 at 18:39, Tedd Sperling wrote: Let me add, currently I am inserting an email address into a database. To find which record was created, I ask for the record number (ID) back. I am asking simply because mysql_insert_id() is deprecated. Now you tell me. :-) I learn something new every day of my life... and I'm getting damned tried of it. Back to the books. Thanks. Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Last Record INSERT
On Wednesday, 26 June 2013 at 19:01, Tedd Sperling wrote: On Jun 26, 2013, at 1:56 PM, Stuart Dallas stu...@3ft9.com (mailto:stu...@3ft9.com) wrote: On Wednesday, 26 June 2013 at 18:39, Tedd Sperling wrote: Let me add, currently I am inserting an email address into a database. To find which record was created, I ask for the record number (ID) back. I am asking simply because mysql_insert_id() is deprecated. Now you tell me. :-) The whole mysql module has been deprecated. The recommended module is now either mysqli or PDO depending on your requirements. Moving to mysqli from mysql will probably be the less painful route. -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] Last Record INSERT
AFAIK mysql_[...] is deprecated in favor of mysqli_[...] correspondent functions, there's nothing to do specifically with mysql[i]_insert_id. On Wed, Jun 26, 2013 at 3:01 PM, Tedd Sperling tedd.sperl...@gmail.comwrote: On Jun 26, 2013, at 1:56 PM, Stuart Dallas stu...@3ft9.com wrote: On Wednesday, 26 June 2013 at 18:39, Tedd Sperling wrote: Let me add, currently I am inserting an email address into a database. To find which record was created, I ask for the record number (ID) back. I am asking simply because mysql_insert_id() is deprecated. Now you tell me. :-) I learn something new every day of my life... and I'm getting damned tried of it. Back to the books. Thanks. Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Last Record INSERT
Learning something new everyday is one of the joys of this profession. If you learn two new things, consider yourself lucky :) On Wed, Jun 26, 2013 at 11:03 AM, Samuel Lopes Grigolato samuel.grigol...@gmail.com wrote: AFAIK mysql_[...] is deprecated in favor of mysqli_[...] correspondent functions, there's nothing to do specifically with mysql[i]_insert_id. On Wed, Jun 26, 2013 at 3:01 PM, Tedd Sperling tedd.sperl...@gmail.com wrote: On Jun 26, 2013, at 1:56 PM, Stuart Dallas stu...@3ft9.com wrote: On Wednesday, 26 June 2013 at 18:39, Tedd Sperling wrote: Let me add, currently I am inserting an email address into a database. To find which record was created, I ask for the record number (ID) back. I am asking simply because mysql_insert_id() is deprecated. Now you tell me. :-) I learn something new every day of my life... and I'm getting damned tried of it. Back to the books. Thanks. Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- From the desk of Dan Munro