Re: [PHP] Re: filter_input and $_POST deep array
On 09/23/2011 03:17 PM, jean-baptiste verrey wrote: seems that the only solution is to still use $_POST and use filter_var instead, it could have been better! You can foreach the $_Post['login'] array and use filter_input on each iteration to do the filtering. Or maybe the filter_input_array is a better place to look at. The manual is your friend. http://php.net/manual/en/function.filter-input.php Besides that. Calling filter_var two times won't kill you! On 23 September 2011 14:11, jean-baptiste verrey jeanbaptiste.ver...@gmail.com wrote: What do you mean? I don't see how I could use foreach there On 23 September 2011 13:31, Al n...@ridersite.org wrote: On 9/23/2011 5:51 AM, jean-baptiste verrey wrote: Hi, I have using a form that gives me something like $_POST=array( 'login'=array( 'email'='he...@myphp.net', 'password'='123456' ) ) is there a way to use filter_input function to filter the values? I tried filter_input(INPUT_POST,'**login[email]') but it does not work! Regards, Jean-Baptiste Verrey foreach() in the manual -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: filter_input and $_POST deep array
On 09/23/2011 06:16 PM, jean-baptiste verrey wrote: foreach cannot work in this situation has filter_input does not work recursively and work only on the first level of $_POST (or $_GET) so the best solution seems to be to use filter_var($_POST['var']['var2']); I was sure filter_input would work on nested levels. But it doesn't as you point out. You could do something like this if you want to filter the same types array_walk_recursive($_POST, function($value) { $value = filter_var($value, FILTER_SANITIZE_STRING); }); Thanks anyway On 23 September 2011 17:13, Thijs Lensselink d...@lenss.nl mailto:d...@lenss.nl wrote: On 09/23/2011 03:17 PM, jean-baptiste verrey wrote: seems that the only solution is to still use $_POST and use filter_var instead, it could have been better! You can foreach the $_Post['login'] array and use filter_input on each iteration to do the filtering. Or maybe the filter_input_array is a better place to look at. The manual is your friend. http://php.net/manual/en/function.filter-input.php Besides that. Calling filter_var two times won't kill you! On 23 September 2011 14:11, jean-baptiste verrey jeanbaptiste.ver...@gmail.com mailto:jeanbaptiste.ver...@gmail.com wrote: What do you mean? I don't see how I could use foreach there On 23 September 2011 13:31, Al n...@ridersite.org mailto:n...@ridersite.org wrote: On 9/23/2011 5:51 AM, jean-baptiste verrey wrote: Hi, I have using a form that gives me something like $_POST=array( 'login'=array( 'email'='he...@myphp.net mailto:he...@myphp.net', 'password'='123456' ) ) is there a way to use filter_input function to filter the values? I tried filter_input(INPUT_POST,'**login[email]') but it does not work! Regards, Jean-Baptiste Verrey foreach() in the manual -- 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] Help needed with mysql import
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 03/02/2011 07:56 AM, Ashim Kapoor wrote: Dear all, I am trying to make a website with php and I found the following code in a book and I am trying to import it. The following are the beginning of the file i am trying to import with the command mysql -u root -pmypassword certainty dump I get the following error : ERROR 1067 (42000) at line 9: Invalid default value for 'id' but when I see line 9 i see the value '0' for id which seems ok to me, I also tried removing the quotes but same error. Can someone guide me ? Thank you, Ashim # MySQL dump 7.1 # # Host: [host deleted] Database: certainty # # Server version 3.22.32 # # Table structure for table 'high_scores' # CREATE TABLE high_scores ( id int(11) DEFAULT '0' NOT NULL auto_increment, name varchar(30), answer_count int(11), credit double(16,4), PRIMARY KEY (id) ); It's not really a PHP question. But here goes. Your first field id is an auto_increment field this means the counter goes up by every insert. Normally this will start at 1 not 0. So either change the 0 to a higher number or remove the auto_increment part before you import change the 0 after and alter the table to put back auto_increment -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBAgAGBQJNbfOvAAoJEMffsHAOnubXC7UP/1k5qA4TDxDnUKrYZLV/rl9s bLRPTQ21riFMIzt0ne14No4+MTwjNtfVAdSnjpCWEZP+Y2MEixaiz8gIcOt9GIOD f9QPJZFEIcVADs3lqeS88eqdgRBNiYy3x2PHyslR3jtuaeFrRvxOLBTgBISq6Ih4 Dd5nRCbo6WObQ5e26HhbDeMJDAnOw4iQMjpoxc6UD9syxkJrORYw6XFvEmJA/QNF RDTNIO7P62ROamGor8urmPdfIemFLyqjD5YAQ64O6aWVHp0ehjO4l1xPWCeI84sV 2g8C3yqi06UjYOE8NHrf64VYcQtvLFkJbzGT6mmPwEP0gBdqX6o2YDwnudv7+APN F5zoVBv/7wygFaP+P0zgJ+EWVML35VfJFuq5VCH3CUk1hROS4X/JtsNXdVkAbaFA BpEhQ4jN0x/34HrI1cWjEUwaUuU6m9XoMIuO+1tQRLFatEW9I5z1c3hrJsPUNImX qSxEGLAZyA7tex++4YFn8DZXWz4mdllI7yejRe0nl1vl4Nn1+t2se/vF0TfZAGdB HgDeUWTdY/N2KeT4z9gPjGEDlRp8Wqo13Sv1yVhzWDdAJQdWaH8+Kk0GCI0jBrgT Pthmjr0e4bKCW19SJtL7/mTRU12qX/kbjMG5JqIh1ixn72qgqcvkTjgvEeQ1Y0DM xBBFUUedwoKevRJI05/2 =mdri -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php-general Digest 14 Feb 2011 03:32:02 -0000 Issue 7180
On 02/14/2011 05:53 AM, Florin Jurcovici wrote: Hi. Me stupid, my bad. Turns out the bug isn't in my code, but in the debugger. I'm working with the trial version of Zend Studio. When inside the call to the static method, everything is undefined. If I look at variables using the Expressions view, I can see their values, and they _are_ defined. Maybe the break at first line switch is on in the debug config. If you step through you should see all variables. Two things i can think of. 1. Your breakpoints are set before the var us initialised 2. something wrong with your IDE/debugger setup Nope. Bug in xdebug for Ubuntu documented here: https://bugs.launchpad.net/ubuntu/+source/xdebug/+bug/545502 The bug comments also contain a link to a debian package which, when installed, elliminates the bug. Did so, now I have a very nicely working PHP development environment, which stops at breakpoints (missing breakpoints was another issue, but that one came from configuration) and shows the values of variables during debugging. Only, not showing values of variables is something you definitely don't expect from a debugger, so initially I didn't even think of the possibility of a debugger bug. I had no idea you were using Xdebug. When you said Zend Studio i assumed you were using the standard Zend debugger. My bad. Been trying to get Xdebug working in combination with Zend Studio 8. The two seem to talk to each other. But Zend Studio doesn't display any data, no breakpoints, etc i compiled from source since i am using Zend Server. No luck. So back to the Zend Debugger for now. br, flj -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP arguments getting lost in call!?
On 02/13/2011 10:00 AM, Florin Jurcovici wrote: Me stupid, my bad. Turns out the bug isn't in my code, but in the debugger. I'm working with the trial version of Zend Studio. When inside the call to the static method, everything is undefined. If I look at variables using the Expressions view, I can see their values, and they _are_ defined. Maybe the break at first line switch is on in the debug config. If you step through you should see all variables. Two things i can think of. 1. Your breakpoints are set before the var us initialised 2. something wrong with your IDE/debugger setup Still, maybe this thread was not completely useless - others may have the same problem when using the same development setup. I recall downloading the PDT from somewhere some time ago, and there variables in the Variables view were definitely updated upon each step through the code. Somewhat off topic: wow, that was a fast response! I challenge any commercial support service to have such response times - on Sunday! On Sun, Feb 13, 2011 at 10:53 AM, Richard Quadling rquadl...@gmail.com wrote: On 13 February 2011 08:36, Florin Jurcovici florin.jurcov...@gmail.com wrote: Hi. The entry point in my php app is a file containing something like: require_once(Disptacher.php); ... Dispatcher:dispatch($arguments); ... The file Dispatcher.php is located in the same folder as the file containing the above code, and contains the following: class Dispatcher { public static function dispatch($arguments) { ... } } For some reason, although before the call to Dispatcher::dispatch() the variable $arguments is set, and contains what it is supposed to contain, inside Dispatcher:dispatch() $arguments is always empty. How come? What am I doing wrong? How can I call a static method and pass it arguments? br, flj -- In politics, stupidity is not a handicap. (Napoleon said it, Bush junior proves it) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php What data IS getting through? print_r(func_get_args()); will show this. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simplifying MySql queries
On 02/12/2011 09:40 PM, Andre Polykanine wrote: Hi all, I'm using in my PHP script the following four MySql queries: $q1=mysql_query(SELECT *FROM`CandidateQuestions`WHERE `Category`='1' ORDER BY RAND() LIMIT 1); $q2=mysql_query(SELECT *FROM`CandidateQuestions`WHERE `Category`='2' ORDER BY RAND() LIMIT 1); $q3=mysql_query(SELECT *FROM`CandidateQuestions`WHERE `Category`='3' ORDER BY RAND() LIMIT 1); $q4=mysql_query(SELECT *FROM`CandidateQuestions`WHERE `Category`='4' ORDER BY RAND() LIMIT 1); and here goes the question: is there a way to make these four in one so strictly one random question is selected from all of the four categories? Thanks! You really should ask this on a SQL mailing list. it doesn't have much to do with PHP. That said. You could use the IN() statement like this: SELECT * FROM `CandidateQuestions` WHERE `Category` IN (1, 2, 3) ORDER BY RAND() LIMIT 1; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] override built-in mail()
On 02/04/2011 04:59 PM, Steve Staples wrote: On Fri, 2011-02-04 at 07:51 -0800, Jim Lucas wrote: On 2/4/2011 5:37 AM, Steve Staples wrote: Hello Guys/Gals, it's friday (at least where I am it is) and I have an issue with a script that I just started using again. The problem is, is that it uses the built in PHP mail() function, and on my testing server, mail() doesn't work. The other issue, is that I use SMTP Auth to connect to my mail server, so that when mail sends out, it comes from my mail server so that there is less of a chance for being marked as SPAM. So, what I am looking to do, is use either the trust old Pear::Mail or PHPMailer scripts (I am sure there are other ones out there, but those are the 2 I am most familiar with). So now to my actual question. How can I override the built-in PHP mail() function, to let either of those 2 (or something else someone may suggest) to act in the same manner as the mail() function? Is this easy? I've googled, but haven't seen any reference to doing what I am looking to do (maybe I just can't google) Steve You cannot override a function. You will have to write a new function, my_mail or some such. Have it take the same arguments as the built in mail function, but internally it uses phpmailer or the likes. Then, do a search and replace for mail( with my_mail( One other possible option, which I had not contemplated until now, would be to actually specify a replacement sendmail executable when setting up the sendmail option in the php.ini. You could specify a php script that can run as though it was sendmail, accept the same arguments, etc... but do all the phpmailer stuff inside. Jim Lucas after posting this, and doing some more googleing, I found this: http://ca.php.net/manual/en/function.override-function.php it says you can override built-in php functions... I haven't tested to see if i can do it, but it seems possible... has anyone used this before? and will it do what I need? (this has been put on the back burner for today, so tonight I will look more deeper into this unless someone else has any luck in the mean time) TIA! Steve In PHP versions 5.3 you need something like runkit or apd. In PHP 5.3 and up you could use monkey patching ?php namespace somenamespace; function mail() { // do something! } You don't actually overwrite the core function but it's close. ?php use somenamespace; mail() // will call the namespaced function \mail() // will call the core function -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] override built-in mail()
On 02/04/2011 08:38 PM, Steve Staples wrote: On Fri, 2011-02-04 at 20:25 +0100, Thijs Lensselink wrote: On 02/04/2011 04:59 PM, Steve Staples wrote: On Fri, 2011-02-04 at 07:51 -0800, Jim Lucas wrote: On 2/4/2011 5:37 AM, Steve Staples wrote: Hello Guys/Gals, it's friday (at least where I am it is) and I have an issue with a script that I just started using again. The problem is, is that it uses the built in PHP mail() function, and on my testing server, mail() doesn't work. The other issue, is that I use SMTP Auth to connect to my mail server, so that when mail sends out, it comes from my mail server so that there is less of a chance for being marked as SPAM. So, what I am looking to do, is use either the trust old Pear::Mail or PHPMailer scripts (I am sure there are other ones out there, but those are the 2 I am most familiar with). So now to my actual question. How can I override the built-in PHP mail() function, to let either of those 2 (or something else someone may suggest) to act in the same manner as the mail() function? Is this easy? I've googled, but haven't seen any reference to doing what I am looking to do (maybe I just can't google) Steve You cannot override a function. You will have to write a new function, my_mail or some such. Have it take the same arguments as the built in mail function, but internally it uses phpmailer or the likes. Then, do a search and replace for mail( with my_mail( One other possible option, which I had not contemplated until now, would be to actually specify a replacement sendmail executable when setting up the sendmail option in the php.ini. You could specify a php script that can run as though it was sendmail, accept the same arguments, etc... but do all the phpmailer stuff inside. Jim Lucas after posting this, and doing some more googleing, I found this: http://ca.php.net/manual/en/function.override-function.php it says you can override built-in php functions... I haven't tested to see if i can do it, but it seems possible... has anyone used this before? and will it do what I need? (this has been put on the back burner for today, so tonight I will look more deeper into this unless someone else has any luck in the mean time) TIA! Steve In PHP versions 5.3 you need something like runkit or apd. In PHP 5.3 and up you could use monkey patching ?php namespace somenamespace; function mail() { // do something! } You don't actually overwrite the core function but it's close. ?php use somenamespace; mail() // will call the namespaced function \mail() // will call the core function The reason i was hoping to override the function, was because then if the script has updates, then i would need to change all references of mail() to my_mail() or if i am not using 5.3 (and what is runkit or apd??) APD is the Advanced PHP Debugger. That reffers to the first link you added. And runkit is a PHP extension which allows you to override functions, classes, etc. http://php.net/manual/en/book.runkit.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] override built-in mail()
On 02/04/2011 08:44 PM, Thijs Lensselink wrote: On 02/04/2011 08:38 PM, Steve Staples wrote: On Fri, 2011-02-04 at 20:25 +0100, Thijs Lensselink wrote: On 02/04/2011 04:59 PM, Steve Staples wrote: On Fri, 2011-02-04 at 07:51 -0800, Jim Lucas wrote: On 2/4/2011 5:37 AM, Steve Staples wrote: Hello Guys/Gals, it's friday (at least where I am it is) and I have an issue with a script that I just started using again. The problem is, is that it uses the built in PHP mail() function, and on my testing server, mail() doesn't work. The other issue, is that I use SMTP Auth to connect to my mail server, so that when mail sends out, it comes from my mail server so that there is less of a chance for being marked as SPAM. So, what I am looking to do, is use either the trust old Pear::Mail or PHPMailer scripts (I am sure there are other ones out there, but those are the 2 I am most familiar with). So now to my actual question. How can I override the built-in PHP mail() function, to let either of those 2 (or something else someone may suggest) to act in the same manner as the mail() function? Is this easy? I've googled, but haven't seen any reference to doing what I am looking to do (maybe I just can't google) Steve You cannot override a function. You will have to write a new function, my_mail or some such. Have it take the same arguments as the built in mail function, but internally it uses phpmailer or the likes. Then, do a search and replace for mail( with my_mail( One other possible option, which I had not contemplated until now, would be to actually specify a replacement sendmail executable when setting up the sendmail option in the php.ini. You could specify a php script that can run as though it was sendmail, accept the same arguments, etc... but do all the phpmailer stuff inside. Jim Lucas after posting this, and doing some more googleing, I found this: http://ca.php.net/manual/en/function.override-function.php it says you can override built-in php functions... I haven't tested to see if i can do it, but it seems possible... has anyone used this before? and will it do what I need? (this has been put on the back burner for today, so tonight I will look more deeper into this unless someone else has any luck in the mean time) TIA! Steve In PHP versions 5.3 you need something like runkit or apd. In PHP 5.3 and up you could use monkey patching ?php namespace somenamespace; function mail() { // do something! } You don't actually overwrite the core function but it's close. ?php use somenamespace; mail() // will call the namespaced function \mail() // will call the core function The reason i was hoping to override the function, was because then if the script has updates, then i would need to change all references of mail() to my_mail() or if i am not using 5.3 (and what is runkit or apd??) APD is the Advanced PHP Debugger. That reffers to the first link you refers :) added. And runkit is a PHP extension which allows you to override functions, classes, etc. http://php.net/manual/en/book.runkit.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] override built-in mail()
On 02/04/2011 09:49 PM, David Harkness wrote: On Fri, Feb 4, 2011 at 12:42 PM, Hansen, Mike mike.han...@atmel.com wrote: I would opt for using my_mail and not overriding a built-in function. It seems to me that it would just cause confusion for the next developer who takes care of your code. You know, that psychopathic programmer that knows your address. =) Yes, better to create your own function (or class) to abstract the mail() API of your choosing is the better route. You'll have to retrofit the script to use it, but you can then swap in different mail systems later without changing the client. Even when you don't anticipate needing to switch to a different provider, adding an abstraction layer from the start is often cheap enough to warrant the risk of never needing to change the implementation underneath. David I should have added. Running APD or runkit in production is probably not a good idea. And renaming a core function just the same. Monkey patching is a nice solution. But can cause confusion as well. Like Mike and David say. Better role your own function / class for this. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PEAR PHP
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/30/2011 05:43 AM, Ethan Rosenberg wrote: Dear list - I enter the command pear list, and get errors. See below -- ethan@rosenberg:/usr/lib/php5$ ls -l total 12 drwxr-xr-x 2 root root 4096 Jan 6 00:53 20090626+lfs drwxr-xr-x 2 root root 4096 Jul 18 2010 libexec -rwxr-xr-x 1 root root 596 Jan 5 08:09 maxlifetime ethan@rosenberg:/usr/lib/php5$ pear list PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/msql.so' - /usr/lib/php5/20090626+lfs/msql.so: cannot open shared object file: No such file or directory in Unknown on line 0 font color=#ff Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/msql.so' - /usr/lib/php5/20090626+lfs/msql.so: cannot open shared object file: No such file or directory in Unknown on line 0 /fontInstalled packages, channel pear.php.net: = Package Version State Archive_Tar 1.3.7 stable Console_Getopt 1.2.3 stable PEAR 1.9.1 stable Structures_Graph 1.0.3 stable Validate_US 0.5.4 beta XML_Util 1.2.1 stable ethan@rosenberg:/usr/lib/php5$ cd 20090626+lfs ethan@rosenberg:/usr/lib/php5/20090626+lfs$ ls -l total 560 -rw-r--r-- 1 root root 95596 Jan 5 08:09 gd.so -rw-r--r-- 1 root root 38272 Jan 5 08:09 mcrypt.so -rw-r--r-- 1 root root 109220 Jan 5 08:09 mysqli.so -rw-r--r-- 1 root root 42352 Jan 5 08:09 mysql.so -rw-r--r-- 1 root root 26116 Jan 5 08:09 pdo_mysql.so -rw-r--r-- 1 root root 87588 Jan 5 08:09 pdo.so -rw-r--r-- 1 root root 141336 Aug 19 04:04 suhosin.so ethan@rosenberg:/usr/lib/php5/20090626+lfs$ Help and advice, please. Thanks. Ethan MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)] msql.so is missing. So either install it. Or comment it out in php.ini -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBAgAGBQJNRSFUAAoJEMffsHAOnubXNQoP/ikY2NC0XaQUJ+58OHMKpTQA SujpSidNfvi+tnBKI4GylQrmGVglf1DnFAxNVo1KT8hXtdXBGCr146sf6vmqri6C gIxna2KQI5NLLAxAoYnZdGkf/e0sKQSv/W1PMH41CbcjIiuIFL+TY5ZXHcEsLWfV R0HorzKxwfPrM7rr5JIE/iIu3dOsjDGzefHT3d4hVYzausDa2YKqB6pBiH2VW4P+ SgJKsMaEVmkK38zv38BboCiJUVaIT5/istPMojQlVdoohp0j+XsIMNysAE5wzI6S iE5Ag8awxy7kR9dfjxt3OjBW29ooSKMCUkSyRz/bW1rVrOqpqRnApXM6AOibOWE1 woKFMUF1CuZ5NVm54IqRp8Fh64mr0gWFtGCgG38B2zsOqycwHDx9bGsITYYIxpeE p3QfhOKmor9fZ8fOzcDeivitJUk26fCvJd1AYewQ9rjmHMKSmx6LpLxsgDoVO8yk yGVTQF3lLkLAAAa0Hx5OeYaANkTo3+r1zEw7GaqLCoto3UxuZp7Zu/pZC8B/e8PA M2OPRQfKQy0eA9BDFlLgOYTIppPnN7RZWFAu0+5gwI6t8NpnMlbNOWaPsRkg9VX/ f4MZ2bzHBQlW9gesGAjHVtGaCuTtmQn3f10MxfkXE+Zz5/Rd6UXo78cj5muURU4x TLXCLnNK6ZEiavTmmqoi =UTPb -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Different sessions, same client
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/23/2011 07:33 AM, Paul M Foster wrote: Storing any sort of login/auth data in cookies has regularly been panned on this list. The preference seems to be to store whatever login/auth information *must* be stored in the $_SESSION variable. Well and good. My problem, however, is that I have multiple applications in different tabs running on the same server, which may all use the same sub-variables, like username. As a result, they run into each other. One application will think I'm logged in when I'm not logged in to that application, but to another in the same browser on the same box. So my question is how to prevent this using the standard PHP functions relating to sessions. I'd like different applications in different tabs on the same box/browser to have different sessions, so they don't share data. Thoughts? Paul Using session_name will allow you to run two different sessions in the same browser. session_name('app1'); session_start(); -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBAgAGBQJNO+TpAAoJEMffsHAOnubXzHYQAI86mjCR49uWTPYweFim9e+K EtU4KnFfXkQj+Qp0YYjjuiAW0muRywbjKkwuAmw7fO/v9DrbGILAvnneNX7OR9cM TBh66J6anuLB3UmItrmFqP2VKgWaLG7KHf0wExfv3duzJkRqp5Y8NQG1Ep8aXA0U 8N2VHQ1ki9ukHeIWcPI4l5558j0NE/5BsiWgJIgTC/CovDjdNYln9vszkmFw0g2G vJore2V3OIBcmLhqpcITSNK4FcaNWIKnrRWnlCgoAzA1WUCQXnmv0nJMZ0P9xtzk iYt2lkBvlGEJ8lnZoAo83XRsQ1oI6vLFwf5xDkI4OGnAsOIzmX3RzStxXyz9o5th VyIHtj8R40Rk6eI6L5xE4w1l58JTFMPdgaFk5Ku/v8i8UGDWjWHC0Qhob14w+H32 RQUtx9dBsYKYT9ZHIkxAQYDc9nTdgajRzo0ONqmzPTS9Qb7NTcjiC9pb1bHBjubA M4zJnyO5N7IUy0FmMyS7PG8saCgJDSYj+stvoCC9Kd0eDRBKs+M5cRLpnXem/Yf8 KG+clIe5+7X9l1TC7uT84HxZYSZCcuwuvRyBUIZknagyREQvLhaFX1OPZ/vk3n6S j7k77oFpcCRjkPVKZeUqFAENEY1J7p6DBEkTz9gRkA+islnSIt8rjz+0wYYg0goy b3C3ThlftPWwcOBuRQOP =ZBm8 -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to get cpu consumption of a php script
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/17/2011 11:23 AM, Tanoor Dieng wrote: Hi everybody, I'm a php developper for a high traffic website. Our web servers run with lightty? We have some issues with the cpu consumption of our servers. The problem is that, we don't know exactly which script consumes so much cpu. So, we cant to figure out how much cpu does a php script take. We have tried 3 methods: 1) Microtime: microtime at the beginning and at the end and make the diff. The problem with that is that it takes the execution time of the script, but in our script we make: - connection to database - connection to memcache - connection to session server All of this is not taken into account, so microtime is not that accurate 2) Shell command: we get the pid of the process executing the script and make a 'top' on this pid . The problem is that the php-cgi manages many threads so it's not accurate too. Is there other methods for dealing with this problem. Thanks, best regards, Tanoor. Use something like xdebug cachegrind to profile the application. This makes it easy to track down memory and CPU usage. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBAgAGBQJNNB8vAAoJEMffsHAOnubXpRkP/2u0EHXnQR+kkp6pQqM8Gry1 1iFIfqck4Bco3rOYcsX9IK22c/YJZ3RGCMnyZyp+XUAmV615keAtqW/sRgWy/cO9 oaiDHdctdnLeFxmoyRVzR7/FkaeM/bJ7Tj29wnkii8gMbNi8W3zm/RQqBSxoAGig tJOx+SBi+jqgxfAn18dutRrqDm1lMRNi3wZI8k6Dg2U8i+s/sAjFMVPbNAvLfDzs uOisnYiJSCdA33zN3IkXD+W9vqVGdHjqF1UABG8srPY/DBUPDjtSrzuHICdQX4SJ luzgDvnoIVoOE0ntiAPIKba89iXDtIIIlvIX2BkQeGfNIoZWP0/M75siX4drLLI/ 6/omgCBOMXkjZ0GMJzdeLPsVjMqagNYKUZfor3KPj0PbpX4RoftWJgvLShHDv74v nusu8vClDwQNc9eBBZ5Kf7MkXzXVXnFUUO21PSb3WQtX/7eziGrhz8vxYEbR7/zA XidHE1vfyTr+DNdbkjkYPHyj/s+ZIloNmf/9rjdC8xpEYEevEErUxY+15MXvSZEq 4JmxVUOe3P9ICZSGMf1+BieH9oZRmteFLtMujwHdXVzWVDrCvurM6dwJVdSNZMhT Ct0PeOwJxJgAtvKL+bOpzd+AMHVEpoWETIYrpXepmCHxbCVCa0fDmxgZ73+32XI8 25mgBHxvMdfINaOjWZJf =mz+P -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parse_ini_file() seems to be broken in PHP 5.2.4-2ubuntu5.12
On Wed, 10 Nov 2010 18:08:01 -0800, Daevid Vincent dae...@daevid.com wrote: http://php.net/manual/en/function.parse-ini-file.php Why doesn't PHP parse the 'null', 'true', 'false', etc into their proper equivalents? What's worse is that it does this mangling of my RAW values to be strings and sets them to 1 !!! WTF good does that do me?! Here is my test.ini file: --- --- [examples] ; this is a section ; this is a comment line log_level = E_ALL ~E_NOTICE 1 = intkey ; this is a int key nullvalue = null; this is NULL truebool = true ; this is boolean (TRUE) falsebool = false ; this is boolean (FALSE) intvalue = -1 ; this is a integer (-1) floatvalue = +1.4E-3; this is a float (0.0014) stringvalue = Hello World ; this is a unquoted string quoted = Hello World ; this is a quoted string apostrophed = 'Hello World' ; this is a apostrophed string quoted escaped = it work's \fine\! ; this is a quoted string with escaped quotes apostrophed escaped = 'it work\'s fine!' ; this is a apostrophed string with escaped apostrophes --- --- Here is my test.php page: --- --- ?php var_dump(parse_ini_file('./test.ini', true)); ? --- --- Here is the output: --- --- array 'examples' = array 'log_level' = string '6135' (length=4) 1 = string 'intkey' (length=6) 'nullvalue' = string '' (length=0) 'truebool' = string '1' (length=1) 'falsebool' = string '' (length=0) 'intvalue' = string '-1' (length=2) 'floatvalue' = string '+1.4E-3' (length=7) 'stringvalue' = string 'Hello World' (length=11) 'quoted' = string 'Hello World' (length=11) 'apostrophed' = string ''Hello World'' (length=13) 'quoted escaped' = string 'it work's \fine\!' (length=17) 'apostrophed escaped' = string ''it work\'sfine' (length=15) --- --- Use the third parameter so the orignal values wil not get converted (still strings though) Besides that are you sure there are no whitespaces behind the ini values? var_dump( parse_ini_file('./foo.ini', true, INI_SCANNER_RAW) ); array(1) { [examples]= array(11) { [1]= string(40) intkey [nullvalue]= string(32) null [truebool]= string(33) TRUE [falsebool]= string(32) false [intvalue]= string(33) -1 [floatvalue]= string(31) +1.4E-3 [stringvalue]= string(30) Hello World [quoted]= string(35) Hello World [apostrophed]= string(30) 'Hello World' [quoted escaped]= string(27) it work's \fine\! [apostrophed escaped]= string(22) 'it work\'s fine!' } } develo...@mypse:~$ php -v PHP 5.2.4-2ubuntu5.12 with Suhosin-Patch 0.9.6.2 (cli) (built: Sep 20 2010 13:18:10) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include() and duplicate function definition
On Wed, 3 Nov 2010 17:59:06 +0800, David Nelson comme...@traduction.biz wrote: Hi, :-) I'm making a child theme for WordPress. I need to rewrite one function defined in ../sometheme/functions/actions.php and put that rewritten function in wp-content/themes/sometheme-child/functions/actions.php. But I want to preserve ../sometheme/functions/actions.php unchanged in any way. (Future theme updates would just overwrite any changes I made.) So, in my new actions.php, I put an include followed by the replacement function definition, named identically to the one I want to replace: ?php include '../sometheme/functions/actions.php'; function foo($arg_1, $arg_2, /* ..., */ $arg_n) { echo All my new code.\n; } ? Because this duplicate foo() function definition comes after the foo() defined in the included file, does it replace the included foo()? Or how can I achieve what I want? Big thanks in advance for any suggestions. :-) David As far as I know it is not possible to overwrite functions in PHP (unless you use runkit, apd). Inside classes this is possible. But that's not the case here. Why do the functions have to be equally named? Try to create a new function and call the original function from there if needed... foo2() { foo() } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include() and duplicate function definition
On Wed, 3 Nov 2010 19:53:52 +0800, David Nelson comme...@traduction.biz wrote: Hi, :-) On Wed, Nov 3, 2010 at 19:29, Peter Lind peter.e.l...@gmail.com wrote: That's not going to happen. My point was you could check in the original file if the function is defined and if not then define it. OK, thanks, Thijs and Peter, it looks like I'm trying to do something that is not currently possible in PHP. Time for some lateral thinking. :-) David Nelson David, I re-read your original post. And noticed you include the function inside your child action.php Is there a special reason for that? You want to overwrite the original function in a child theme. probably to get different functionality. So why do you need the original function? Just create your action.php and define the same function. // include '../sometheme/functions/actions.php'; function foo($arg_1, $arg_2, /* ..., */ $arg_n) { echo All my new code.\n; } It's code duplication. But i don't think themes should have dependencies to one an other. You could also create a actions.php file outside the themes folder. wp-content/shared-functions/action.php And then in your themes do: theme 1 include shared-function/action.php; foo(); theme 2 include shared-function/action.php; foo(); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reminder On Mailing List Rules
On Thu, 21 Oct 2010 16:30:03 +0100, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Thu, 2010-10-21 at 10:25 -0400, Daniel Brown wrote: Hey, Folks; Just a gentle reminder after watching things get worse by the day: it is one of the rules of this and all official php.net mailing lists that you must not top-post. For anyone wondering just one of the reasons why we have this rule in effect, tab through this thread in the archives: http://www.mail-archive.com/php-general@lists.php.net/msg262390.html See how disastrous and headache-inducing it looks? You wouldn't put code together looking like spaghetti thrown at a wall and smashed into the carpet, especially knowing your clients and peers would see it, would you? It's a very similar situation here: your every word is being recorded in literally hundreds of places simultaneously, preserved as educational and professional reference material for current and future developers --- and not just in the PHP programming language, but in computer programming in general, as theories lend themselves to apply to other situations as well. Many of you take the time out of your busy schedules to voluntarily impart knowledge on people of varying degrees of skills and abilities, which is beyond commendable; so why not take just a couple of extra seconds to show pride in your participation, lead by example, and continue to set the bar high, rather than simply settling for the quickest Twitter-like R/T to a post? ;-P The ultimate goal here isn't to start a flame war (or even any further discussion on the subject for that matter), but to point out that this is a RULE of the official community here, not a PREFERENCE. P.S. - Those of you who have been around for years will likely recall with some fondness the level of respect, participation, and quality of discussions this list once had; the degree of mutual respect and camaraderie was palpable. If you're wondering if those days have really diminished into little more than granular memory, it's not just you --- check the following graph for some rather disturbing evidence: http://dir.gmane.org/gmane.comp.php.general -- /Daniel P. Brown Network Infrastructure Manager Documentation, Webmaster Teams http://www.php.net/ I always bottom post when I'm replying from my computer, but when on the move or at work, I'm only left with my Android, and the default email client doesn't allow reply positioning of any sort, so it's always top-posting :( Does anyone know of any decent email clients for Android that allow bottom posting that you maybe use or have had experience with? I use the K-9 mail client on Android. When replying you can edit the quoted message and do bottom posting. Not so convenient as using Thunderbird or Evolution. But it works! Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] floored by floor()
On 10/14/2010 07:48 AM, Mattias Thorslund wrote: Hi List, I'm having a problem with the behavior of the floor() function: echo floor(327.03 * 100).\n; //prints 32702 and not 32703!! Sanity check: var_dump(327.03 * 100); //prints float(32703) as expected Any ideas why this happens, and how to work around it? Thanks, Mattias Read the floating point precision part http://nl2.php.net/float Use round() before you use floor() to get the expected result. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Zend studio location Cross-Domain Scripting Vulnerability
On 10/13/2010 12:19 AM, Daevid Vincent wrote: http://80vul.com/Zend%20studio/Zend%20studio%20location%20Cross.htm Interesting. A co-worker and I were JUST noticing how our PHPDoc comments were being parsed pretty much verbatim includingb tags and links and stuff and thought, wow, that's stupid, that's just a XSS or injection waiting to happen. LOL. Guess someone's ears were burning. ;-) Why didn't you inform Zend before you went full disclosure? It's a nasty bug though!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Could this be a bug?
On 09/14/2010 11:31 PM, Camilo Sperberg wrote: On Tue, Sep 14, 2010 at 02:46, Thijs Lensselinkd...@lenss.nl wrote: On 09/14/2010 08:33 AM, Thijs Lensselink wrote: On 09/14/2010 12:16 AM, Camilo Sperberg wrote: I have some really strange behaviour going on here, and I think it could be a (minor) PHP's bug. I am not really sure about what happens internally, but my best guess would be that after a memory exhaustion, when I try to execute a custom error handler with the register_shutdown_function (which is executed even after a fatal error) and try to access the element that provoked the memory exhaustion, no error should raise instead of *Uninitialized string offset: 0. I have prepared a little test case to reproduce the error and (I hope) can explain the error. ?php date_default_timezone_set('America/Santiago'); ini_set('memory_limit','1M'); ini_set('display_errors',1); error_reporting(-1); function my_error_handler($errno = '0', $errstr = '[FATAL] General Error', $errfile = 'N/A', $errline = 'N/A', $errctx = '') { This seems to be your error. You set $errctx to be a string. But later on you use it as an array. Remove the = '' part. And it will function as expected. You're right... However I don't like leaving non-default value in functions so I did something like if(empty($errctx)) $errctx = array() in the first line of the custom error handler which threw out the error message and everything works ok now. I think from 5.2 and up you can use the array keyword to force an array as parameter.. But -and correct me if I'm wrong- isn't isset (or empty) supposed to return a FALSE whenever that variable doesn't exist? With your help, I could reduce the test case into: $asdf = 'hello world'; if (empty($asdf[4]['inventing'])) echo 'nice little world'; if (isset($asdf['inventing'][6])) echo 'little nice world'; // This works ok. This works because the string $asdf is set with a value. So $asdf[4] exists but ['inventing'] doesn't so it will return false $asdf = ''; if (empty($asdf[4]['inventing'])) echo 'nice little world'; if (isset($asdf['inventing'][6])) echo 'little nice world'; // This returns E_NOTICE This doesn't work because the string $asdf is empty. So calling $asdf[4] will trigger a notice since there is no 4th character Shouldn't these 2 examples work exactly the same way? (AKA as Nº 1). If not... why not? Both are string types, onyl difference is that one has no characters in it while the other does, but essentialy they are both the same. Greetings ! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Could this be a bug?
On 09/14/2010 12:16 AM, Camilo Sperberg wrote: I have some really strange behaviour going on here, and I think it could be a (minor) PHP's bug. I am not really sure about what happens internally, but my best guess would be that after a memory exhaustion, when I try to execute a custom error handler with the register_shutdown_function (which is executed even after a fatal error) and try to access the element that provoked the memory exhaustion, no error should raise instead of *Uninitialized string offset: 0. I have prepared a little test case to reproduce the error and (I hope) can explain the error. ?php date_default_timezone_set('America/Santiago'); ini_set('memory_limit','1M'); ini_set('display_errors',1); error_reporting(-1); function my_error_handler($errno = '0', $errstr = '[FATAL] General Error', $errfile = 'N/A', $errline = 'N/A', $errctx = '') { global $clean_exit; if(empty($clean_exit)) { ini_set('memory_limit','16M'); ob_start(); echo 'h1PHP v'.PHP_VERSION.', error Ndeg; '.$errno.'/h1'; ?h4-- BEGIN COPY --/h4p style=font-size:110%;margin:50px 0 20px 25pxemError Ndeg;:/embr /?php echo 'strong'.$errno.'/strongbr /'; ?emError Detail:/embr /?php echo 'strong'.$errstr.'/strongbr /emFile:/embr /strong'.$errfile.'/strongbr /emLine:/embr /strong'.$errline.'/strongbr /emDebug:/embr /'; if (isset($errctx['r']['print'])) echo 'pTHIS LINE GIVES THE ERROR, WHAT SHOULD IT RETURN?/p'; Maybe i'm missing something here (kinda sick at home) but.. What do you expect to happen here? When i do a var_dump() on $errctx i get string(0) That would explain the error you are seeing. ?/ph4-- END COPY --/h4?php $content = ob_get_contents(); ob_end_clean(); die($content); } } set_error_handler('my_error_handler'); register_shutdown_function('my_error_handler'); for ($i = 0; $i 1; $i++) $a[$i] = mt_rand(1,254); $r['print'] = print_r($a,TRUE); echo 'pEverything fine./p'; $clean_exit = TRUE; * Would this be a bug or is this expected behaviour? I have tested this on PHP v5.2.14, I've not tested it yet on 5.3.3, but I guess it would have the same behaviour. Greetings! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Could this be a bug?
On 09/14/2010 08:33 AM, Thijs Lensselink wrote: On 09/14/2010 12:16 AM, Camilo Sperberg wrote: I have some really strange behaviour going on here, and I think it could be a (minor) PHP's bug. I am not really sure about what happens internally, but my best guess would be that after a memory exhaustion, when I try to execute a custom error handler with the register_shutdown_function (which is executed even after a fatal error) and try to access the element that provoked the memory exhaustion, no error should raise instead of *Uninitialized string offset: 0. I have prepared a little test case to reproduce the error and (I hope) can explain the error. ?php date_default_timezone_set('America/Santiago'); ini_set('memory_limit','1M'); ini_set('display_errors',1); error_reporting(-1); function my_error_handler($errno = '0', $errstr = '[FATAL] General Error', $errfile = 'N/A', $errline = 'N/A', $errctx = '') { This seems to be your error. You set $errctx to be a string. But later on you use it as an array. Remove the = '' part. And it will function as expected. global $clean_exit; if(empty($clean_exit)) { ini_set('memory_limit','16M'); ob_start(); echo 'h1PHP v'.PHP_VERSION.', error Ndeg; '.$errno.'/h1'; ?h4-- BEGIN COPY --/h4p style=font-size:110%;margin:50px 0 20px 25pxemError Ndeg;:/embr /?php echo 'strong'.$errno.'/strongbr /'; ?emError Detail:/embr /?php echo 'strong'.$errstr.'/strongbr /emFile:/embr /strong'.$errfile.'/strongbr /emLine:/embr /strong'.$errline.'/strongbr /emDebug:/embr /'; if (isset($errctx['r']['print'])) echo 'pTHIS LINE GIVES THE ERROR, WHAT SHOULD IT RETURN?/p'; Maybe i'm missing something here (kinda sick at home) but.. What do you expect to happen here? When i do a var_dump() on $errctx i get string(0) That would explain the error you are seeing. ?/ph4-- END COPY --/h4?php $content = ob_get_contents(); ob_end_clean(); die($content); } } set_error_handler('my_error_handler'); register_shutdown_function('my_error_handler'); for ($i = 0; $i 1; $i++) $a[$i] = mt_rand(1,254); $r['print'] = print_r($a,TRUE); echo 'pEverything fine./p'; $clean_exit = TRUE; * Would this be a bug or is this expected behaviour? I have tested this on PHP v5.2.14, I've not tested it yet on 5.3.3, but I guess it would have the same behaviour. Greetings! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] State and City Database
On 07/07/2010 10:02 PM, tedd wrote: Hi gang: Does anyone have a source for a US State and City database? Cheers, tedd Hey Tedd, Maybe this helps. I used the data files for some other projects.. http://earth-info.nga.mil/gns/html/ http://geonames.usgs.gov/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is wrong with this code?
Gary . wrote: class Pg_Error { private static $errors = array(INTEGRITY_CONST_UNIQUE = 'uniqueness constraint violated'); Shouldn't this be: array(self::INTEGRITY_CONST_UNIQUE = 'uniqueness constraint violated'); ... public static function getMessage($ec) { $text = ''; if (array_key_exists($ec, Pg_Error::$errors)) { $text = Pg_Error::$errors[$ec]; } return $text; } ... } ? Calling it, the array_key_exists call always returns false: $this-assertEquals('uniqueness constraint violated', Pg_Error::getMessage(Pg_Error::INTEGRITY_CONST_UNIQUE)); and I can't see what I've done wrong :( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is wrong with this code?
Gary . wrote: On 4/28/10, Thijs Lensselink wrote: Gary . wrote: class Pg_Error { private static $errors = array(INTEGRITY_CONST_UNIQUE = 'uniqueness constraint violated'); Shouldn't this be: array(self::INTEGRITY_CONST_UNIQUE = 'uniqueness constraint violated'); Yes, or something very like it. See Message-ID: y2la35643581004280018i22b3de1ag1a836e7229378...@mail.gmail.com That message is about defining the class constant. Which is done. But later on it is called as a normal constant. Not a class constant Besides the fact that it should throw a notice. It also makes sure Pg_Error::$errors looks a bit different then expected array(1) { [INTEGRITY_CONST_UNIQUE]= string(30) uniqueness constraint violated } This makes Pg_Error::getMessage(23505) always return string(0) which equals false -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Call to undefined method on class property!?
Allen McCabe wrote: I have a singleton database object in a global file at the top of my document. In most other locations I am able to access it just fine, however in my footer I want to loop through a properties list for links (I am saving links to a database, each with its own properties). Here is the code snippet that is giving me trouble: footerlinks.inc.php: ?php $result = $db-query('SELECT * FROM `links` WHERE `category` = \'footer_navigation\';'); $total = $db-affected_rows; Here you use affected_rows as a class property to assign a value to a variable. if ($total 0) { $Link = new Link(); $count = $db-affected_rows($result); Here you call affected_rows as a class method. And from looking at your Database class. affected_rows is a property not a method. So that explains the undefined method error. $i = 0; while ($row = $db-fetch_array($result)) { $properties = $Link-setLinkProperties($row); $link[$i] = 'a '; foreach ($properties as $prop) { $link[$i] .= $prop; } $link[$i] .= ''; $row['text']; $link[$i] .= '/a'; $i++; } $j = 0; while ($j $link) { echo $link[$j]; if ($j $count) { echo ' | '; } $j++; } } ? The $Link-$Link-setLinkProperties() method is defined in Link.class.php: ?php class Link { public function setLinkProperties($rows) { if (!empty($row['href'])) { $properties['href'] = 'href=' . $row['href'] . ' '; } if (!empty($row['class'])) { $properties['class'] = 'class=' . $row['class'] . ' '; } if (!empty($row['style'])) { $properties['style'] = 'style=' . $row['style'] . ' '; } if (!empty($row['title'])) { $properties['title'] = 'title=' . $row['title'] . ' '; } if (!empty($row['name'])) { $properties['name'] = 'name=' . $row['name'] . ' '; } if (!empty($row['target'])) { $properties['target'] = 'target=' . $row['target'] . ' '; } if (!empty($row['rel'])) { $properties['rel'] = 'rel=' . $row['rel'] . ' '; } if (!empty($row['onclick'])) { $properties['onclick'] = 'onclick=' . $row['onclick'] . ' '; } if (!empty($row['ondblclick'])) { $properties['ondblclick'] = 'ondblclick=' . $row['ondblclick'] . ' '; } if (!empty($row['onmouseover'])) { $properties['onmouseover'] = 'onmouseover=' . $row['onmouseover'] . ' '; } if (!empty($row['onmouseout'])) { $properties['onmouseout'] = 'onmouseout=' . $row['onmouseout'] . ' '; } return $properties; } // END OF METHOD setLinkProperties } // END OF CLASS ? Also for reference, the method query() in my database class sets a value for $affected_rows: Database.class.php: ?php class Database { private $server = ''; //database server private $user = ''; //database login name private $pass = ''; //database login password private $database = ''; //database name private $pre = ''; //table prefix ### //internal info private $error = ''; private $errno = 0; //number of rows affected by SQL query public $affected_rows = 0; ... ? This is the error I am receiving: *Fatal error*: Call to undefined method Database::affected_rows() in * /home/mwclans1/public_html/components/footerlinks.inc.php* on line *9* Please help PHP gurus!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 404 page
navneet sharma wrote: Hi, - About 404 error document... Make sure filenotfound.html is in public_html or www directory as your are using shared hosting... - Generally in share hosting environment you are not allowed to modify php.ini (GoDaddy allows), you can modify some property of httpd.config and php.ini using .htaccess but again depands on server administrator's permission. Navneet. On Mon, Dec 28, 2009 at 11:13 AM, Sudhakar sudhakarar...@gmail.com wrote: hi 1. i have a .htaccess file in my root directory on unix hosting following is the code in .htaccess file ErrorDocument 404 /filenotfound.html try removing the '/' in front of the file. I don't think the 404 file resides in the root of your filesystem. the file filenotfound.html is also in the root directory as the htaccess file when i intentionally type a wrong url either if a misspell a file ex= http://domainname.com/filenam.html or a folder ex = http://domainname.com/100 to test if this is working filenotfound.html is not being called any reason why this is happening also the same thing with wamp on my local computer, i have a htaccess and also the filenotfound in d:/wamp/www however when i misspell the ulr of my localhost, i have noticed in the status bar that the page is being redirected to http://linkhelp.clients.google.com and i get a 404 from this website, how can i change this redirection 2. how do i access the php.ini and httpd.conf file from my cpanel, do i need to ask my hosting provider to make any changes or can i make these changes myself 3. after downloading putty and if i have wamp in d:/wamp/www how do i access mysql from the command prompt using putty on my local machine please advice thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Saving server side file to local machine with JS
Skip Evans wrote: Sorry, I should have been clearer. When PHP finishes creating the file I need one of the JS alert type windows to appear that says.. Your file has completed, would you like to save it to your machine? Like you get when you download a file. If I knew the JS code to do this I perhaps could embed it in the PHP at the end of the function that creates the file??? Is that clearer? Thanks, Skip Not sure if you can save it directly From javascript! What you could do is. 1. Make an asynchrome call to a php script on the server with javascript. 2. Once PHP is finished you can make it return a URL to the asynchrome javascript call. This URl will point to the generated download file. 3. Then with javascript create a nice div with two buttons. One to initiate the download and the other to cancel... Paul M Foster wrote: On Sun, Jul 26, 2009 at 09:55:14PM -0500, Skip Evans wrote: Okay, I know I've done this before, but now I'm blanking out. I have code that creates a CSV file, and when it's done I want a JS alert to pop up and let them save the file. Isn't this some kind of alert() type call on the JS side??? I know I've done this before and I've been on Google an hour now! Not sure I understand your question, but there is a function called alert() in javascript. It opens a window with your error message in it. I don't know of a way to trigger this from PHP, since PHP is server-side and Javascript is client-side. You might be able to have javascript scan for the existence/closing of the file in question and then alert the user. Or you could have PHP, when the file is complete, launch a new page which contains the javascript code to alert the user. Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php.net down?
Anybody noticed php.net is down? It's responding to pings. But no pages load. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mac OS X Server
The Doctor wrote: ALl right, I just install MySQL 5.1.36 on a Mac OS X Server but the PHP is looking at the Mysql 5.0.67 ? How do I tell the php.ini to look at the 5.1 instead of the 5.0? You don't do that from the php.ini file. Either recompile PHP against the new MySQL source. If you use some sort of package management you can just upgrade PHP. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with my class
Luke wrote: 2009/4/16 Jan G.B. ro0ot.w...@googlemail.com 2009/4/16 Luke l...@blog-thing.com: Hi guys, I've been learning about object oriented programming and I wrote this test class but it doesn't seem to be working, it throws no errors but doesn't insert anything to the database either. I have made sure that the data being sent when the class is instantiated is valid. I'm probably missing something simple here... Are you actually calling your public function? $x = new RecipeCreator('a', 'b', 'c'); $x-saveRecipe(); You might want to insert some error reporting... echo mysql_error(); and alike Byebye I have already class RecipeCreator { private $rtitle; private $problem; private $solution; function __construct ($t, $p, $s) { if(!isset($t, $p, $s)) { throw new Exception ('Missing parameters for __construct, need $title $problem and $solution'); } $this-rtitle = mysql_real_escape_string($t); $this-problem = mysql_real_escape_string($p); $this-solution = mysql_real_escape_string($s); } public function saveRecipe() { $query = INSERT INTO recipe (title, problem, solution) VALUES ('.$this-rtitle.', '.$this-problem.', '.$this-solution.'); mysql_query($query); } } Many thanks, Luke Slater -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Yes I am doing that. The query seems to be going through all right too I tested the syntax in mysql query browser and tried mysql_error() but there was nothing. I think there's an issue with the __construct because when I wrote a method in there to return one of the properties of the function, it turned up blank! As I said before the variables I'm passing in are definitely valid... And what happens when you instantiate your object without parameters? $foo = new RecipeCreator(); It should throw and exception. This way you at least know if your constructor is functioning properly. And take a look at the message you throw when the parameters are not set. The parameters are named $t, $p, $s but the message in the throw statement uses $title, $problem, $solution did you try echoing out the query and run it from phpMyAdmin or something similar? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with my class
Luke Slater wrote: On Thu, Apr 16, 2009 at 2:41 PM, Thijs Lensselink p...@addmissions.nl mailto:p...@addmissions.nl wrote: Luke wrote: 2009/4/16 Jan G.B. ro0ot.w...@googlemail.com mailto:ro0ot.w...@googlemail.com 2009/4/16 Luke l...@blog-thing.com mailto:l...@blog-thing.com: Hi guys, I've been learning about object oriented programming and I wrote this test class but it doesn't seem to be working, it throws no errors but doesn't insert anything to the database either. I have made sure that the data being sent when the class is instantiated is valid. I'm probably missing something simple here... Are you actually calling your public function? $x = new RecipeCreator('a', 'b', 'c'); $x-saveRecipe(); You might want to insert some error reporting... echo mysql_error(); and alike Byebye I have already class RecipeCreator { private $rtitle; private $problem; private $solution; function __construct ($t, $p, $s) { if(!isset($t, $p, $s)) { throw new Exception ('Missing parameters for __construct, need $title $problem and $solution'); } $this-rtitle = mysql_real_escape_string($t); $this-problem = mysql_real_escape_string($p); $this-solution = mysql_real_escape_string($s); } public function saveRecipe() { $query = INSERT INTO recipe (title, problem, solution) VALUES ('.$this-rtitle.', '.$this-problem.', '.$this-solution.'); mysql_query($query); } } Many thanks, Luke Slater -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Yes I am doing that. The query seems to be going through all right too I tested the syntax in mysql query browser and tried mysql_error() but there was nothing. I think there's an issue with the __construct because when I wrote a method in there to return one of the properties of the function, it turned up blank! As I said before the variables I'm passing in are definitely valid... And what happens when you instantiate your object without parameters? $foo = new RecipeCreator(); It should throw and exception. This way you at least know if your constructor is functioning properly. And take a look at the message you throw when the parameters are not set. The parameters are named $t, $p, $s but the message in the throw statement uses $title, $problem, $solution did you try echoing out the query and run it from phpMyAdmin or something similar? I changed the variables to $t $p and $s because I thought by naming them with $title $problem and $solution may have been getting them mixed up somehow. I figured out the problem, which was that I was actually calling the saveRecipe() method without the parentheses. Happens to the best :) Too long programming in Perl -.- Thanks for your help, Luke Slater Great you figured it out. Regards, Thijs -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] integrating perl and PHP problem
Moses wrote: Hi Everyone, I have a perl program which I would like to display its results in PHP. I have read PHP book and the solution is to convert the perl program which is not easy. I have tried a simple example but it is not working. The perl script is #! /usr/bin/perl -w print hello world and the Php script is ?php $result = exec(/var/www/hello.pl,$dirout); foreach($dirout as $line) { echo $line\n; } ? Thanks. I don't think PHP / Apache have the rights to execute a perl script like this. Either give hello.pl execute rights. Or change the line in exec to /usr/bin/perl /var/www/hello.pl -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP + MySQL - Load last inserts
Sebastian Muszytowski wrote: Hello :) I have some troubles with php and mysql. I have a normal MySQL Query and this returns X 3 rows. Now i want to get the last 3 inserted values. For Example i've inserted A, B, C, D, E I want to get the last inserted values, e.g. E D C (in reversed order) So how to do this? I already searched the web and the whole php.net site but i don't see any workaround. Thanks in advance Sebastian It's not really a PHP question. But here goes : SELECT column FROM `table` ORDER BY column DESC LIMIT 3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] LOAD INFILE
John Boy wrote: Hi I want to upload a .csv file from my local pc to a mysql server. My local machine is XP2. I have used the following but the file does not upload. When using php MyAdmin it returns the error 'file not found'. Can anyone help? ?php // Include our login information include('db_login_master.php'); // Connect - note: 'false' is 'no new link use existing' parameter and '128' enables LOAD DATA $connection = mysql_connect($db_host, $db_username, $db_password,false,128); if (!$connection){ die (Could not connect to the database: br /. mysql_error()); } // Select the database $db_select=mysql_select_db($db_database); if (!$db_select) { die (Could not select the database: br /. mysql_error()); } // Import new avaiability data from local CSV file $sql2 = 'LOAD DATA LOCAL INFILE \'C:EXPORT.CSV\' INTO TABLE `availability` FIELDS TERMINATED BY \';\' ENCLOSED BY \'\' ESCAPED BY \'\' LINES TERMINATED BY \'\\r\\n\''; // echo $sql2; mysql_query($sql2); echo 'p align=centerfont face=Verdana color=#FF'; mysql_query($sql0); printf(Records added: %d\n, mysql_affected_rows()); echo 'p align=centerBUPDATE COMPLETE/B/p'; ? Are you only passing the path to the C:EXPORT.CSV local file inside the query? You first need to upload the file. Either through a form or bu using FTP, SSH or something similar. More info about uploading files with PHP: http://php.net/manual/en/features.file-upload.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] bad interpreter error from CLI
Thodoris wrote: Hi gang, I am trying to run a script from cli which goes like this: #!/usr/bin/php ?php passthru(printenv); ? The error I get is this: /usr/bin/php^M: bad interpreter: Permission denied the php binary is indeed in this location and when I run the same script like this: php -f test.php it works properly. I will have to mention that the executable flag is set in the file's permissions. Any ideas why is this happening? php -v gives me: PHP 5.1.6 (cli) (built: Nov 12 2008 11:22:34) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies Does the filesystem the scripts are on by any chance has 'noexec' set? $ mount (rw,noexec,nosuid,nodev) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5.2.9 - 5.2.9-1 and curl
Niki wrote: Hi all, I'm using PHP 5.2.9 on a Windows dedicated server. Could you kindly confirm me that I have to update to PHP 5.2.9-1 (http://www.php.net/archive/2009.php#id2009-03-10-1) only if I have curl extension enabled (extension=php_curl.dll in php.ini) ? Well nobody forces you to upgrade. But it would be wise. Now the bug in curl is still fresh in your mind. But if you forget and decide to enable it later. Big chance you vulnerable to some sort of attack. If I run a phpinfo() on my webserver, no curl section is shown (no extension=php_curl.dll in php.ini). So, is my configuration (Windows 2003 Server - PHP 5.2.9) safe? The bug only affects libcurl. So i guess when curl is disabled it's safe... Thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to work with Webservices (.asmx) server
Hoi Anton, Great job on the Dutch part :) But please keep the thread on list. You have set the server location when you create a SOAP client instance. Take a look at : http://php.net/manual/en/soapclient.soapclient.php So when instantiating the SOAP client object you pass as a second parameter. An array with as minimal settings the location and uri. I guess in your case it would be something like this: $client = new SoapClient(null, array( 'location' = http://localhost/WebService/GetData.asmx;, 'uri' = http://localhost/WebService/;) ); And if your webservice provides a WSDL file you can replace the null parameter for that one. Anton Heuschen wrote: Dag. Dank U well. Lol and thats where my Dutch is going to end... Thank you for the info, just one question that had me confused also and that is to do with this the URL you actually are talking to with your SOAP client is http://localhost/WebService/ Ive seen that in material on the net too ... but I wondered so how does your SOAP request know where to connect to ? should I not have the target server URL (or is this also pointing to the Web Services Servers WSDL not setup correctly and will my client only work if I run it from the same PC? ) This is what confuses me so . Regards 2009/3/10 Thijs Lensselink p...@addmissions.nl mailto:p...@addmissions.nl Anton Heuschen wrote: I am confused with XML-RPC / SOAP and WSDL ... If you have a server with a script/file like test.asmx and some web services ...below example of service format : SOAP 1.2 The following is a sample SOAP 1.2 request and response. The placeholders shown need to be replaced with actual values. - SAMPLE OF Web Service from the server below : SOAP 1.2 The following is a sample SOAP 1.2 request and response. The placeholders shown need to be replaced with actual values. POST /webservice/GetData.asmx HTTP/1.1 Host: www.theserver.com http://www.theserver.com Content-Type: application/soap+xml; charset=utf-8 Content-Length: length ?xml version=1.0 encoding=utf-8? soap12:Envelope xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:soap12=http://www.w3.org/2003/05/soap-envelope; soap12:Body GetData xmlns=http://localhost/WebService/; Inputstring/Input /GetData /soap12:Body /soap12:Envelope HTTP/1.1 200 OK Content-Type: application/soap+xml; charset=utf-8 Content-Length: length ?xml version=1.0 encoding=utf-8? soap12:Envelope xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:soap12=http://www.w3.org/2003/05/soap-envelope; soap12:Body GetDataResponse xmlns=http://localhost/WebService/; Outputstring/Output /GetDataResponse /soap12:Body /soap12:Envelope END OF SAMPLE I spend about most of my time looking at SOAP, XML-RPC and the PHP SOAP extension, like from here: http://tutorial.jcwcn.com/Web-Design/PHP/XML-and-PHP/2008-08-15/10160.html Most of these talk about request to the server and a script with .wsdl extension ... but from the example SOAP 1.2 framework above and the fact that the url to the web service is not a .wsdl file but in fact a .asmx file, how on earth to you It doesn't have to be a .wsdl extension to offer that functionality. The WSDL output is nothing more then what the webservice has to offer. Requests are not send to the .wsdl but to the webservice endpoint. 1) post a request to the example above. 2) What do you use here now actually ? SOAP/XML-RPC/WSDL ? or is this something else ? Its extremely confusing since this does not seem to fit in with any of the examples, material on the net. The examples above show requests en responses in the SOAP format. You could target this webservice in multiple ways. But building a SOAP client would probably be the best option. I basically need to call the service and pass string to the Input parameter and get the response field. Some examples using the PHP Soap class talk about setting the URI, the host and the NS and I don't know from the example SOAP 1.2 fields provided where this should be taken from. the URL you actually are talking to with your SOAP client is http://localhost/WebService/ Some guidelines to good documentation/howto or tutorials and/or some examples and functions/class would
Re: [PHP] How to work with Webservices (.asmx) server
Anton Heuschen wrote: Thanks Thijs. My Father is from the Netherlands, but I wont try it all in Dutch myself... Ok slowly but surely and with your advice I start making sense of this, I am still playing around with some tests and reading up. It should be real clear and obvious once you get a working example I guess. Thanks for your assistance and advice so far. If you have more questions. The whole list is at your disposal. Regards Now of to make myself a nice Hagelslag botterham to soothe my nerves ;-) Now that sounds tasty. Always thought we Dutch are the only ones crazy enough to eat this stuff :) Anton 2009/3/11 Thijs Lensselink p...@addmissions.nl Hoi Anton, Great job on the Dutch part :) But please keep the thread on list. You have set the server location when you create a SOAP client instance. Take a look at : http://php.net/manual/en/soapclient.soapclient.php So when instantiating the SOAP client object you pass as a second parameter. An array with as minimal settings the location and uri. I guess in your case it would be something like this: $client = new SoapClient(null, array( 'location' = http://localhost/WebService/GetData.asmx;, 'uri' = http://localhost/WebService/;) ); And if your webservice provides a WSDL file you can replace the null parameter for that one. Anton Heuschen wrote: Dag. Dank U well. Lol and thats where my Dutch is going to end... Thank you for the info, just one question that had me confused also and that is to do with this the URL you actually are talking to with your SOAP client is http://localhost/WebService/ Ive seen that in material on the net too ... but I wondered so how does your SOAP request know where to connect to ? should I not have the target server URL (or is this also pointing to the Web Services Servers WSDL not setup correctly and will my client only work if I run it from the same PC? ) This is what confuses me so . Regards 2009/3/10 Thijs Lensselink p...@addmissions.nl mailto: p...@addmissions.nl Anton Heuschen wrote: I am confused with XML-RPC / SOAP and WSDL ... If you have a server with a script/file like test.asmx and some web services ...below example of service format : SOAP 1.2 The following is a sample SOAP 1.2 request and response. The placeholders shown need to be replaced with actual values. - SAMPLE OF Web Service from the server below : SOAP 1.2 The following is a sample SOAP 1.2 request and response. The placeholders shown need to be replaced with actual values. POST /webservice/GetData.asmx HTTP/1.1 Host: www.theserver.com http://www.theserver.com Content-Type: application/soap+xml; charset=utf-8 Content-Length: length ?xml version=1.0 encoding=utf-8? soap12:Envelope xmlns:xsi= http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:soap12=http://www.w3.org/2003/05/soap-envelope; soap12:Body GetData xmlns=http://localhost/WebService/; Inputstring/Input /GetData /soap12:Body /soap12:Envelope HTTP/1.1 200 OK Content-Type: application/soap+xml; charset=utf-8 Content-Length: length ?xml version=1.0 encoding=utf-8? soap12:Envelope xmlns:xsi= http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:soap12=http://www.w3.org/2003/05/soap-envelope; soap12:Body GetDataResponse xmlns=http://localhost/WebService/; Outputstring/Output /GetDataResponse /soap12:Body /soap12:Envelope END OF SAMPLE I spend about most of my time looking at SOAP, XML-RPC and the PHP SOAP extension, like from here: http://tutorial.jcwcn.com/Web-Design/PHP/XML-and-PHP/2008-08-15/10160.html Most of these talk about request to the server and a script with .wsdl extension ... but from the example SOAP 1.2 framework above and the fact that the url to the web service is not a .wsdl file but in fact a .asmx file, how on earth to you It doesn't have to be a .wsdl extension to offer that functionality. The WSDL output is nothing more then what the webservice has to offer. Requests are not send to the .wsdl but to the webservice endpoint. 1) post a request to the example above. 2) What do you use here now actually ? SOAP/XML-RPC/WSDL ? or is this something else ? Its extremely confusing since this does not seem to fit in with any of the examples, material on the net. The examples above show requests en responses
Re: [PHP] How to work with Webservices (.asmx) server
Anton Heuschen wrote: I am confused with XML-RPC / SOAP and WSDL ... If you have a server with a script/file like test.asmx and some web services ...below example of service format : SOAP 1.2 The following is a sample SOAP 1.2 request and response. The placeholders shown need to be replaced with actual values. - SAMPLE OF Web Service from the server below : SOAP 1.2 The following is a sample SOAP 1.2 request and response. The placeholders shown need to be replaced with actual values. POST /webservice/GetData.asmx HTTP/1.1 Host: www.theserver.com Content-Type: application/soap+xml; charset=utf-8 Content-Length: length ?xml version=1.0 encoding=utf-8? soap12:Envelope xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:soap12=http://www.w3.org/2003/05/soap-envelope; soap12:Body GetData xmlns=http://localhost/WebService/; Inputstring/Input /GetData /soap12:Body /soap12:Envelope HTTP/1.1 200 OK Content-Type: application/soap+xml; charset=utf-8 Content-Length: length ?xml version=1.0 encoding=utf-8? soap12:Envelope xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:soap12=http://www.w3.org/2003/05/soap-envelope; soap12:Body GetDataResponse xmlns=http://localhost/WebService/; Outputstring/Output /GetDataResponse /soap12:Body /soap12:Envelope END OF SAMPLE I spend about most of my time looking at SOAP, XML-RPC and the PHP SOAP extension, like from here: http://tutorial.jcwcn.com/Web-Design/PHP/XML-and-PHP/2008-08-15/10160.html Most of these talk about request to the server and a script with .wsdl extension ... but from the example SOAP 1.2 framework above and the fact that the url to the web service is not a .wsdl file but in fact a .asmx file, how on earth to you It doesn't have to be a .wsdl extension to offer that functionality. The WSDL output is nothing more then what the webservice has to offer. Requests are not send to the .wsdl but to the webservice endpoint. 1) post a request to the example above. 2) What do you use here now actually ? SOAP/XML-RPC/WSDL ? or is this something else ? Its extremely confusing since this does not seem to fit in with any of the examples, material on the net. The examples above show requests en responses in the SOAP format. You could target this webservice in multiple ways. But building a SOAP client would probably be the best option. I basically need to call the service and pass string to the Input parameter and get the response field. Some examples using the PHP Soap class talk about setting the URI, the host and the NS and I don't know from the example SOAP 1.2 fields provided where this should be taken from. the URL you actually are talking to with your SOAP client is http://localhost/WebService/ Some guidelines to good documentation/howto or tutorials and/or some examples and functions/class would be appreciated immensely http://wso2.org/library/1060 Regards -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Help - No .php file extension
Hibbert Miller wrote: Hello,I have been asked to install an existing PHP/MySQL application on a system using Windows Vista. What application are we talking about here? Is it a known Open/Closed source application? Is it supposed to run on windows? I have installed PHP 5.2.8, MySQL 5.1.31 and IIS 7.0. PHP is working as expected (I created a test page which displays the output from phpinfo()). The application in question posts to a login page from an index page called index.php. However, the form's action is simply set to login, and not login.php as expected. Further checking revealed that all links in the application appear to exclude the file extensions. Sounds like this applications is making use of some sort of controller to handle requests. A lot of frameworks and applications make use of the MVC* pattern. That could be a reason why there's no .php extension. The call to login will probably result into something like http://host.tld/login, Which will be rewritten by the help of either htaccess or php itself. I have combed through the php.ini file and have not been able to find any configuration setting that deal with this. I have also tried configuring IIS to send all requests to PHP by setting the Handler Mapping to * instead of just *.php. Did there come a .htaccess file with the application? I'm not sure how IIS handles these things. Last time i touched IIS. It was still in 5.x version range... Thank you in advance for any information you may be able to provide. HM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Dev Facts
Quoting Nathan Rixham [EMAIL PROTECTED]: Evening All, I'd be /really/ interested to know who uses what! *Procedural or OOP?* OO *Dev OS* Ubuntu / Windows XP *Dev PHP Version* 5.2.6 *Live Server OS* Debian / Suse *Live Server PHP Version* 5.2.6 *Which HTTP Server Software (+version)?* Apache 2 *IDE / Dev Environment* Zend Studio for Eclipse *Preferred Framework(s)?* Zend Framework / Symfony *Do you Unit Test?* Sometimes *Most Used Internal PHP Class* *Preferred OS CMS* *Anything else you use frequently in you're PHP'ing that's worth mentioning:* SVN ps: I'm not asking for any kind of research project, just interested and interested to know what's most common + might learn something/find some new tools/toys! pps: will reply myself as well but if I do here it'll make your intertwined replies messy! Many Regards Nathan -- 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] Static method variable
Quoting Christoph Boget [EMAIL PROTECTED]: Perhaps I'm misunderstanding what a static method variable is supposed to do. I thought the value would be static for an class' instance but it appears it is static across all instances of the class. Consider: class StaticTest { public function __construct() { } public function test( $newVal ) { static $retval = ''; if( $retval == '' ) { $retval = $newVal; } echo $retval . 'br'; } } $one = new StaticTest(); $one-test( 'joe' ); $two = new StaticTest(); $two-test( 'bob' ); Should it be working that way? thnx, Chris That's exactly how a static class var functions. It's available cross all instances of the class. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is this a bug?
Jochem Maas wrote: T Lensselink schreef: Catalin Zamfir Alexandru, DATAGRAM SRL wrote: Hello guys, I've been stalking on the list for some time. Didn't have anything to report/talk, until now. I have a code like this, maybe you guys can reproduce it, with output buffering started: Echo 'something'; Echo 'another thing'; Echo 'something br /'\; What happens is that ANYTHING that was echo'ed until that \, will not reach the buffer. Although, this should actually be a Parse Error, it isn't, it just echoes what was echoed after the god damned \. It took me two hours to find this typo in the code . ouch. don't forget you can do: $ php - l yourscript.php to test for syntax errors (the warning does show up with this). additionally a good syntax highlighting editor can help you to spot stuff like this ... anything to stop the eyes from bleeding :/ Can you guys reproduce the error? I can actually give you a link to the server where this code runs. The script doesn't cause a parse error Instead it throws a warning. 'PHP Warning: Unexpected character in input: '\' (ASCII=92) state=1 in' Don't think it's a bug. And the reason there's no syntax error is because the \ is a PHP escape character. is this character ever valid as an escape character outside of a string? if it is that's news to me and if it isn't then really it is a bug ... it should be a straight up parse error ... chances are that it's down to limitations in the lexer? the output buffer handler that seems to be swallowing the warning every second request now that is weird. I don't think it should be valid outside a string. But PHP seems to see this different. The only reason i could think of. Is that the \ somehow is a registered symbol. So it throws a non fatal E_COMPILE_ERROR. Could be a bug. That's for the guys on internals to decide. I'd also expect a parse error. With output buffering enabled i still get the same warning on every request. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Braindead
Chris Haensel wrote: Hi guys, maybe I am too stupid, but I can not see a solution for this. Have been cracking up my brain for the last hours, so I finally dare to ask. I have a database table with some columns text1 | text2 | text3 | text4 -- Now, for some stats thingy, I am trying to get the COUNT of distinct entries So, i would like to get the count of entries where text2 is foo OR text3 is foo I have 20.863 entries at the moment, and it takes quite a lot of time reading through that stuff. I have tried SELECT COUNT(*) as mycount FROM mytable WHERE text2 = 'foo' and text3 = 'foo' but I neither get an error nor any output. It just loads and loads without any output... I am out of ideas :o( Help, anybody? :o)) Chris The amount of records is not that big to slow things down. Did you use indexes on your database? And did you try running the query through commandline or phpMyAdmin? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] pdo compilation question
Quoting Tim Rupp [EMAIL PROTECTED]: Hi list, I hope this is the right area to ask, I'm trying to compile PDO support in 5.2.6 and am following the instructions here http://us2.php.net/manual/en/pdo.installation.php My compile line is the following ./configure --enable-force-cgi-redirect \ --disable-rpath \ --with-bz2 \ --with-db4=/usr \ --with-curl \ --with-gd \ --enable-gd-native-ttf \ --without-gdbm \ --with-gettext \ --with-ncurses \ --with-gmp \ --with-iconv \ --with-openssl \ --with-regex=system \ --with-zlib \ --with-layout=GNU \ --enable-bcmath \ --enable-exif \ --enable-ftp \ --enable-magic-quotes \ --enable-sockets \ --enable-sysvsem \ --enable-sysvshm \ --enable-wddx \ --with-kerberos \ --with-ldap=shared \ --with-mysql=shared \ --enable-mbstring=all \ --with-apxs2=/usr/sbin/apxs \ --with-pgsql=shared \ --with-mysqli \ --with-freetype-dir=/usr/include/freetype2 \ --with-mcrypt \ --enable-soap \ --enable-pcntl \ --enable-pdo=shared \ --with-sqlite=shared \ --with-pdo-sqlite=shared \ --with-pdo-mysql=shared \ --with-pdo-pgsql=shared \ --with-pdo-oci=shared This config line I'm working with has been a growing one, so there may be some things here that may or may not be needed. Anyway, Upon compiling the above, I get the following error when I do a php -m Warning: PHP Startup: Invalid library (maybe not a PHP library) 'pdo.so' in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20060613/pdo_mysql.so' - /usr/local/lib/php/20060613/pdo_mysql.so: undefined symbol: php_pdo_get_dbh_ce in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20060613/pdo_pgsql.so' - /usr/local/lib/php/20060613/pdo_pgsql.so: undefined symbol: php_pdo_register_driver in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20060613/pdo_sqlite.so' - /usr/local/lib/php/20060613/pdo_sqlite.so: undefined symbol: php_pdo_register_driver in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20060613/sqlite.so' - /usr/local/lib/php/20060613/sqlite.so: undefined symbol: php_pdo_register_driver in Unknown on line 0 I've included the extensions in my php.ini file, but I'm completely lost on where to go from here because the error is less than helpful. The order that I've included them is extension=pdo.so extension=pdo_mysql.so extension=pdo_pgsql.so extension=pdo_sqlite.so extension=sqlite.so and they do exist, as shown here -rwxr-xr-x 1 root root 364012 May 14 2007 apc.so -rwxr-xr-x 1 root root 102531 Aug 18 14:25 ldap.so -rwxr-xr-x 1 root root 120644 Aug 18 14:25 mysql.so -rwxr-xr-x 1 root root 270860 Nov 13 2006 oci8.so -rwxr-xr-x 1 root root 125246 Aug 18 14:25 pdo_mysql.so -rwxr-xr-x 1 root root 100772 Aug 18 14:25 pdo_oci.so -rwxr-xr-x 1 root root 111246 Aug 18 14:25 pdo_pgsql.so -rwxr-xr-x 1 root root 270276 Aug 18 14:25 pdo.so -rwxr-xr-x 1 root root 1370516 Aug 18 14:25 pdo_sqlite.so -rwxr-xr-x 1 root root 235943 Aug 18 14:25 pgsql.so -rwxr-xr-x 1 root root 1010437 Aug 18 14:25 sqlite.so -rwxr-xr-x 1 root root 598407 Jan 29 2008 xdebug.so I'm using RHEL 4, and have installed the sqlite-devel, but I think php is choosing to use the sqlite that comes with it I'm hoping someone on the list can point me in the right direction. Thanks in advance, Tim you are loading extensions of an older PHP version. Do an ls -als on /usr/local/lib/php. you will find a directory with a higher date. That's your new extension path. Just change the location in the php.ini to reflect the new location. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Semi-ADVERT, not really spam, sorry for it
Quoting Jochem Maas [EMAIL PROTECTED]: metastable schreef: V S Rawat wrote: If you provide paid help in code development/ testing/ troubleshooting related to php or other software areas, please feel free to drop a line to me at my id mentioned below. Please don't write here as some other members might find this off topic. Sorry for bothering the rest of you. I hope you wouldn't really mind if some of our colleagues who are doing such a lovely volunteer work here get to earn some money for a bottle of beer and more. Rest assured that it is no fraud/ scam/ cheating. I am very much here to take the brickbats. Thanks. -- V vsrawat at gmail dot com Imo, it is both off-topic and inappropriate. which the subject made pretty clearly, use common sense and ignore such mails if they don't interest you. Moreover, I have not seen your name in any of the topics on this list or hadn't seen yours either, at least Rawat is a real name. and for the record he has posted 2 more messages to the list than you have this year (your massive contribution ammounts to 7 posts since Nov'07) ... Rawat's first post started with the words 'Newbie Problem' so he's indentified himself as a beginner and therefore it's in everyone's interest that he do alot more reading (and asking questions) rather than replying to other's questions with the limited knowledge he has atm. remembered it in any reply, as opposed to many others who take time from their busy schedules to give something back, free of charge. This does not inspire much confidence in your qualities or determination. There are many channels out there that would be beneficial to your goals, e.g. wendo, ogone and the likes. Please take your commercial goals there. He's looking for a little off-list help for which he is apparently willing to offer some kind of compensation ... plenty of other's have done the same in the past, some of us occasionally even take people up on their offer and I've actually earned more dollars that way than you've posted words to this list. Seems to me you either have a pathetic grasp of the english language or you can't be bothered to read. Just my two cents. indeed. PS - for those that know, I'm back ... with a vengeance. So right! welcome back Jochem. This list just isn't the same without your comments ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why PHP4?
Quoting Hélio Rocha [EMAIL PROTECTED]: Sorry to disagree, But I think that with PHP4 a lot of people start thinking that they could be programmers (maybe they can, developers it's another story). When php5 came they didn't know how do deal with the deprecated methods and worst, some hosters didn't know how to virtualize a f1ck1n' server with Apache+PHP5. A lot of mistakes were made when php5 came out but how can a language grow up when they DEPRECATE the syntax? we're not talking about removing the last ';'... O come on. All people have had enough time to get used to it. Between the time PHP5 first came out and when it started to gain attention mainstream wise. Is a gap of 5 years. I think 5 years is enough to get used to new / deprecated features. I still think PHP is moving the right way. When i do an upgrade i first check change logs. You can always expect things to change. It's a dynamic world we live in :) Maybe I'm in a GET LOST PHP phase but I think that someone is killing it, and the ones who are stuck in 4 are not helping. When U write code, U must not be worried 'bout the next upgrade of your server! Best regards! On Wed, Jul 30, 2008 at 3:31 AM, VamVan [EMAIL PROTECTED] wrote: Its because PHP got really famous with version 4.0 and many people actually converted their CGI or other websites in to PHP 4 websites because it was easy and cheap. But 5.0 brought too many changes like serious OOPS and register global concepts for security, which is useful but made transition difficult. I feel thats why PHP 4 is still supported. Its not only the language that has changed, but also people had to upgrade their skill set and there was some learning curve involved. Unfortunately everyone fell in the trap of register globals which was not dealt until php 4.3.1 as a security concept. Pear and Pecl were there but everyone was pretty much writing all the code (reinventing the wheel) from scratch. This brings in huge code base to change. I liked PHP because intitially it was a procedural langauge and it resembled C. But now with OOPS you can build powerful websites which is good. There are many other cases but I feel strongly this is what makes them still support PHP 4. Thanks Personally i use PHP5 when ever i can. But at work we are stuck with some small legacy applications . And some major applications written on top of PHP4. For which is no time to do the research let alone the time to rebuild them. I think there are a few reasons why people still use PHP4. 1. People learned PHP4 as a hobby. So upgrading knowledge goes much slower. Then when you have to stay on top work wise. (which will create a chicken egg situation with point 2) 2. Hosting providers have no clue how to configure their environment. Or are stuck with customers running PHP4 applications. 3. No time to research and rebuild existing applications. (which will create a chicken egg situation with point 2) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [soap]about compress
Quoting 付兴林 [EMAIL PROTECTED]: I have an issue about soap. Is the data returned from servier compressed by gzip, When using soap in php5 to creat web service? Can we set for compress lever or not compress? _ 这里好多好玩的视频,用鼠标点到视频看看,有惊喜! http://cnweb.search.live.com/video/results.aspx?q=%E5%A5%A5%E8%BF%90%E5%9C%A3%E7%81%ABmkt=zh-cnFORM=WLMTWC For the SOAPClient you can pass some settings in the $options parameter. $options = array('compression' = SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 9); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] uploading big files with PHP
Quoting Angelo Zanetti [EMAIL PROTECTED]: Hi all We are pitching to develop a website where the admin has to upload big video files but I'm not sure how this can be done as the file upload will most probably time out. How do current websites do it? Is there somehow a way to make use of FTP to transfer the files? Any links, help, advice will be appreciated. Thanks in advance Angelo http://www.elemental.co.za Uploading big files should not be a problem. Make sure the some .ini settings are correct for you: max_execution_time = 30 ; Maximum execution time of each script, in seconds max_input_time = 60 ; Maximum amount of time each script may spend parsing request data max_input_nesting_level = 64 ; Maximum input variable nesting level ; Maximum size of POST data that PHP will accept. post_max_size = 8M The first 3 you can set with ini_set. You could of course use the ftp functionality available in PHP. http://nl3.php.net/ftp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] uploading big files with PHP
Quoting Angelo Zanetti [EMAIL PROTECTED]: -Original Message- From: Thijs Lensselink [mailto:[EMAIL PROTECTED] Sent: 25 July 2008 12:08 To: php-general@lists.php.net Subject: Re: [PHP] uploading big files with PHP Quoting Angelo Zanetti [EMAIL PROTECTED]: Hi all We are pitching to develop a website where the admin has to upload big video files but I'm not sure how this can be done as the file upload will most probably time out. How do current websites do it? Is there somehow a way to make use of FTP to transfer the files? Any links, help, advice will be appreciated. Thanks in advance Angelo http://www.elemental.co.za Uploading big files should not be a problem. Make sure the some .ini settings are correct for you: max_execution_time = 30 ; Maximum execution time of each script, in seconds max_input_time = 60 ; Maximum amount of time each script may spend parsing request data max_input_nesting_level = 64 ; Maximum input variable nesting level ; Maximum size of POST data that PHP will accept. post_max_size = 8M The first 3 you can set with ini_set. You could of course use the ftp functionality available in PHP. http://nl3.php.net/ftp - Thanks Thijs, It does make sense to change the post_max_size value. But what if the file is for example a 100MB file or bigger. This probably isn't the best way to handle this? I'm trying to find the best practices to do this or is this totally the wrong way to go about this? Thanks again! Angelo If the file is located on the client side. Then form based upload over HTTP is your only option really. FTP only comes in handy when the file in question resides on the server. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] After INSERT form submit - Data doesn't refresh!
Quoting Rahul S. Johari [EMAIL PROTECTED]: Here's what it is: I have a php page, a.php, which contains these three things: - SELECT statement to display records from a mySQL Table - HTML Form for inserting data into the mySQL Table - INSERT statement to insert that row into the mySQL Table If the flow of you program really works in this order. Then i can understand you are looking at the same records after a INSERT. The SELECT query is run before the INSERT. So if you submit your INSERT form. The page first selects a record set from the database. And after that preforms the INSERT. The HTML Form submits to the same, a.php Once the user submits the Form, a.php is called which INSERT's the row into the mySQL Table. However, the row does not appear in the SELECT statement table data unless I hit refresh on the page. (The INSERT function is executed before the SELECT in the page). I used the header() code that was suggested: header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Pragma: no-cache'); $ffile = 'a.php'; $time = filemtime($ffile); header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT'); .. but it didn't help. Everything is working fine except that the Browser is more then likely caching the data and thus not allowing the newly inserted row to appear on top when the SELECT is executed. On Jul 22, 2008, at 8:34 AM, Thiago H. Pojda wrote: Code, please? :) On Tue, Jul 22, 2008 at 9:33 AM, Rahul S. Johari [EMAIL PROTECTED] wrote: Hmm, interesting. In my case, $file does indeed output dynamic data. I did try with the modified time but it still doesn't work. I still have to hit refresh on the browser, after submitting the form, in order for the inserted record to appear. Not sure what to do - it's rather annoying. Novice users of the page would assume the entry didn't get inserted or something happened. One alternate is to submit Data to a different page and let that page redirect to the Original page - but I do find it hard to believe that there is no solution to this caching. Thanks guys! On Jul 22, 2008, at 8:26 AM, Yeti wrote: The Last-Modified header tells the browser when the requested page was last modified. Now I don't know how you get the date in your case but here is an example: browser requests /test/test.php which is a simple php file without any includes etc. in this case $file = '/test/test.php'; This wont work if $file outputs dynamic data, so only use it if the content only changes when you change the file. Now if you are using templates etc. obtaining the Last-Modified time is a bit more complicated. If you use server side caching then you can chose the cached file else you have to figure it out yourself. And the RFC 2616 header specification says: An origin server MUST NOT send a Last-Modified date which is later than the server's time of message origination. In such cases, where the resource's last modification would indicate some time in the future, the server MUST replace that date with the message origination date. So do not send a future date! On Tue, Jul 22, 2008 at 2:11 PM, Rahul S. Johari [EMAIL PROTECTED] wrote: I tried with just the first three header() statements you gave, but it didn't work. Let me try the modification date ... which file is being referred to in $ffile? Also, I'm using Firefox, if it's of any consequence. Thanks! On Jul 22, 2008, at 7:30 AM, Bernhard Kohl wrote: I'm pretty sure this is a cache issue .. To disable caching: header('Cache-Control: no-cache, no-store, max-age=0, must- revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Pragma: no-cache'); But if you have the modification date then use $time = filemtime($ffile); header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT'); On Tue, Jul 22, 2008 at 1:14 PM, Rahul S. Johari [EMAIL PROTECTED] wrote: Ave, I'm wondering if there's a PHP solution to this, I could be in the wrong place. I have an INSERT form which submits to the same php page, which also displays the records from the mySQL database the INSERT form submits to. When the form submits and the page returns, the added record does not show up unless you Refresh the page. I'm imagining even after form submit, the Browser is caching the data and displaying data from the Cache. Is there a solution to this? Is there anything PHP can do to instruct the browser not the cache the data? Thanks! --- Rahul Sitaram Johari Founder, Internet Architects Group, Inc. [Email] [EMAIL PROTECTED] [Web] http://www.rahulsjohari.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Rahul Sitaram Johari Founder, Internet Architects Group, Inc. [Email] [EMAIL PROTECTED]
Re: [PHP] After INSERT form submit - Data doesn't refresh!
Quoting Rahul S. Johari [EMAIL PROTECTED]: Here's what it is: I have a php page, a.php, which contains these three things: - SELECT statement to display records from a mySQL Table - HTML Form for inserting data into the mySQL Table - INSERT statement to insert that row into the mySQL Table The HTML Form submits to the same, a.php Once the user submits the Form, a.php is called which INSERT's the row into the mySQL Table. However, the row does not appear in the SELECT statement table data unless I hit refresh on the page. (The INSERT function is executed before the SELECT in the page). I used the header() code that was suggested: header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Pragma: no-cache'); $ffile = 'a.php'; $time = filemtime($ffile); header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT'); .. but it didn't help. Everything is working fine except that the Browser is more then likely caching the data and thus not allowing the newly inserted row to appear on top when the SELECT is executed. On Jul 22, 2008, at 8:34 AM, Thiago H. Pojda wrote: Code, please? :) On Tue, Jul 22, 2008 at 9:33 AM, Rahul S. Johari [EMAIL PROTECTED] wrote: Hmm, interesting. In my case, $file does indeed output dynamic data. I did try with the modified time but it still doesn't work. I still have to hit refresh on the browser, after submitting the form, in order for the inserted record to appear. Not sure what to do - it's rather annoying. Novice users of the page would assume the entry didn't get inserted or something happened. One alternate is to submit Data to a different page and let that page redirect to the Original page - but I do find it hard to believe that there is no solution to this caching. Thanks guys! On Jul 22, 2008, at 8:26 AM, Yeti wrote: The Last-Modified header tells the browser when the requested page was last modified. Now I don't know how you get the date in your case but here is an example: browser requests /test/test.php which is a simple php file without any includes etc. in this case $file = '/test/test.php'; This wont work if $file outputs dynamic data, so only use it if the content only changes when you change the file. Now if you are using templates etc. obtaining the Last-Modified time is a bit more complicated. If you use server side caching then you can chose the cached file else you have to figure it out yourself. And the RFC 2616 header specification says: An origin server MUST NOT send a Last-Modified date which is later than the server's time of message origination. In such cases, where the resource's last modification would indicate some time in the future, the server MUST replace that date with the message origination date. So do not send a future date! On Tue, Jul 22, 2008 at 2:11 PM, Rahul S. Johari [EMAIL PROTECTED] wrote: I tried with just the first three header() statements you gave, but it didn't work. Let me try the modification date ... which file is being referred to in $ffile? Also, I'm using Firefox, if it's of any consequence. Thanks! On Jul 22, 2008, at 7:30 AM, Bernhard Kohl wrote: I'm pretty sure this is a cache issue .. To disable caching: header('Cache-Control: no-cache, no-store, max-age=0, must- revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Pragma: no-cache'); But if you have the modification date then use $time = filemtime($ffile); header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT'); On Tue, Jul 22, 2008 at 1:14 PM, Rahul S. Johari [EMAIL PROTECTED] wrote: Ave, I'm wondering if there's a PHP solution to this, I could be in the wrong place. I have an INSERT form which submits to the same php page, which also displays the records from the mySQL database the INSERT form submits to. When the form submits and the page returns, the added record does not show up unless you Refresh the page. I'm imagining even after form submit, the Browser is caching the data and displaying data from the Cache. Is there a solution to this? Is there anything PHP can do to instruct the browser not the cache the data? Thanks! --- Rahul Sitaram Johari Founder, Internet Architects Group, Inc. [Email] [EMAIL PROTECTED] [Web] http://www.rahulsjohari.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Rahul Sitaram Johari Founder, Internet Architects Group, Inc. [Email] [EMAIL PROTECTED] [Web] http://www.rahulsjohari.com --- Rahul Sitaram Johari Founder, Internet Architects Group, Inc. [Email] [EMAIL PROTECTED] [Web] http://www.rahulsjohari.com -- Thiago Henrique Pojda --- Rahul Sitaram Johari Founder, Internet Architects Group, Inc. [Email] [EMAIL PROTECTED] [Web]
Re: [PHP] After INSERT form submit - Data doesn't refresh!
Quoting Rahul S. Johari [EMAIL PROTECTED]: No, actually the flow of the program does not work in that order. The flow of the program is in this order: My response was just to fast. Should have read all. At least the order is clear now :) - INSERT row function - INSERT HTML FORM - SELECT function to display records Technically the point at which the SELECT statement is executed and pulls records from the mySQL database - the newly inserted row is ALREADY there, so it really shouldn't have any problems displaying the new row. So if you do a print_r() on the result. It shows the updated record set? I know a couple of you are asking for the code, but quite honestly the codes are very, very simple INSERT, SELECT sql quries along with a simple HTML form. I don't think the actual SQL quries embedded in the page will really resolve the problem or help anyone in diagnosing this. I can post them - but I think like Thijs requested - the order would probably have been more important. Indeed the order is important. But a bit of code never hurts. Or a URL to check the output. The page begins with: ?php if($insertSubmit) { $query = INSERT INTO . .. execute query ... } ? somewhere after that is the HTML Form that the user can fill in somewhere after that ?php $query = SELECT * FROM tbl . .. execute query ... echo all records } ? So honestly I don't think it's this code that makes the difference. I still believe this is a browser cache issue. I could be wrong though. On Jul 22, 2008, at 9:08 AM, Thijs Lensselink wrote: Quoting Rahul S. Johari [EMAIL PROTECTED]: Here's what it is: I have a php page, a.php, which contains these three things: - SELECT statement to display records from a mySQL Table - HTML Form for inserting data into the mySQL Table - INSERT statement to insert that row into the mySQL Table If the flow of you program really works in this order. Then i can understand you are looking at the same records after a INSERT. The SELECT query is run before the INSERT. So if you submit your INSERT form. The page first selects a record set from the database. And after that preforms the INSERT. The HTML Form submits to the same, a.php Once the user submits the Form, a.php is called which INSERT's the row into the mySQL Table. However, the row does not appear in the SELECT statement table data unless I hit refresh on the page. (The INSERT function is executed before the SELECT in the page). I used the header() code that was suggested: header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Pragma: no-cache'); $ffile = 'a.php'; $time = filemtime($ffile); header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT'); .. but it didn't help. Everything is working fine except that the Browser is more then likely caching the data and thus not allowing the newly inserted row to appear on top when the SELECT is executed. On Jul 22, 2008, at 8:34 AM, Thiago H. Pojda wrote: Code, please? :) On Tue, Jul 22, 2008 at 9:33 AM, Rahul S. Johari [EMAIL PROTECTED] wrote: Hmm, interesting. In my case, $file does indeed output dynamic data. I did try with the modified time but it still doesn't work. I still have to hit refresh on the browser, after submitting the form, in order for the inserted record to appear. Not sure what to do - it's rather annoying. Novice users of the page would assume the entry didn't get inserted or something happened. One alternate is to submit Data to a different page and let that page redirect to the Original page - but I do find it hard to believe that there is no solution to this caching. Thanks guys! On Jul 22, 2008, at 8:26 AM, Yeti wrote: The Last-Modified header tells the browser when the requested page was last modified. Now I don't know how you get the date in your case but here is an example: browser requests /test/test.php which is a simple php file without any includes etc. in this case $file = '/test/test.php'; This wont work if $file outputs dynamic data, so only use it if the content only changes when you change the file. Now if you are using templates etc. obtaining the Last-Modified time is a bit more complicated. If you use server side caching then you can chose the cached file else you have to figure it out yourself. And the RFC 2616 header specification says: An origin server MUST NOT send a Last-Modified date which is later than the server's time of message origination. In such cases, where the resource's last modification would indicate some time in the future, the server MUST replace that date with the message origination date. So do not send a future date! On Tue, Jul 22, 2008 at 2:11 PM, Rahul S. Johari [EMAIL PROTECTED] wrote: I tried with just the first three header() statements you gave
Re: [PHP] How can i get the location of an exit()/die() from within register_shutdown_function()?
Quoting Mathijs van Veluw [EMAIL PROTECTED]: Hello there, I have an shutdown function to catch fatal-errors etc.. Now when there is an exit() somewhere i get an empty message from get_last_error(). I want to know the location of this exit() or die(). Is there a way to get the file and line-number from where the exit/die originated? Thx in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I don't think this is possible in PHP. When exit(0); is called. PHP execution stops. In the manual there is a small comment about exit inside a register_shutdown_function [snip] Multiple calls to register_shutdown_function() can be made, and each will be called in the same order as they were registered. If you call exit() within one registered shutdown function, processing will stop completely and no other registered shutdown functions will be called. [/snip] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Login without cookies enabled help
Quoting Shelley [EMAIL PROTECTED]: Hi all, What is your way to organize user login without Client Cookies being disabled? Sample code will be appreciated. Waiting for your reply... -- Regards, Shelley You can use sessions to store data on the server instead of the client. http://nl2.php.net/manual/en/ref.session.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] REALLY NEWB QUESTION - include issue
Quoting TS [EMAIL PROTECTED]: Code segment? Exact error message? (Is there more context?) Include (/file); Function.include/a]: open_basedir restriction in effect. File(/var/www/vhosts/domain/httpdocs/file.php) is not within the allowed path(s): (/var/www/vhosts/differentdomain/httpdocs:/tmp) in /var/www/vhosts/samedifferentdomain/httpdocs/custom-template.php on line 151 It's my server and it makes perfect security sense because the package I'm using allows me to resell but, I don't care about that particular security issue since I'm not reselling. I'm assuming it's something in php.ini. It's a linux machine. I'm not sure what else there is to tell. Thanks, T -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 01, 2008 1:08 AM To: TS Subject: RE: [PHP] REALLY NEWB QUESTION - include issue Code segment? Exact error message? (Is there more context?) I probably don't have the answer to answer you, but make like a little easier for those who might by giving them some information to work with. David -- Original Message -- From: TS [EMAIL PROTECTED] To: php-general@lists.php.net Date: Tue, 1 Jul 2008 00:50:50 -0600 Subject: [PHP] REALLY NEWB QUESTION - include issue Trying to include() a script from another domain on my server and it won't let me do it. I'm getting this error. open_basedir restriction in effect. Operation not permitted etc... Please help and stop laughing at me. Thanks ahead, T Looks like your hosting is blocking files included outside of the webroot. If you have root access you could change this. If you wanted to. But security is not a bad thing :) To allow opening of remote url's you can enable 'allow_url_fopen' in php.ini. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple array problem
Quoting Brian Dunning [EMAIL PROTECTED]: I'm trying to add a number to a value in an array. Pretend I have this: $new_value = array('orange', 2); $arr = array( array('blue', 4), array('orange', 5), array('green', 6)); I want to add the new value to the existing matching array element, so I end up with this: $arr = array( array('blue', 4), array('orange', 7), array('green', 6)); Seems like it should be really simple but all the ways I can figure out to do it are too kludgey. Just loop through the array to update. And use in_array to check if the key to update exists. Then you can do $array[$key][1] = $newValue. Something like this maybe: function updateArray($array, $update) { list($updateKey, $updateValue) = $update; foreach ($array as $key = $subArray) { if (in_array($updateKey, $subArray)) { $array[$key][1] = $updateValue; } } } updateArray($arr, $new_value); var_dump($arr); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: FW: [PHP] REALLY NEWB QUESTION - include issue
Quoting TS [EMAIL PROTECTED]: To allow opening of remote url's you can enable 'allow_url_fopen' in php.ini. This isn't a remote url though. It's a local path. Looking for something similar to crossdomain.xml file for Flash if anyone is familiar with that. Thanks, T -Original Message- From: Thijs Lensselink [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 01, 2008 1:58 AM To: php-general@lists.php.net Subject: RE: [PHP] REALLY NEWB QUESTION - include issue Quoting TS [EMAIL PROTECTED]: Code segment? Exact error message? (Is there more context?) Include (/file); Function.include/a]: open_basedir restriction in effect. File(/var/www/vhosts/domain/httpdocs/file.php) is not within the allowed path(s): (/var/www/vhosts/differentdomain/httpdocs:/tmp) in /var/www/vhosts/samedifferentdomain/httpdocs/custom-template.php on line 151 It's my server and it makes perfect security sense because the package I'm using allows me to resell but, I don't care about that particular security issue since I'm not reselling. I'm assuming it's something in php.ini. It's a linux machine. I'm not sure what else there is to tell. Thanks, T -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 01, 2008 1:08 AM To: TS Subject: RE: [PHP] REALLY NEWB QUESTION - include issue Code segment? Exact error message? (Is there more context?) I probably don't have the answer to answer you, but make like a little easier for those who might by giving them some information to work with. David -- Original Message -- From: TS [EMAIL PROTECTED] To: php-general@lists.php.net Date: Tue, 1 Jul 2008 00:50:50 -0600 Subject: [PHP] REALLY NEWB QUESTION - include issue Trying to include() a script from another domain on my server and it won't let me do it. I'm getting this error. open_basedir restriction in effect. Operation not permitted etc... Please help and stop laughing at me. Thanks ahead, T Looks like your hosting is blocking files included outside of the webroot. If you have root access you could change this. If you wanted to. But security is not a bad thing :) To allow opening of remote url's you can enable 'allow_url_fopen' in php.ini. In your first post you mentioned something about a remote domain. So i assumed you were including a remote page. But Chris already answered your question. Just add the paths so they are accessible. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] can you give me example of website using postgresql database?
Quoting paragasu [EMAIL PROTECTED]: i am planning to use postgresql for my next project (social network). anyone can point me any website using postgresql database? it will help me a lot.. thanks.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php RTFM and have fun. http://nl.php.net/manual/en/ref.pgsql.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unset and circular references
Quoting Abu Warez [EMAIL PROTECTED]: Hi, I'm using php 5.2.1 on an Ubuntu machine. I have the following class diagram (observer pattern): +-+ +-+ +-+ | class A |#-| class B | -| interface C | | | +-+ | | | |---|| | +-+ +-+ in my case class A, the creator of class B, is also the class to observe for class B. The following code implements the above diagram: ?php interface C { } class B { var $m_ObsC; public function __construct( C $p_ObsC ) { $this-m_ObsC = $p_ObsC; } public function __destruct() { echo B::destruct called br; } } class A implements C { var $m_b; public function __construct() { $this-m_b = new B( $this ); } public function __destruct() { echo A::destruct called br; } } $a = new A(); unset( $a ); echo br-end-of-scriptbr; ? the output of the above code is: -end-of-script A::destruct called B::destruct called So actually the memory used by object $a is freed only after the script ends and NOT when unset was called. Now this is a big problem for me, because i need to free the memory when I call unset and not after the script ends else php runs out of memory in my real application. Object $a is not referenced by any other object. I also tried with: $this-m_b = new B( $this ); but the result is the same. Any clue how to determine php tho free the memory when unset is called and not after the script ends? Thanks, Abu I think this happens because there is still a reference to the B object. According to the manual : The destructor method will be called as soon as all references to a particular object are removed or when the object is explicitly destroyed or in any order in shutdown sequence. So as long as A has a reference to B the __destructor will not be called. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables in forms
Quoting Ron Piggott [EMAIL PROTECTED]: Jim what you sent is very helpful. I had an error message when I submitted the form with a POST your_cleaning_function gave me this error: Fatal error: Call to undefined function: your_cleaning_function() I am trying to save the ones that were checked to a mySQL table and then notify the user the database was updated. The first thing that happens is the code you gave me below. How do I resolve this error? I get the concept of functions, but this isn't an area of PHP that I have used before. Ron On Sun, 2008-06-22 at 23:40 -0700, Jim Lucas wrote: Ron Piggott wrote: I am writing a form right now. I would like to make the checkbox an array variable. The first part of the array is the component reference, the second part is the package reference. What name would you assign to it that I could use in processing the form in the PHP script this posts to? Ron tr td valign=topfont face=times new romancenterChildren's Activities/center/td td valign=topfont face=times new romancenterChild's ABC's/center/td tdcenterinput type=checkbox name=component_1_package_1/center/td tdcenterinput type=checkbox name=component_1_package_2/center/td /tr In your form, do this input type=checkbox name=components[1][1] input type=checkbox name=components[1][2] Then in PHP do this. This is if the form was sent via POST ?php $components = your_cleaning_function($_POST['components']); foreach ( $components AS $component_id = $packages ) { foreach ( $packages AS $package_id = $value ) { // At this point, the only way you would get here is if // a person was to place a check mark in the check box // So, one would assume that this component/package // combo was infact checked. } } ? The function your_cleaning_function is no native PHP function. Jim just added it to show that you need to filter input data. To test the script just remove the function call completely. But remember when you put this in production. You want some sort of input filtering. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Runs But Does Not Display on Linux
Quoting Wei, Alice J. [EMAIL PROTECTED]: Hello, I have reinstalled Apache back into my Linux machine, and placed the code html headtitleTest/title body pThis is test/p ?php echo Hello!; ? /body /html into the apache/htdocs folder titled hello.php When I execute it from the browser using an http:// address followed by the IP address and hello.php, I get this pop up message that asks me if I wanted to open up my file and what I want to do with it. Is it necessary for me to install anything else? I have added the AddType application/x-httpd-php .php into the httpd.conf file, so now it is not giving me file does not exist error anymore, but how do I get thie accurate output to show up from the browser? I welcome any suggestion. Alice == Alice Wei MIS 2009 School of Library and Information Science Indiana University Bloomington [EMAIL PROTECTED] From: DeadTOm [EMAIL PROTECTED] Sent: Wednesday, June 11, 2008 11:15 PM To: Wei, Alice J. Cc: php-general@lists.php.net Subject: Re: [PHP] PHP Runs But Does Not Display on Linux With localhost I was assuming that the files resided on your local machine, my bad. How are you accessing these files? The location you are getting them from has to be running a web server of some kind with php or the php scripts will not run and you'll only see the html output as you described. I run a linux server with apache2, php and mysql and I believe that the purpose of the php5-mysql package is to add files that define those mysql function calls. I'm sure that there is something similar for mssql. -Allen Wei, Alice J. wrote: Hi, -Original Message- From: DeadTOm [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 11, 2008 10:58 PM To: Wei, Alice J. Cc: php-general@lists.php.net Subject: Re: [PHP] PHP Runs But Does Not Display on Linux OK, I see now. When you open the script from your browser are you accessing it via a server like Http://localhost/some/file.php or are you just opening a php file on your hard drive? I'm guessing you're accessing it on the hard drive directly, which will not work since PHP scripts are executed server side. So you will need to install apache2 with php. As far as the mssql_connect error goes, the same rule applies. You need to have the proper php module installed to define for php what the mssql_connect function does, otherwise php doesn't know what it is and yells at you for not defining the function. -Allen Thanks for clarifying the first point, and that is probably why. As for the second point, according to http://us.php.net/manual/en/function.mssql-connect.php, isn't mssql_connect defined already as something internal within PHP? Or, am I missing something here? Plus, I connect this not to the localhost, but to a different Windows machine, so does this mean that I have to install it? One of the members on the list suggested something from http://www.freetds.org/, if this is something I have to install, I will definitely give it a shot. Alice Wei, Alice J. wrote: Hi, For testing purpose, I have something like html headtitleTest/title body pThis is test/p ?php echo Hello!; ? /body /html I see the following from the command prompt when I execute the above script: html headtitleTest/title body pThis is test/pHello /body /html On the browser, I only see: html headtitleTest/title body pThis is test/p /body /html I just realized that the mysql_connect error is a typo, I should have typed mssql_connect. I call this from a different machine, so I shouldn't get this kind of error even if I don't have it installed, right? Or, am I missing something here? Alice -Original Message- From: DeadTOm [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 11, 2008 10:46 PM To: Wei, Alice J. Cc: php-general@lists.php.net Subject: Re: [PHP] PHP Runs But Does Not Display on Linux Otherwise, it consistently gives me errors Call to undefined function: mysql_connect()If you're getting an error... If you're getting this error, there is a line of code in the php script that is trying to connect to a mysql database and the mysql extension for php is not installed. So php doesn't know this function is supposed to do hence, the undefined function error. I can only see the HTML code of the php functions I call within the code at the command output in text format, but I cannot see it on the browser. I'm a little confused about what you mean here. You shouldn't see any HTML code in your browser. Wei, Alice J. wrote: Hi, I have originally commented out all the MS SQL lines in the php.ini files so that it supports MS SQL, but that does not seem to work. MySQL? Since I am not using that to connect my PHP to, do I still need to install it? By the way, my Microsoft SQL server
Re: [PHP] NuSOAP assistance.
Quoting Dan Joseph [EMAIL PROTECTED]: Hi Everyone, This is kind of a follow up to my SOAP question on Friday. I have decided that NuSOAP is my quickest solution. I am having some issues though. Everything looks like I have it in place, but I must be doing something wrong since the WSDL won't work right. Wondering if someone could shed a light on this. http://new.vehicletransportusa.com/v2/services/URSQuoteServices.php http://new.vehicletransportusa.com/v2/services/URSQuoteServices.php?wsdl Here is the code: ?php require_once( lib/nusoap.php ); $NAMESPACE = 'Quotes'; $server = new soap_server; $server-configureWSDL('Quotes', $NAMESPACE); $server-wsdl-schemaTargetNamespace = $NAMESPACE; $server-wsdl-addComplexType( 'VehiclesArray', 'complexType', 'array', '', 'SOAP-ENC:Array', array(), array( array('ref'='SOAP-ENC:arrayType','wsdl:arrayType'='tns:Vehicles[]') ), 'tns:Vehicles' ); $server-wsdl-addComplexType( 'VehicleQuote', 'complexType', 'struct', 'all', '', array('id'= array( 'name'='id', 'type'='xsd:string' ), 'key'= array( 'name'='key', 'type'='xsd:string' ), 'firstname'= array( 'name'='firstname', 'type'='xsd:string' ), 'companyname'= array( 'name'='lastname', 'type'='xsd:string' ), 'dealername'= array( 'name'='companyname', 'type'='xsd:string' ), 'contact_address1'= array( 'name'='dealername', 'type'='xsd:string' ), 'contact_address1'= array( 'name'='contact_address1', 'type'='xsd:string' ), 'contact_address2'= array( 'name'='contact_address2', 'type'='xsd:string' ), 'contact_city'= array( 'name'='contact_city', 'type'='xsd:string' ), 'contact_state'= array( 'name'='contact_state', 'type'='xsd:string' ), 'contact_zip'= array( 'name'='contact_zip', 'type'='xsd:string' ), 'emailaddress'= array( 'name'='emailaddress', 'type'='xsd:string' ), 'phone'= array( 'name'='phone', 'type'='xsd:string' ), 'cellphone'= array( 'name'='cellphone', 'type'='xsd:string' ), 'fax'= array( 'name'='fax', 'type'='xsd:string' ), 'contactpref'= array( 'name'='contactpref', 'type'='xsd:string' ), 'referral'= array( 'name'='referral', 'type'='xsd:string' ), 'origin_contactname'= array( 'name'='origin_contactname', 'type'='xsd:string' ), 'origin_contactphone1'= array( 'name'='origin_contactphone1', 'type'='xsd:string' ), 'origin_contactphone2'= array( 'name'='origin_contactphone2', 'type'='xsd:string' ), 'origin_address1'= array( 'name'='origin_address1', 'type'='xsd:string' ), 'origin_address2'= array( 'name'='origin_address2', 'type'='xsd:string' ), 'origin_city'= array( 'name'='origin_city', 'type'='xsd:string' ), 'origin_state'= array( 'name'='origin_state', 'type'='xsd:string' ), 'origin_zip'= array( 'name'='origin_zip', 'type'='xsd:string' ), 'dest_contactname'= array( 'name'='dest_contactname', 'type'='xsd:string' ), 'dest_contactphone1'= array( 'name'='dest_contactphone1', 'type'='xsd:string' ), 'dest_contactphone2'= array( 'name'='dest_contactphone2', 'type'='xsd:string' ), 'dest_address1'= array( 'name'='dest_address1', 'type'='xsd:string' ), 'dest_address2'= array( 'name'='dest_address2', 'type'='xsd:string' ), 'dest_city'= array( 'name'='dest_city', 'type'='xsd:string' ), 'dest_state'= array( 'name'='dest_state', 'type'='xsd:string' ), 'dest_zip'= array( 'name'='dest_zip', 'type'='xsd:string' ), 'vin'= array( 'name'='vin', 'type'='xsd:string' ), 'year'= array( 'name'='year', 'type'='xsd:string' ), 'make'= array( 'name'='make', 'type'='xsd:string' ), 'model'= array( 'name'='model', 'type'='xsd:string' ), 'color'= array( 'name'='color', 'type'='xsd:string' ), 'vehicletype'= array( 'name'='vehicletype', 'type'='xsd:string' ), 'inop'= array( 'name'='inop', 'type'='xsd:string' ), 'buyer_id'= array( 'name'='buyer_id', 'type'='xsd:string' ), 'item_id'= array( 'name'='item_id', 'type'='xsd:string' ), 'engine_size'= array( 'name'='engine_size', 'type'='xsd:string' ), 'modified'= array( 'name'='modified', 'type'='xsd:string' ), 'enclosed_carrier'= array( 'name'='enclosed_carrier', 'type'='xsd:string' ), 'pickupdate'= array( 'name'='pickupdate', 'type'='xsd:string' ), 'latestpickupdate'= array( 'name'='latestpickupdate', 'type'='xsd:string' ), 'quote_type'= array( 'name'='quote_type', 'type'='xsd:string' ), 'savequote'= array( 'name'='savequote', 'type'='xsd:string' ), ) ); $server-register( 'getQuote', array( 'id'='xsd:string' ), array( 'key'='xsd:string' ), array(
Re: [PHP] imap_open() error. (Can't open mailbox)
Quoting Mathijs van Veluw [EMAIL PROTECTED]: Hello there, i use imap to read incoming mail from the the SMTP server. On the live server everythings works as it should. I can use imap_open('/path/to/file', '', ''), to read just one raw-mail. On my test env i can't get this to work. I get the error message: Can't open mailbox. While on the live server it works and i get the correct resource resource(42) of type (imap). I realy don't know what the problem is. Can someone help me with this? Thanks in advance. Mathijs. I didn't work with IMAP much. So one suggestion could be to check if your dev box is behind a proxy server. If you're using SSL check if it's enabled on your dev box. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] imap_open() error. (Can't open mailbox)
Quoting Mathijs van Veluw [EMAIL PROTECTED]: Thijs Lensselink wrote: Quoting Mathijs van Veluw [EMAIL PROTECTED]: Hello there, i use imap to read incoming mail from the the SMTP server. On the live server everythings works as it should. I can use imap_open('/path/to/file', '', ''), to read just one raw-mail. On my test env i can't get this to work. I get the error message: Can't open mailbox. While on the live server it works and i get the correct resource resource(42) of type (imap). I realy don't know what the problem is. Can someone help me with this? Thanks in advance. Mathijs. I didn't work with IMAP much. So one suggestion could be to check if your dev box is behind a proxy server. If you're using SSL check if it's enabled on your dev box. the imap_open() only gets a file location. This file containts a raw-mail, so no need for ssl or proxy stuff etc.. It doesn't give a file location. it creates a resource. This resource you can use to retrieve the data. SSL is no option like you said. I would at least check the proxy. I'm behind a proxy here also. And for remote communication i use a proxy class. Maybe somebody else on the list can point you in the right direction. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Avoid object twice
Quoting Yui Hiroaki [EMAIL PROTECTED]: Thank you for your advice me! -My.php--- ?php Class My{ private $word; function __construct($getword){ $this-word=$getword; } public function buff(){ mail([EMAIL PROTECTED],test,test); } } ? -- --b.php ?php function __autoload($class_name) { include_once $class_name . '.php'; } $objref=new My(Good); $objref-buff(); ? --c.php-- ?php function __autoload($class_name) { include_once $class_name . '.php'; } $obj=new My(Hello); $obj-buff(); -- That is what I want to try. When c.php run, Mail() function run // it is OK When b.php run, it also run Mail() fuction. // it is NOT OK I would like to run Mail() function one time only from c.php. However I also get prameter which declare Good in b.php Now when c.php and b.php run, the program send twice email. That is not good!! I would like to run c.php and b.php, then the program, which is Mail() function, get one email and get Good from b.php Regards, Yui You could add a parameter to the buff() method. Class My{ private $word; function __construct($getword){ $this-word=$getword; } public function buff($sendMail = false){ if ($sendMail) { mail([EMAIL PROTECTED],test,test); } } } When executing b.php pass true too the buff() method to send an email. --b.php ?php function __autoload($class_name) { include_once $class_name . '.php'; } $objref=new My(Good); $objref-buff(true); ? When executing c.php don't pass a parameter to the buff() method. So it defaults to false. And will not send an email. --c.php-- ?php function __autoload($class_name) { include_once $class_name . '.php'; } $obj=new My(Hello); $obj-buff(); -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Avoid object twice
Quoting Yui Hiroaki [EMAIL PROTECTED]: My problem is that I would like to share the parameter. For instance, goolge map key. There are actually two files. example, main.php ?php $googlemapkey=g8ejeUFEUHEU;// example mail([EMAIL PROTECTED],test.test); ? Above is part of code; I will excute main.php program. then other.php run But when other.php run, other.php requre $googlemapkey. Of couse, I can get $googlemapkey if I use include or require. But if I use include or require, mail([EMAIL PROTECTED],test.test) run again. So this program send twice email. It is NOT GOOD. I juse send $googlemapkey from mail.php to other.php Please advice if you have any solution. Regards, Yui 2008/6/4 Boyd, Todd M. [EMAIL PROTECTED]: I knew it . But Hello and Good is different file. I would like to get Good from b.php. Please tell me goo advice. Yui 2008/6/4 Boyd, Todd M. [EMAIL PROTECTED]: Thank you for your advice me! -My.php--- ?php Class My{ private $word; function __construct($getword){ $this-word=$getword; } public function buff(){ mail([EMAIL PROTECTED],test,test); } } ? -- --b.php ?php function __autoload($class_name) { include_once $class_name . '.php'; } $objref=new My(Good); $objref-buff(); ? --c.php-- ?php function __autoload($class_name) { include_once $class_name . '.php'; } $obj=new My(Hello); $obj-buff(); -- That is what I want to try. When c.php run, Mail() function run // it is OK When b.php run, it also run Mail() fuction. // it is NOT OK I would like to run Mail() function one time only from c.php. However I also get prameter which declare Good in b.php Now when c.php and b.php run, the program send twice email. That is not good!! I would like to run c.php and b.php, then the program, which is Mail() function, get one email and get Good from b.php You are not making any sense... if you only want the Mail() function to run once, then ONLY CALL -BUFF() ONE TIME. It's that simple. You are mailing twice because you call buff() in two separate places--and buff() in turn calls Mail(). I don't understand your problem. $objref = new My(Good); $obj = new My(Hello); $obj-buff(); Bam. You get Hello, Good, and it sends one e-mail. Since you are completely abstracting your code from its real-world application, that's the best I can do. I still don't get it. Please explain to me WHY this is not a solution to your problem? === My.php === ?php Class My{ private $word; function __construct($getword){ $this-word=$getword; } public function buff(){ mail([EMAIL PROTECTED],test,test); } } ? === b.php === ?php function __autoload($class_name) { include_once $class_name . '.php'; } $objref=new My(Good); // $objref-buff(); NOTICE HOW THIS IS COMMENTED OUT!!! ? === c.php === ?php function __autoload($class_name) { include_once $class_name . '.php'; } $obj=new My(Hello); $obj-buff(); // MAIL() IS EXECUTED HERE ? If that doesn't work, then here are my questions: 1.) What on earth are you ACTUALLY trying to do? 2.) Does -buff() NEED to be called for each instance of My()? 3.) Are you wanting multiple instances of this class to share data? 4.) If (3), then are you familiar with the STATIC property? Todd Boyd Web Programmer I think you are making it way to complicated for yourself. So you really just need to share settings between files. That's exactly what include / require are for. settings.php ?php $googlemapkey = g8ejeUFEUHEU;// example function sendMail() { mail([EMAIL PROTECTED],test.test); } ? Here you include settings.php and are able to use the mapkey variable. If you want to send an email just call sendMail(); other.php ?php include settings.php; // use your google API key any way you want sendMail(); // sends mail ? If you don't need the sendMail(); function. then don't call it. other2.php ?php include settings.php; // use your google API key any way you want ? I think that's about as clear as i can make it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] slowness mystery
Quoting Rene Veerman [EMAIL PROTECTED]: Using a statis .js file costs 3.54 seconds. Should i suspect apache now? You could try running the php script from the command line. And see how long it takes. Just to make sure if it's apache or PHP. Profiling the script will also help tracking down the bottleneck. Give xdebug a try : http://xdebug.org/docs/profiler -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Avoid object twice
Quoting Yui Hiroaki [EMAIL PROTECTED]: Thank you for a good suggest! Somehow, I have to execute my.php also. This program have to run. 1)My.php 2)b.php My.php show Hello - it is OK, b.php shows Hello Good it is NOT good. I need to get only Good Please give me a suggestion. Regards, Yui 2008/6/3 James Dempster [EMAIL PROTECTED]: I suggest you don't put code other than class structures in class files. Also don't execute My.php just execute b.php which though __autoload includes My.php. -b.php ?php function __autoload($class_name) { include_once $class_name . '.php'; } $obj=new My(Hello); $obj-buff(); $objref=new My(Good); $objref-buff(); --- --My.php-- ?php Class My{ private $word; function __construct($getword){ $this-word=$getword; } public function buff(){ echo $this-word.br /; } } /James Dempster On Tue, Jun 3, 2008 at 9:17 AM, Yui Hiroaki [EMAIL PROTECTED] wrote: HI! I had mistake in code in php. When I excute My.php, it say Hello When I excute b.php, it say Hello Good I would like to execute b.php and show only Good If you know it ,please teach me! Here is code below; -b.php ?php function __autoload($class_name) { include_once $class_name . '.php'; } $objref=new My(Good); $objref-buff(); ? --- --My.php-- ?php $obj=new My(Hello); $obj-buff(); Class My{ private $word; function __construct($getword){ $this-word=$getword; } public function buff(){ echo $this-word.br /; } } ? -- Regards, Yui 2008/6/3 James Dempster [EMAIL PROTECTED]: I don't see how it's possible for you to get Hello after Good, when the file that cause's Hello is required to do Good /James On Mon, Jun 2, 2008 at 2:00 PM, Yui Hiroaki [EMAIL PROTECTED] wrote: Please take a look at code. a.php $obj=new my(Hello); $obj-buff(); Class my{ private $word; function __construct($getword){ $this-word=$getword; } public function buff(){ echo $this-word.br /; } -- -b.php--- function __autoload($class_name) { include_once $class_name . '.php'; } $objref=new my(Good); $objref-buff(); I get an Echo; Good Hello Hello I do not need to get Hello twice. When I b.php , $obj=new my(Hello) is loaded. Do you have any adia to avoid load $obj in a.php twice? Regards, Yui -- 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 If you only want to see Good Then don't run it twice. Take James's suggestion and try it again: -b.php ?php function __autoload($class_name) { include_once $class_name . '.php'; } $objref=new My(Good); $objref-buff(); --- --My.php-- ?php Class My{ private $word; function __construct($getword){ $this-word=$getword; } public function buff(){ echo $this-word.br /; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Avoid object twice
Quoting Yui Hiroaki [EMAIL PROTECTED]: Please look at my.php my.php load $obj=new My(Hello); $obj-buff(); so, if a.php load, it absolutely got hello in load b.php Regards, Yui 2008/6/3 Thijs Lensselink [EMAIL PROTECTED]: Quoting Yui Hiroaki [EMAIL PROTECTED]: Thank you for a good suggest! Somehow, I have to execute my.php also. This program have to run. 1)My.php 2)b.php My.php show Hello - it is OK, b.php shows Hello Good it is NOT good. I need to get only Good Please give me a suggestion. Regards, Yui 2008/6/3 James Dempster [EMAIL PROTECTED]: I suggest you don't put code other than class structures in class files. Also don't execute My.php just execute b.php which though __autoload includes My.php. -b.php ?php function __autoload($class_name) { include_once $class_name . '.php'; } $obj=new My(Hello); $obj-buff(); $objref=new My(Good); $objref-buff(); --- --My.php-- ?php Class My{ private $word; function __construct($getword){ $this-word=$getword; } public function buff(){ echo $this-word.br /; } } /James Dempster On Tue, Jun 3, 2008 at 9:17 AM, Yui Hiroaki [EMAIL PROTECTED] wrote: HI! I had mistake in code in php. When I excute My.php, it say Hello When I excute b.php, it say Hello Good I would like to execute b.php and show only Good If you know it ,please teach me! Here is code below; -b.php ?php function __autoload($class_name) { include_once $class_name . '.php'; } $objref=new My(Good); $objref-buff(); ? --- --My.php-- ?php $obj=new My(Hello); $obj-buff(); Class My{ private $word; function __construct($getword){ $this-word=$getword; } public function buff(){ echo $this-word.br /; } } ? -- Regards, Yui 2008/6/3 James Dempster [EMAIL PROTECTED]: I don't see how it's possible for you to get Hello after Good, when the file that cause's Hello is required to do Good /James On Mon, Jun 2, 2008 at 2:00 PM, Yui Hiroaki [EMAIL PROTECTED] wrote: Please take a look at code. a.php $obj=new my(Hello); $obj-buff(); Class my{ private $word; function __construct($getword){ $this-word=$getword; } public function buff(){ echo $this-word.br /; } -- -b.php--- function __autoload($class_name) { include_once $class_name . '.php'; } $objref=new my(Good); $objref-buff(); I get an Echo; Good Hello Hello I do not need to get Hello twice. When I b.php , $obj=new my(Hello) is loaded. Do you have any adia to avoid load $obj in a.php twice? Regards, Yui -- 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 If you only want to see Good Then don't run it twice. Take James's suggestion and try it again: -b.php ?php function __autoload($class_name) { include_once $class_name . '.php'; } $objref=new My(Good); $objref-buff(); --- --My.php-- ?php Class My{ private $word; function __construct($getword){ $this-word=$getword; } public function buff(){ echo $this-word.br /; } } I don't think i understand you fully. Or you're trying to make it to complicated. You have a class in My.php : Class My{ private $word; function __construct($getword){ $this-word=$getword; } public function buff(){ echo $this-word.br /; } } And a script that creates an instance of My b.php : function __autoload($class_name) { include_once $class_name . '.php'; } $obj=new My(Hello); $obj-buff(); $objref=new My(Good); $objref-buff(); The output will be Hellobr/Goodbr/. because you call it two times. So if you only want to see Good. Then you change b.php to look like this: function __autoload($class_name) { include_once $class_name . '.php'; } $objref=new My(Good); $objref-buff(); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Code I Must find
Quoting John Taylor-Johnston [EMAIL PROTECTED]: Seen that in the manual. I'll need a routine of some sort I guess. I'll get my cookie cutters out tomorrow and see what I can create. I make cool gingerbread men, for a dude. **htmlentities() does most of what I want, sort of. **lists-php wrote: you might try looking at the php manual. start with: http://www.php.net/manual/en/function.ord.php and go from there. ?php $mystring = [EMAIL PROTECTED]; # How can I generate $mystring in ascii characters? echo ($mystring in ascii charachters); ? lists-php wrote: that's not UTF, rather just the html representation of the ascii codes for the characters. [someone else has already pointed you to an ascii table.] when put in the context of the mailto:; it's actually fairly easy for a bot to identify and decode (i'm not saying that they do, but it's not hard). if you're going to use this approach you may want to make the e-mail addresses user-readable, but unlinked. while still easily decoded, most bots won't waste time trying to decode every string like that that they encounter (at least not yet). - Rick Original Message Date: Thursday, May 29, 2008 07:08:34 PM -0400 From: John Taylor-Johnston [EMAIL PROTECTED] To: PHP-General php-general@lists.php.net Subject: [PHP] PHP Code I Must find A web site deploys what I think are UTF characters to mask email addresses. Is there there a php function I can use to generate this? Or was this hand-done? It is crackable, but a darned good stab at the problem of spiders at the same. Any feedback, info or code would be appreciated, John John Taylor-Johnston wrote: My source is this page: http://www.grandlodge.mb.ca/contact.html John /div align=centerTo report a technical problem with this site please a href=mailto:#119;#101;#098;#109;#097;#115;#116;#101;# 11 4;#064;#103;#114;#097;#110;#100;#108;#111;#100;#103; #1 01;#046;#109;#098;#046;#099;#097;contact the webmaster/a./div/ /In UTF code: mailto:#119;#101;#098;#109;#097;#115;#116;#101;#114;# 06 4;#103;#114;#097;#110;#100;#108;#111;#100;#103;#101; #0 46;#109;#098;#046;#099;#097; would be this in latin characters: mailto:[EMAIL PROTECTED]/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- End Original Message -- -- End Original Message -- -- You could do something like this (knowing the strings are pure ascii) function ascToEnt($string) { $char = ''; $strLength = strlen($string); for ($x = 0; $x $strLength; $x++) { $char .= '#' . ord($string{$x}) . ';'; } return $char; } echo ascToEnt('[EMAIL PROTECTED]'); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] validating textarea using php
Quoting Sudhakar [EMAIL PROTECTED]: hi i need to validate textarea of a html form using php textarea name=comments cols=26 rows=3 id=comments?php echo($comments);?/textarea presently my php code to validate the text area is if($comments == ) { $error.=brPlease enter your comments; } with this code if a user hits the space bar once or couple of times as a matter of fact there are no characters entered by the user i do not want this to happen, if a user simply hits the spacebar and does not type anything i should be able to display an alert message. please advice how i can change the above php code. PHP is sevrer sided. So if you want to check if a user provided the textarea with input. You have to submit the page. and let PHP do the magic. If the textarea is not filled. You could send the user back to the form. With an apropriat warning message. It's probably easier to do it with client side javascript. Check the contents of the textarea on submit and preform some actions from there. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] AI file and mapping with PHP
Quoting Angelo Zanetti [EMAIL PROTECTED]: Hi Guys, We have a project where by we have a map in ai format (vector format). What we want to do is to programmatically come up with a solution that say on the map there is a restaurant at a certain location, that we can zoom into the map on that specific area. I really am not sure where to start. I guess image maps arent going to work are they? Should I be using the GD library for manipulating the images and doing zooming? Also will the ai format be supported? Please guys, any tips, links or help is appreciated. TIA Angelo I think doing something like this with GD is nearly impossible. But you could import the vector image in flash/flex. Draw an invisible grid over it to create some sort of long / lat coordinats. Or maybe just move to the google / yahoo map API's. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP debugger
Quoting Daniel Brown [EMAIL PROTECTED]: On Mon, Apr 28, 2008 at 7:00 AM, J. Manuel Velasco - UBILIBET [EMAIL PROTECTED] wrote: Hello, Anybody knows a good debugger for PHP and basic usage? There's a pretty good one known as Jason Pruim. ;-P ROFL! -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- 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] AJAX and PHP
Quoting Alain Roger [EMAIL PROTECTED]: Hi, i'm playing around with AJAX and PHP to create something like a small desktop application. basically the first step is to log in the system. for that i have a log-in form where users can choose the interface language. here is my problem : when the log-in form runs, it is in English. user can click on some arrow to open another DIV and display all other languages available. a click on a particular flag, will call the PHP page where the log-in form (login field + password field) are stored with dynamic language interface. however, i make no sense for the title of this form to call a PHP page where will be just 1 dynamic text (changing on flag choice). so if you understand well, i have 2 divs (1 for form title, 1 for log-in form itself). and i load thanks AJAX php code into divs. my problem is that i do not want to write a PHP page just for 1 label... it makes sense for a complete form but not for a simple text line or label. So how can i do that without refreshing page. using AJAX and PHP only ? i guess you already faced such situation so i would really appreciate your help. thanks a lot, -- Alain Making an Ajax request for one little label maybe a bit overkill. As i understand you request the whole form through an Ajax request. And display this to the user? And every language generates a new form? Why not just create the form dynamically with javascript and load the data from PHP. So the form can stay the same for all calls. You just fill it with data depending on the language selected. You can fill the form for instance by sending a JSON encoded object from PHP to javascript. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] AJAX and PHP
Quoting Alain Roger [EMAIL PROTECTED]: in fact i meant by redirecting the following thing : - if user wrote a correct pwd and login, the system should redirect [using header(Location ] syntax to launch the application. but if i use such syntax it will be redirected only into the div#0, and not in the browser itslef. is it clearer now ? It's crystal clear :) I guess you could do it in two ways. Firstly without a redirect. You could just use javascript and CSS to show some sort of error message. Reload the form in the div. And give the user another try to login. If you really want a reload. You have to do it with javascript. You could let PHP send back a status to javascript. And based on that. Either load a div with content. Or do a document.location = ''; Hope it helps. On Mon, Apr 21, 2008 at 11:40 AM, Thijs Lensselink [EMAIL PROTECTED] wrote: Quoting Alain Roger [EMAIL PROTECTED]: you understood right. basically my problem is that the layout avoid it. here is something like my layout : div#0 div#1Lanague (label) : img flag img arrow to show all languages from div#2/div#1 div#2 all flags/div#2 div#3 login field + pwd field + submit button/div#3 /div#0 till now i only use AJAX to refresh the content of div#3 but it does not change the label from div#1 when user selects another language from div#2. Well it looks like you need a extra Ajax call to the server. Click a language flag sends a request to the server. The server responds with an JSON object. Containing the content for div#2. With javascript you can update the contents of div#2 if i place the whole form into a PHP i face several questions : - how the ajax will reload this PHP page (reloading itself) in the parent control div#0 ? If you would like to reload the whole of div#0 You could send and JSON object from PHP to javascript. And let javascript generate the div structure and update the DOM. - when user will click on submit button, where will be loaded the content return of checking if log+pwd are correct ? When a user logs in a Ajax request is send to the server. the server responds with an JSON object containing the error message. With javascript you could update the contents of div#3 to display a message. - how to redirect to another PHP page, when user click on submit button ? the redirection will happen only in the content div, so only in div#0 and not into the browser :-( I have a hard time understanding this last issue. What exactly do you mean by redirecting to another PHP page? Al. On Mon, Apr 21, 2008 at 9:55 AM, Thijs Lensselink [EMAIL PROTECTED] wrote: Quoting Alain Roger [EMAIL PROTECTED]: Hi, i'm playing around with AJAX and PHP to create something like a small desktop application. basically the first step is to log in the system. for that i have a log-in form where users can choose the interface language. here is my problem : when the log-in form runs, it is in English. user can click on some arrow to open another DIV and display all other languages available. a click on a particular flag, will call the PHP page where the log-in form (login field + password field) are stored with dynamic language interface. however, i make no sense for the title of this form to call a PHP page where will be just 1 dynamic text (changing on flag choice). so if you understand well, i have 2 divs (1 for form title, 1 for log-in form itself). and i load thanks AJAX php code into divs. my problem is that i do not want to write a PHP page just for 1 label... it makes sense for a complete form but not for a simple text line or label. So how can i do that without refreshing page. using AJAX and PHP only ? i guess you already faced such situation so i would really appreciate your help. thanks a lot, -- Alain Making an Ajax request for one little label maybe a bit overkill. As i understand you request the whole form through an Ajax request. And display this to the user? And every language generates a new form? Why not just create the form dynamically with javascript and load the data from PHP. So the form can stay the same for all calls. You just fill it with data depending on the language selected. You can fill the form for instance by sending a JSON encoded object from PHP to javascript. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Alain Windows XP SP2 PostgreSQL 8.2.4 / MS SQL server 2005 Apache 2.2.4 PHP 5.2.4 C# 2005-2008 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Alain Windows XP SP2 PostgreSQL 8.2.4 / MS SQL server 2005 Apache 2.2.4 PHP 5.2.4 C# 2005-2008 -- PHP General Mailing List (http
Re: [PHP] AJAX and PHP
Quoting Alain Roger [EMAIL PROTECTED]: you understood right. basically my problem is that the layout avoid it. here is something like my layout : div#0 div#1Lanague (label) : img flag img arrow to show all languages from div#2/div#1 div#2 all flags/div#2 div#3 login field + pwd field + submit button/div#3 /div#0 till now i only use AJAX to refresh the content of div#3 but it does not change the label from div#1 when user selects another language from div#2. Well it looks like you need a extra Ajax call to the server. Click a language flag sends a request to the server. The server responds with an JSON object. Containing the content for div#2. With javascript you can update the contents of div#2 if i place the whole form into a PHP i face several questions : - how the ajax will reload this PHP page (reloading itself) in the parent control div#0 ? If you would like to reload the whole of div#0 You could send and JSON object from PHP to javascript. And let javascript generate the div structure and update the DOM. - when user will click on submit button, where will be loaded the content return of checking if log+pwd are correct ? When a user logs in a Ajax request is send to the server. the server responds with an JSON object containing the error message. With javascript you could update the contents of div#3 to display a message. - how to redirect to another PHP page, when user click on submit button ? the redirection will happen only in the content div, so only in div#0 and not into the browser :-( I have a hard time understanding this last issue. What exactly do you mean by redirecting to another PHP page? Al. On Mon, Apr 21, 2008 at 9:55 AM, Thijs Lensselink [EMAIL PROTECTED] wrote: Quoting Alain Roger [EMAIL PROTECTED]: Hi, i'm playing around with AJAX and PHP to create something like a small desktop application. basically the first step is to log in the system. for that i have a log-in form where users can choose the interface language. here is my problem : when the log-in form runs, it is in English. user can click on some arrow to open another DIV and display all other languages available. a click on a particular flag, will call the PHP page where the log-in form (login field + password field) are stored with dynamic language interface. however, i make no sense for the title of this form to call a PHP page where will be just 1 dynamic text (changing on flag choice). so if you understand well, i have 2 divs (1 for form title, 1 for log-in form itself). and i load thanks AJAX php code into divs. my problem is that i do not want to write a PHP page just for 1 label... it makes sense for a complete form but not for a simple text line or label. So how can i do that without refreshing page. using AJAX and PHP only ? i guess you already faced such situation so i would really appreciate your help. thanks a lot, -- Alain Making an Ajax request for one little label maybe a bit overkill. As i understand you request the whole form through an Ajax request. And display this to the user? And every language generates a new form? Why not just create the form dynamically with javascript and load the data from PHP. So the form can stay the same for all calls. You just fill it with data depending on the language selected. You can fill the form for instance by sending a JSON encoded object from PHP to javascript. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Alain Windows XP SP2 PostgreSQL 8.2.4 / MS SQL server 2005 Apache 2.2.4 PHP 5.2.4 C# 2005-2008 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] function returns no value
Quoting Ali Reza Sajedi [EMAIL PROTECTED]: I added var_dump($result); to the function. As part of the output I get the following: [fields]= array(1) { [fa]= string(22) ورود به سایت} which is the string which should be returned and printed. The result is there, however, it couldn't be printed. Any ideas? Regards Ali - Original Message - From: Nathan Nobbe To: Ali Reza Sajedi Cc: php-general@lists.php.net Sent: Monday, April 21, 2008 12:42 AM Subject: Re: [PHP] function returns no value On Sun, Apr 20, 2008 at 4:51 PM, Ali Reza Sajedi [EMAIL PROTECTED] wrote: Hello, with the following call I try to print a string out of DB echo $allg-translate($db, $lang, 14, auth/authCallback, 4); function translate () should do a DB querry and returns the requested string. Although the querry yields a positive result, the function returns no value. Here is the function: function translate ($db, $lang, $MaiKey, $page, $pid) { $statement = SELECT fa FROM language WHERE MaiKey='$MaiKey' AND page='$page' AND pid='$pid'; $result = $db-Execute($statement); if ($result=== false) die(); return $result-fields[0]; Try $result-fields[fa] instead. } Could anybody see what is going wrong here? its hard to say, since we cant see whats going on inside the Execute function... you might try to add a var_dump($result); directly after the call to Execute, just for debugging purposes, then remove it once you know whats going on. -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP GD library installing
Quoting Luca Paolella [EMAIL PROTECTED]: How do I install/activate the GD library with my existing PHP version? I'm quite sure it isn't already, since I got this error: Fatal error: Call to undefined function imagecreate() in /Volumes/Data/Users/luca/Library/WebServer/Documents/reloadTest/image.php on line 6 Please forgive my ignorance, and thanks for your help On windows it's as easy as downloading the dll from pecl4win.php.net. But from your directory structure i presume you have some sort of *nix system. So you have to reconfigure and rebuild PHP. Add the following to the configure line. And rebuild PHP after that. Make sure GD is installed on the system. --with-gd --with-jpeg-dir --with-png-dir -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP GD library installing
Quoting Robin Vickery [EMAIL PROTECTED]: On 10/04/2008, Thijs Lensselink [EMAIL PROTECTED] wrote: Quoting Luca Paolella [EMAIL PROTECTED]: How do I install/activate the GD library with my existing PHP version? I'm quite sure it isn't already, since I got this error: Fatal error: Call to undefined function imagecreate() in /Volumes/Data/Users/luca/Library/WebServer/Documents/reloadTest/image.php on line 6 Please forgive my ignorance, and thanks for your help On windows it's as easy as downloading the dll from pecl4win.php.net. But from your directory structure i presume you have some sort of *nix system. So you have to reconfigure and rebuild PHP. Ouch... first try installing the php gd module through whatever package manager your *nix distribution uses. For instance, on Ubuntu linux you'd do: sudo aptitude install php5-gd Ouch? That's exactly what i added to my post Make sure GD is installed on the system. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP GD library installing
Quoting Robin Vickery [EMAIL PROTECTED]: On 10/04/2008, Thijs Lensselink [EMAIL PROTECTED] wrote: Quoting Robin Vickery [EMAIL PROTECTED]: On 10/04/2008, Thijs Lensselink [EMAIL PROTECTED] wrote: Quoting Luca Paolella [EMAIL PROTECTED]: How do I install/activate the GD library with my existing PHP version? I'm quite sure it isn't already, since I got this error: Fatal error: Call to undefined function imagecreate() in /Volumes/Data/Users/luca/Library/WebServer/Documents/reloadTest/image.php on line 6 Please forgive my ignorance, and thanks for your help On windows it's as easy as downloading the dll from pecl4win.php.net. But from your directory structure i presume you have some sort of *nix system. So you have to reconfigure and rebuild PHP. Ouch... first try installing the php gd module through whatever package manager your *nix distribution uses. For instance, on Ubuntu linux you'd do: sudo aptitude install php5-gd Ouch? That's exactly what i added to my post Make sure GD is installed on the system. Making sure GD is installed on the system is a very sensible thing to do. The ouch was aimed at the suggestion that if you're on a *nix system, the course of action is to recompile php. Normally these days you'd just install the gd module (the equivalent of your windows dll) through your package manager. My bad! :) I always compile everything from source -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: fwrite/fclose troubles
Quoting Dave Goodchild [EMAIL PROTECTED]: Why are you writing a logging class? Why not use error_log and enable error logging? Maybe he wants to log user actions in an application? Can log so much more then just errors. But the answer to this problem was already given. :) On Fri, Mar 21, 2008 at 1:11 PM, Al [EMAIL PROTECTED] wrote: int file_put_contents ( string $filename, mixed $data [, int $flags [, resource $context]] ) This function is identical to calling fopen(), fwrite() and fclose() successively to write data to a file. This native function does it for you Mark Weaver wrote: Hi all, I've been lurking and reading now for some time, but have decided to come out of the shadows cause I've got an issue that's gonna drive me crazy! I'm developing an application and within this application is a class that is very simple and only serves a singular purpose - to make log entries to help with debugging. Problem is, now I'm debugging the damned logging class that is supposed to be helping me debug the application as I'm putting it together! sigh I've looked and looked all over the place, but I don't seem to be able to find an answer to this problem. The only information that I have found so far deals with permissions and I don't think that's the problem. At first I was getting an access denied error but since setting dir perms and log file perms so that both apache and my user can right to both the directory and the file that one has gone away. Log Directory permissions: /mystuff/logs rwx-rwx-rwx (777) Log file permissions: /mystuff/logs/run.log rwx-rwx-rwx (777) At any rate, the following is the information I'm getting in the apache error_log while working on this particular portion of the application: PHP Warning: fwrite(): supplied argument is not a valid stream resource in /mystuff/inc/Log.inc on line 22, PHP Warning: fclose(): supplied argument is not a valid stream resource in /mystuff/inc/Log.inc on line 23, The Log class: - class Log{ public $path, $entry, $logfile; public function Log(){} public function setLog($path,$file){ $this-path = $path; $this-logfile = $file; } public function writeLog($entry){ // open the file, in this case the log file $h = $this-path/$this-logfile; fopen($h, 'a+'); fwrite($h,$entry); fclose($h); } } Code snippet where attempting to write log entry from program: $pl_log = new Log; $pl_log-setLog($logpath,run.log); $usernanme = $_POST['username']; $password = $_POST['secret']; /** * (debugging) logging incoming values from form: */ $pl_log-writeLog(getDateTime(): Incoming values from Login Form: blah...blah...blah\n); Any help with this would be most appreciated. (be gentle... I'm a PERL program learning PHP OOP) -- 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] General use of rewrite / redirect
Quoting Aschwin Wesselius [EMAIL PROTECTED]: Per Jessen wrote: Yes, that's a very typical setup. When the form is processed, you send a 303 redirect to the Thank you page. That way, if the user hits the back arrow, he's taken back to the form URL, not the post URL. (which would then warn him about re-submitting etc.) Ok, fine. But why do a real redirect when a header with 303 could be sufficient? If you model good enough, there would not be a need for header(location) redirects. Or am I wrong? What is your opinion about (ab)using rewrites / redirects? Do you use it quick and dirty, or is it some elegant way of controlling flow? I think there are valid reasons for using a header(location) redirect. As Per already pointed out. I don't see what using header() has to do with a good design. Sometimes you just want to do a redirect 303 or not :) I think there are plenty of perfectly valid reasons for using a redirect, whether dynamically from php or via an apache config. And undoubtedly there equally many poor reason for using redirect and/or rewrite. (they're very different things, by the way). I know they're different things. I only want to start a discussion so people do understand other techniques instead of just using whatever 'works' as a solution to their problem with flow. Redirects do solve some issues, but they should be avoided whenever possible. header(location) mechanisms do come with a very huge disadvantage if you don't use them with caution. Requests are reinitialised, libraries loaded (again), DB connections setup/checked again, session lookups are being done, log write for another request etc. That's quite an impact for just not knowing what to do with flow. So, if you know what you want to handle (control) and what you want the user to see (view), one should be able to model it without the use of redirects unless it really is needed. Not much different from a normal page load. Or is it OK, to redirect and 'simplify' the flow? I think it's ok to use. Also think about the fact that not all PHP applications are giant OO monsters. There's some simple scripts out there also. For wich header would be sufficient. -- Aschwin Wesselius /'What you would like to be done to you, do that to the other'/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5 file_get_contents() problems
Quoting Chris [EMAIL PROTECTED]: I've encountered a situation where under PHP 5 the file_get_contents() function will not work properly (actually not at all) if the php.ini Filesystem configuration parameter, allow_url_include is set to OFF. According to the PHP documentation allow_url_include is intended to limiting PHP from accessing scripts on other servers. I have read posts that suggest setting allow_url_include to ON as a solution. Well that's great if you have the ability to modify your php.ini. But what if you have an account on a shared hosting system and the hosting company will NOT make the requested change? Is there a work around to this or how would one access remote web services if allow_url_include is OFF. This looks like a huge problem since many services, like PayPal's IPN and Google maps geocoding, rely on communication with their servers. Try ini_set(allow_url_include, 1); In your script. (not tested) If that doesn't help. You can use CURL for this : http://php.net/manual/en/ref.curl.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5 file_get_contents() problems
Quoting Greg Bowser [EMAIL PROTECTED]: for security reasons, allow_url_include can only be set from the main php.ini I wasn't sure about that one. Thanks for the correction. On Tue, Mar 18, 2008 at 10:22 AM, Thijs Lensselink [EMAIL PROTECTED] wrote: Quoting Chris [EMAIL PROTECTED]: I've encountered a situation where under PHP 5 the file_get_contents() function will not work properly (actually not at all) if the php.ini Filesystem configuration parameter, allow_url_include is set to OFF. According to the PHP documentation allow_url_include is intended to limiting PHP from accessing scripts on other servers. I have read posts that suggest setting allow_url_include to ON as a solution. Well that's great if you have the ability to modify your php.ini. But what if you have an account on a shared hosting system and the hosting company will NOT make the requested change? Is there a work around to this or how would one access remote web services if allow_url_include is OFF. This looks like a huge problem since many services, like PayPal's IPN and Google maps geocoding, rely on communication with their servers. Try ini_set(allow_url_include, 1); In your script. (not tested) If that doesn't help. You can use CURL for this : http://php.net/manual/en/ref.curl.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] General use of rewrite / redirect
Quoting Aschwin Wesselius [EMAIL PROTECTED]: Per Jessen wrote: header(location) mechanisms do come with a very huge disadvantage if you don't use them with caution. Requests are reinitialised, libraries loaded (again), DB connections setup/checked again, session lookups are being done, log write for another request etc. That's quite an impact for just not knowing what to do with flow. I'm having difficulties following you - a plain 303 redirect to a Thank you page shouldn't cause all of that. It's an HTTP reply with the 303 and the new URL, followed by a single URL request from the browser. OK. I think I know how other people (like you) think about just requesting URL's one after another. If that's not such a performance issue for you, fine. People like who? Come on we try to help. A plain 303 redirect mostly isn't just a HTML file, it's another script (or the same script with another action falling through a switch statement, whatever). A 303 is whatever you make of it. Point is: why hitting you webserver with multiple requests per user, just after submitting a form or whatever caused the redirect? If you have 2 users per day, that won't hurt. But if you have 30.000 concurrent users a minute, that could be 60.000 requests (besides all the images, stylesheets, javascripts that are being re-requested). Or am I talking nonsense? True. Why hit your webserver with useless requests. But if you submit a form. There must be a action behind it .. right? So you either reload the page, use header() or some other method. The next page needs to be loaded. And so will CSS, JS, images. -- Aschwin Wesselius /'What you would like to be done to you, do that to the other'/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A Quick Reminder....
Quoting tedd [EMAIL PROTECTED]: At 11:14 AM -0400 3/12/08, Jason Pruim wrote: Up here in the great big hand (Michigan for those who don't know) during the winter we have so much snow on the ground that you just kind of drive where ever looks like road... Even if it means you have people passing on your right going the opposite way. Yeah, but those are mostly Dutch -- you never know where they're going. :-) It's a bit different here in Lansing -- with most being politicians, we all drive in circles. It's always the Dutch huh! :) It's because in our small ountry all traffic is stuck all day long. So when it finally moves it goes all directions :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A Quick Reminder....
Quoting Daniel Brown [EMAIL PROTECTED]: On Thu, Mar 13, 2008 at 10:06 AM, Thijs Lensselink [EMAIL PROTECTED] wrote: It's always the Dutch huh! :) It's because in our small ountry all traffic is stuck all day long. So when it finally moves it goes all directions :) Not quite as bad as they do in India. I saw this a few weeks ago and was amazed. SFW. http://www.youtube.com/watch?v=RjrEQaG5jPM wow! how do these people get to there destinations :) but the worst i've seen is still in Moscow. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A Quick Reminder....
Quoting tedd [EMAIL PROTECTED]: At 10:06 AM -0400 3/13/08, Thijs Lensselink wrote: Quoting tedd [EMAIL PROTECTED]: At 11:14 AM -0400 3/12/08, Jason Pruim wrote: Up here in the great big hand (Michigan for those who don't know) during the winter we have so much snow on the ground that you just kind of drive where ever looks like road... Even if it means you have people passing on your right going the opposite way. Yeah, but those are mostly Dutch -- you never know where they're going. :-) It's a bit different here in Lansing -- with most being politicians, we all drive in circles. It's always the Dutch huh! :) It's because in our small ountry all traffic is stuck all day long. So when it finally moves it goes all directions :) There's a difference between Dutch in Dutch-land and those here in Michigan. The ones we have here are really strange. They are the type that say Thrown Mama down the stairs, the broom and other such heart-stopping comments. True! But the Dutch do have a way with words :) I've heard worse phrases then that! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Ajax progress bar
Quoting Shelley [EMAIL PROTECTED]: Hi all, I'm searching some file upload progress bar code. But no good result was found. :( So is there anybody please be kind enough to show some code here? Great thanks. -- Regard, Shelley (http://phparch.cn) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You can try searching the archives. Rasmus had an example a long time ago. Although it requires APC to be installed. Maybe it's interesting. Found it: Example : http://progphp.com/upload.php Source : http://progphp.com/upload.phps -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Ajax progress bar
Quoting Mr Webber [EMAIL PROTECTED]: I haven't' tried this yet ... so I would appreciate your feedback. -Original Message- From: Thijs Lensselink [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 12, 2008 4:28 AM To: php-general@lists.php.net Subject: Re: [PHP] PHP Ajax progress bar Quoting Shelley [EMAIL PROTECTED]: Hi all, I'm searching some file upload progress bar code. But no good result was found. :( So is there anybody please be kind enough to show some code here? Great thanks. -- Regard, Shelley (http://phparch.cn) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You can try searching the archives. Rasmus had an example a long time ago. Although it requires APC to be installed. Maybe it's interesting. Found it: Example : http://progphp.com/upload.php Source : http://progphp.com/upload.phps -- Pls don't top post. If you want to know if it works. Go ahead! Copy paste the code and give it a try. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Ajax progress bar
Quoting Shelley [EMAIL PROTECTED]: Thijs Lensselink 写道: Quoting Mr Webber [EMAIL PROTECTED]: I haven't' tried this yet ... so I would appreciate your feedback. -Original Message- From: Thijs Lensselink [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 12, 2008 4:28 AM To: php-general@lists.php.net Subject: Re: [PHP] PHP Ajax progress bar Quoting Shelley [EMAIL PROTECTED]: Hi all, I'm searching some file upload progress bar code. But no good result was found. :( So is there anybody please be kind enough to show some code here? Great thanks. -- Regard, Shelley (http://phparch.cn) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You can try searching the archives. Rasmus had an example a long time ago. Although it requires APC to be installed. Maybe it's interesting. Found it: Example : http://progphp.com/upload.php Source : http://progphp.com/upload.phps -- Pls don't top post. If you want to know if it works. Go ahead! Copy paste the code and give it a try. I don't think it works. I tried. The screen always said 0%, 0 of 0 byte until the file is uploaded. Is that what you mean progress bar? -- Regards, Shelley (http://phparch.cn) Do you have all the yui files? and APC enabled? I tried it some time ago and it worked. But i did have to set apc.rfc1867 = on in php.ini to make it work. Forgot to mention that one. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing files
Quoting mathieu leddet [EMAIL PROTECTED]: Hi all, I have a simple question : how can I ensure that 2 files are identical ? How about this ? 8-- function files_identical($path1, $path2) { return (file_get_contents($path1) == file_get_contents($path2)); } 8-- Note that I would like to compare any type of files (text and binary). Thanks for any help, -- Mathieu You could use md5_file for this. Something like: function files_identical($path1, $path2) { return (md5_file($path1) == md5_file($path2)); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Comparing files
Quoting Andrés Robinet [EMAIL PROTECTED]: -Original Message- From: Edward Kay [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 12, 2008 7:13 AM To: mathieu leddet; php-general@lists.php.net Subject: RE: [PHP] Comparing files -Original Message- From: mathieu leddet [mailto:[EMAIL PROTECTED] Sent: 12 March 2008 11:04 To: php-general@lists.php.net Subject: [PHP] Comparing files Hi all, I have a simple question : how can I ensure that 2 files are identical ? How about this ? 8-- function files_identical($path1, $path2) { return (file_get_contents($path1) == file_get_contents($path2)); } 8-- Note that I would like to compare any type of files (text and binary). Thanks for any help, Depending upon the size of the files, I would expect it would be quicker to compare a hash of each file. Edward I don't understand how comparing hashes can be faster than comparing contents, except for big files for which you will likely hit the memory limit first and for files who only differ from each other at the very end of them, so the comparison will only be halted then. If the file sizes vary too much, however, a mixed strategy would be the winner; and certainly, you will want to store path names and calculated hashes in a database of some kind to save yourself from hogging the server each time (yeah, CPU and RAM are cheap, but not unlimited resources). I must agree that a mixed solution would be best here. Comparing hashes means that a hash must be calculated for files A and B and the related overhead will increase according to the file size (right or wrong?). Comparing the file contents will have an associated overhead for buffering and moving the file contents into memory, and it's also a linear operation (strings are compared byte to byte till there's a difference). So... why not doing the following? 1 - Compare file sizes (this is just a property stored in the file system structures, right?). If sizes are different, the files are different. Otherwise move to step 2. I like this idea. It's fast and will catch most differences. 2 - If the file sizes are smaller than certain size (up to you to find the optimal file size), just compare contents through, say, file_get_contents. Otherwise move to step 3. 3 - Grab some random bytes at the beginning, at the middle and at the end of both files and compare them. If they are different, the files are different. Otherwise move to step 4. Not sure about this one. Will all the file operations not create to much overhead if you are dealing with large files? 4 - If you reach this point, you are doomed. You have 2 big files that you must compare and they are apparently equal so far. Comparing contents will be over killing if at all possible, so you will want to generate hashes and compare them. Run md5_file on both files (it would be great if you have, say, file A's hash already calculated and stored in a DB or data file) and compare results. It is always up to what kind of files you are dealing with, if the files are often different only at the end of the stream, you may want to skip step 2. But this is what I would generally do. By the way, md5 is a great hashing function, but it is not bullet-proof, collisions may happen (though it's much better than crc32, for example). So, you MD5 is for sure not bullet-proof. You could always switch to sha1_file for a bit more security. may also think of how critical is to you to have some false positives (some files that are considered equal by md5_file and they are not) and probably use some diff-like solution instead of md5_file. Anyway, having compared sizes and random bytes (steps 1 through 3), it's very likely that md5_file will catch it if two files are different in just a few bytes. Regards, Rob Andrés Robinet | Lead Developer | BESTPLACE CORPORATION 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 | TEL 954-607-4207 | FAX 954-337-2695 | Email: [EMAIL PROTECTED] | MSN Chat: [EMAIL PROTECTED] | SKYPE: bestplace | Web: bestplace.biz | Web: seo-diy.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] PHP Ajax progress bar
Quoting Philip Thompson [EMAIL PROTECTED]: On Mar 12, 2008, at 5:02 AM, Thijs Lensselink wrote: Thijs Lensselink 写道: How do you pronounce your name? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Well.. how to explain this one... thijs : T + [ice] That's the best i can do :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Ajax progress bar
Quoting Daniel Brown [EMAIL PROTECTED]: On Wed, Mar 12, 2008 at 11:03 AM, Philip Thompson [EMAIL PROTECTED] wrote: On Mar 12, 2008, at 9:52 AM, Thijs Lensselink wrote: Quoting Philip Thompson [EMAIL PROTECTED]: How do you pronounce your name? Well.. how to explain this one... thijs : T + [ice] Which is different than the famous rapper/actor... hijs-t : [ice] + T HA! -- /Dan Daniel P. Brown Senior Unix Geek ? while(1) { $me = $mind--; sleep(86400); } ? Same reaction here! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Storing values between multiple page forms
Quoting Matty Sarro [EMAIL PROTECTED]: Greets all! I am working on a minor project for work for entering inventory information for servers we ship out. Here is my plan: First page - Get client name, number of servers, and find number of miscellaneous equipment(s) being shipped (UPS's, monitors, etc) From there, create a loop to run through each server based on number of servers input on first page. Each server will come up as a new page. Each server can have x hard drives, the number of which will be put in by the user, and the form will be generated by a loop based on the number the user puts in (ie: either generate the form based on submitted number of hard drives, or have user put in a drop down and use some javascript for the rest). I'm still planning this out... my major concern is how would I maintain values between pages? I'd like to have a summary printed before actually storing values into the database. I'm going to start throwing together some code, but I just wasn't sure how to maintain the values. The first version is most likely just going to be one really large form, but obviously this is going to be ugly and not so easy to work with considering the variances that the different servers have. Any suggestions would be welcome. Maybe take a look at stut's article :) http://stut.net/articles/sessionless_sessions.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Deprecated configure options
Ian M. Evans wrote: Was just upgrading to 5.2.5 and used the same configure line as I used for 5.2.0. Got the following notice: Notice: Following unknown configure options were used: --enable-pic --with-dom --with-png --with-xml --enable-track-vars --enable-trans-sid --enable-yp --enable-mbstr-enc-trans --enable-dio --enable-mcal --with-jpeg Safe to assume those were deprecated? You can just run ./configure --help and see for yourself. Some have changed and some seem to have been deprecated. --with-pic --disable-dom --with-png-dir[=DIR] --disable-libxml --disable-xml --with-jpeg-dir[=DIR] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] URL modification
Quoting Xavier de Lapeyre [EMAIL PROTECTED]: Thnks, H... made a quick look into it. Seems to be apache compatible. I'm designing a site to be hosted on an IIS Server. Does it still works there? Regards, Xavier de Lapeyre Web Developer Enterprise Data Services 24, Dr Roux Street, Rose Hill Office: (230) 465 17 00 Fax: (230) 465 29 00 Site: www.eds.mu Email: [EMAIL PROTECTED] Please consider the environment before printing this mail note. -Original Message- From: Andrés Robinet [mailto:[EMAIL PROTECTED] Sent: vendredi 22 février 2008 11:48 To: php-general@lists.php.net Subject: RE: [PHP] URL modification -Original Message- From: Xavier de Lapeyre [mailto:[EMAIL PROTECTED] Sent: Friday, February 22, 2008 2:09 AM To: php-general@lists.php.net Subject: [PHP] URL modification Importance: High Hi all, I saw on some websites that modifies the links to access the webpages. Something like: http://www.example.com/login/ instead of http://www.example.com/login.php Does anyone knows how this works or how its call / which PHP library performs this action? Xavier de Lapeyre That's called URI/URL Routing and it's usually performed as part of every MVC Framework I know of (CodeIgniter, CakePHP, Symfony, Zend Framework... just to name a few). It's usually implemented through Apache's mod_rewrite module, but you can get close without that module, if you allow for something like: http://www.example.com/index.php/myaccount/profile (that is, you don't need mod_rewrite unless you want to remove the index.php part of the URI path) However, if you have an existing website, migrating it to use one of the MVC frameworks (or just using a stand-alone URI Routing class) may not be the path you want to follow. Regards, Rob Andrés Robinet | Lead Developer | BESTPLACE CORPORATION 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 | TEL 954-607-4207 | FAX 954-337-2695 | Email: [EMAIL PROTECTED] | MSN Chat: [EMAIL PROTECTED] | SKYPE: bestplace | Web: bestplace.biz | Web: seo-diy.com There are rewrite modules for IIS also. Just google for IIS rewrite. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php