[PHP] Enabling the chroot() function in PHP 5.4
Hi All, Does anybody know how to enable the chroot() function in PHP 5.4? It was easy in PHP 5.3 as long as you were building the CLI by itself. In the PHP 5.4 configure script there is a new PHP_BINARIES variable being used instead of setting PHP_SAPI=cli and thus the #define ENABLE_CHROOT_FUNC 1 is never written to the output file. I have been able to manually enable it by adding the define to the main/php_config.h after running configure. The issue seems to be a line: if test program = program. This comparison being true is what causes the configure script to add cli to the PHP_BINARIES variable instead of setting the PHP_SAPI variable. The other prerequisites (HAVE_CHROOT and ZTS) are all at the required settings. It is only the ENABLE_CHROOT_FUNC which is causing the function to not be compiled into the resulting binary. Any information or explanation would be very helpful. For the record, I know what the chroot() function does and does not do. I am experimenting with using chroot() to isolate an already running script to a particular subset of the filesystem for file operations. -- - Aaron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Enabling the chroot() function in PHP 5.4
Hi Aaron, It's better if you ask this question on the PHP internals list, there's hardly anyone compiling it's own PHP here. - Matijn On Thu, Jun 13, 2013 at 9:55 AM, Aaron Stephens aaron.t.steph...@gmail.comwrote: Hi All, Does anybody know how to enable the chroot() function in PHP 5.4? It was easy in PHP 5.3 as long as you were building the CLI by itself. In the PHP 5.4 configure script there is a new PHP_BINARIES variable being used instead of setting PHP_SAPI=cli and thus the #define ENABLE_CHROOT_FUNC 1 is never written to the output file. I have been able to manually enable it by adding the define to the main/php_config.h after running configure. The issue seems to be a line: if test program = program. This comparison being true is what causes the configure script to add cli to the PHP_BINARIES variable instead of setting the PHP_SAPI variable. The other prerequisites (HAVE_CHROOT and ZTS) are all at the required settings. It is only the ENABLE_CHROOT_FUNC which is causing the function to not be compiled into the resulting binary. Any information or explanation would be very helpful. For the record, I know what the chroot() function does and does not do. I am experimenting with using chroot() to isolate an already running script to a particular subset of the filesystem for file operations. -- - Aaron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DEV] new FTP function
On Fri, Jan 18, 2013 at 10:33 AM, KISE wowk...@gmail.com wrote: Paul Dragoonis, Actually it wont work i did tried it before, if the dir end with / it will list the directories inside the path you gave it and if it doesn't have any directories it will return false since there is no directories to return. you have to take out the last / and then remove the directory in question and list the files in the parent directory and check if the dir exists otherwise it will return false, i spent 3hrs yesterday thinking why its returning false even though the directory exists. The discussion is now getting more into the general coding realm than internals, so let's move it over there in case anyone wants to mention something like: function ftp_dir_exists($conn, $currentDir) { $currentDir = (substr($currentDir,-1,1) == '/') ? substr($currentDir,0,-1) : $currentDir; $list = ftp_nlist($conn, '-dF '. $currentDir); return in_array($currentDir, $list); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [PHP-DEV] new FTP function
On Fri, Jan 18, 2013 at 9:43 AM, Daniel Brown danbr...@php.net wrote: On Fri, Jan 18, 2013 at 10:33 AM, KISE wowk...@gmail.com wrote: Paul Dragoonis, Actually it wont work i did tried it before, if the dir end with / it will list the directories inside the path you gave it and if it doesn't have any directories it will return false since there is no directories to return. you have to take out the last / and then remove the directory in question and list the files in the parent directory and check if the dir exists otherwise it will return false, i spent 3hrs yesterday thinking why its returning false even though the directory exists. The discussion is now getting more into the general coding realm than internals, so let's move it over there in case anyone wants to mention something like: function ftp_dir_exists($conn, $currentDir) { $currentDir = (substr($currentDir,-1,1) == '/') ? substr($currentDir,0,-1) : $currentDir; $list = ftp_nlist($conn, '-dF '. $currentDir); return in_array($currentDir, $list); } Haven't played with ftp functions at all, but wondering what if you gave it dirname($currentDir) instead of $currentDir? (Still have to do the trailing '/'-ectomy) $list = ftp_nlist($conn, dirname($currentDir)); untested, just a thought. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [PHP-DEV] new FTP function
On Fri, Jan 18, 2013 at 9:26 PM, tamouse mailing lists tamouse.li...@gmail.com wrote: On Fri, Jan 18, 2013 at 9:43 AM, Daniel Brown danbr...@php.net wrote: On Fri, Jan 18, 2013 at 10:33 AM, KISE wowk...@gmail.com wrote: Paul Dragoonis, Actually it wont work i did tried it before, if the dir end with / it will list the directories inside the path you gave it and if it doesn't have any directories it will return false since there is no directories to return. you have to take out the last / and then remove the directory in question and list the files in the parent directory and check if the dir exists otherwise it will return false, i spent 3hrs yesterday thinking why its returning false even though the directory exists. The discussion is now getting more into the general coding realm than internals, so let's move it over there in case anyone wants to mention something like: function ftp_dir_exists($conn, $currentDir) { $currentDir = (substr($currentDir,-1,1) == '/') ? substr($currentDir,0,-1) : $currentDir; $list = ftp_nlist($conn, '-dF '. $currentDir); return in_array($currentDir, $list); } Haven't played with ftp functions at all, but wondering what if you gave it dirname($currentDir) instead of $currentDir? (Still have to do the trailing '/'-ectomy) $list = ftp_nlist($conn, dirname($currentDir)); untested, just a thought. Although on further thought, if $currentDir actually points to a non-directory, that will still pass, won't it. Might have to go with ftp_rawlist and parse it out to ensure it is a directory... Check the first character of each line to see if it's 'd', then the file name will be the last field in the line. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] about PHP's filter_var function
Am 20.09.2012 19:54, schrieb Jim Lucas: On 09/20/2012 10:00 AM, Matijn Woudt wrote: On Thu, Sep 20, 2012 at 6:03 PM, Jim Lucasli...@cmsws.com wrote: On 09/20/2012 02:35 AM, Sebastian Krebs wrote: Plaseplease update... 5.1.6 is from 2006! I read the it's required, but I can't imagine _anything_ that it's worth it to use such an extremely outdated, unsupported and therefore insecure and inefficient version... You know: There are 3 (!) new minor versions available right now (5.2, 5.3 and 5.4). However: Regarding your concrete problem I guess you can use ip2long() if (ip2long($ip)) { I would suggest a modification to this. if ( ip2long($ip) !== false ) { I suggest this because IP to long will return negative numbers for half the IP range. Therefor 50% of your possible results would be considered false when in fact they are valid IPs. See Example #2 on this page: http://php.net/manual/en/function.ip2long.php First of all, I agree with Maciek that inet_pton is the way to go because of IPv6. But, there seems to be some wrong information in your reply which bothers me. First of all, ip2long only returns negative numbers on 32bit systems, not on 64bit (which most servers are nowadays). Second, there's nothing wrong with the if, if(-5) is still true. The only difference is that you can differentiate between IP 0.0.0.0 and false. But IP 0.0.0.0 is not valid anyway. - Matijn After some testing, I stand corrected. Wow, I wonder where I ran into the issue of negative numbers equating to false. while loops maybe... Strange. I must have ran into this issue years ago. I have always performed strict (===) comparisons because I thought PHP would equate negative numbers as false. Learn something new every day... You can find the full matrix here: http://php.net/types.comparisons -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] about PHP's filter_var function
Hello: I want to use filter_var function by this way: $ip = 192.168.0.1; if( !filter_var($ip, FILTER_VALIDATE_IP) ) { echo IP is not valid; } else { echo IP is valid; } I want to check the string $ip is IP address or not.but my PHP version is 5.1.6. and I know the filter_var requires at least PHP version 5.2.0. so, Any other function in PHP 5.1.6 can slove this work and replace the filter_var function ? Thank you, I'm a new one, so I don't know much about PHP documentation. By the way, The PHP version is required. so I can't upgrade it.
Re: [PHP] about PHP's filter_var function
You can use regex to check the format: /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/ You can also explode $ip on . and check if every part is numeric and less than 255. On 20 September 2012 14:44, lx lxlenovos...@gmail.com wrote: Hello: I want to use filter_var function by this way: $ip = 192.168.0.1; if( !filter_var($ip, FILTER_VALIDATE_IP) ) { echo IP is not valid; } else { echo IP is valid; } I want to check the string $ip is IP address or not.but my PHP version is 5.1.6. and I know the filter_var requires at least PHP version 5.2.0. so, Any other function in PHP 5.1.6 can slove this work and replace the filter_var function ? Thank you, I'm a new one, so I don't know much about PHP documentation. By the way, The PHP version is required. so I can't upgrade it.
Re: [PHP] about PHP's filter_var function
Plaseplease update... 5.1.6 is from 2006! I read the it's required, but I can't imagine _anything_ that it's worth it to use such an extremely outdated, unsupported and therefore insecure and inefficient version... You know: There are 3 (!) new minor versions available right now (5.2, 5.3 and 5.4). However: Regarding your concrete problem I guess you can use ip2long() if (ip2long($ip)) { } else { } Regards, Sebastian Am 20.09.2012 11:14, schrieb lx: Hello: I want to use filter_var function by this way: $ip = 192.168.0.1; if( !filter_var($ip, FILTER_VALIDATE_IP) ) { echo IP is not valid; } else { echo IP is valid; } I want to check the string $ip is IP address or not.but my PHP version is 5.1.6. and I know the filter_var requires at least PHP version 5.2.0. so, Any other function in PHP 5.1.6 can slove this work and replace the filter_var function ? Thank you, I'm a new one, so I don't know much about PHP documentation. By the way, The PHP version is required. so I can't upgrade it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] about PHP's filter_var function
On 09/20/2012 02:35 AM, Sebastian Krebs wrote: Plaseplease update... 5.1.6 is from 2006! I read the it's required, but I can't imagine _anything_ that it's worth it to use such an extremely outdated, unsupported and therefore insecure and inefficient version... You know: There are 3 (!) new minor versions available right now (5.2, 5.3 and 5.4). However: Regarding your concrete problem I guess you can use ip2long() if (ip2long($ip)) { I would suggest a modification to this. if ( ip2long($ip) !== false ) { I suggest this because IP to long will return negative numbers for half the IP range. Therefor 50% of your possible results would be considered false when in fact they are valid IPs. See Example #2 on this page: http://php.net/manual/en/function.ip2long.php } else { } Regards, Sebastian Am 20.09.2012 11:14, schrieb lx: Hello: I want to use filter_var function by this way: $ip = 192.168.0.1; if( !filter_var($ip, FILTER_VALIDATE_IP) ) { echo IP is not valid; } else { echo IP is valid; } I want to check the string $ip is IP address or not.but my PHP version is 5.1.6. and I know the filter_var requires at least PHP version 5.2.0. so, Any other function in PHP 5.1.6 can slove this work and replace the filter_var function ? Thank you, I'm a new one, so I don't know much about PHP documentation. By the way, The PHP version is required. so I can't upgrade it. -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] about PHP's filter_var function
On 20-09-2012 18:03, Jim Lucas wrote: On 09/20/2012 02:35 AM, Sebastian Krebs wrote: Plaseplease update... 5.1.6 is from 2006! I read the it's required, but I can't imagine _anything_ that it's worth it to use such an extremely outdated, unsupported and therefore insecure and inefficient version... You know: There are 3 (!) new minor versions available right now (5.2, 5.3 and 5.4). However: Regarding your concrete problem I guess you can use ip2long() if (ip2long($ip)) { I would suggest a modification to this. if ( ip2long($ip) !== false ) { I would actually suggest using inet_pton() instead of ip2long, since it can also handle IPv6 adresses, not only v4 which people here seem to think are the only ones in use on this planet. And I agree with Jim that you really should use a strict equality check in this case. - Tul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] about PHP's filter_var function
Am 20.09.2012 18:03, schrieb Jim Lucas: On 09/20/2012 02:35 AM, Sebastian Krebs wrote: Plaseplease update... 5.1.6 is from 2006! I read the it's required, but I can't imagine _anything_ that it's worth it to use such an extremely outdated, unsupported and therefore insecure and inefficient version... You know: There are 3 (!) new minor versions available right now (5.2, 5.3 and 5.4). However: Regarding your concrete problem I guess you can use ip2long() if (ip2long($ip)) { I would suggest a modification to this. if ( ip2long($ip) !== false ) { I suggest this because IP to long will return negative numbers for half the IP range. Therefor 50% of your possible results would be considered false when in fact they are valid IPs. See Example #2 on this page: http://php.net/manual/en/function.ip2long.php No, negative numbers are true too. Only 0 is false, so '0.0.0.0' is the only edge case. } else { } Regards, Sebastian Am 20.09.2012 11:14, schrieb lx: Hello: I want to use filter_var function by this way: $ip = 192.168.0.1; if( !filter_var($ip, FILTER_VALIDATE_IP) ) { echo IP is not valid; } else { echo IP is valid; } I want to check the string $ip is IP address or not.but my PHP version is 5.1.6. and I know the filter_var requires at least PHP version 5.2.0. so, Any other function in PHP 5.1.6 can slove this work and replace the filter_var function ? Thank you, I'm a new one, so I don't know much about PHP documentation. By the way, The PHP version is required. so I can't upgrade it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] about PHP's filter_var function
On Thu, Sep 20, 2012 at 6:03 PM, Jim Lucas li...@cmsws.com wrote: On 09/20/2012 02:35 AM, Sebastian Krebs wrote: Plaseplease update... 5.1.6 is from 2006! I read the it's required, but I can't imagine _anything_ that it's worth it to use such an extremely outdated, unsupported and therefore insecure and inefficient version... You know: There are 3 (!) new minor versions available right now (5.2, 5.3 and 5.4). However: Regarding your concrete problem I guess you can use ip2long() if (ip2long($ip)) { I would suggest a modification to this. if ( ip2long($ip) !== false ) { I suggest this because IP to long will return negative numbers for half the IP range. Therefor 50% of your possible results would be considered false when in fact they are valid IPs. See Example #2 on this page: http://php.net/manual/en/function.ip2long.php First of all, I agree with Maciek that inet_pton is the way to go because of IPv6. But, there seems to be some wrong information in your reply which bothers me. First of all, ip2long only returns negative numbers on 32bit systems, not on 64bit (which most servers are nowadays). Second, there's nothing wrong with the if, if(-5) is still true. The only difference is that you can differentiate between IP 0.0.0.0 and false. But IP 0.0.0.0 is not valid anyway. - Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] about PHP's filter_var function
Am 20.09.2012 18:17, schrieb Maciek Sokolewicz: On 20-09-2012 18:03, Jim Lucas wrote: On 09/20/2012 02:35 AM, Sebastian Krebs wrote: Plaseplease update... 5.1.6 is from 2006! I read the it's required, but I can't imagine _anything_ that it's worth it to use such an extremely outdated, unsupported and therefore insecure and inefficient version... You know: There are 3 (!) new minor versions available right now (5.2, 5.3 and 5.4). However: Regarding your concrete problem I guess you can use ip2long() if (ip2long($ip)) { I would suggest a modification to this. if ( ip2long($ip) !== false ) { I would actually suggest using inet_pton() instead of ip2long, since it can also handle IPv6 adresses, not only v4 which people here seem to think are the only ones in use on this planet. And I agree with Jim that you really should use a strict equality check in this case. IPv6 is a valid point, but inet_pton() triggers a warning in case of invalid addresses, which makes it quite useless for validation in my eyes. Also it's not available on windows before 5.3 And the strict comparison feels ... a little bit to much. Of course depending on the use-case, I would treat 0.0.0.0 as invalid too. - Tul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] about PHP's filter_var function
On 09/20/2012 10:00 AM, Matijn Woudt wrote: On Thu, Sep 20, 2012 at 6:03 PM, Jim Lucasli...@cmsws.com wrote: On 09/20/2012 02:35 AM, Sebastian Krebs wrote: Plaseplease update... 5.1.6 is from 2006! I read the it's required, but I can't imagine _anything_ that it's worth it to use such an extremely outdated, unsupported and therefore insecure and inefficient version... You know: There are 3 (!) new minor versions available right now (5.2, 5.3 and 5.4). However: Regarding your concrete problem I guess you can use ip2long() if (ip2long($ip)) { I would suggest a modification to this. if ( ip2long($ip) !== false ) { I suggest this because IP to long will return negative numbers for half the IP range. Therefor 50% of your possible results would be considered false when in fact they are valid IPs. See Example #2 on this page: http://php.net/manual/en/function.ip2long.php First of all, I agree with Maciek that inet_pton is the way to go because of IPv6. But, there seems to be some wrong information in your reply which bothers me. First of all, ip2long only returns negative numbers on 32bit systems, not on 64bit (which most servers are nowadays). Second, there's nothing wrong with the if, if(-5) is still true. The only difference is that you can differentiate between IP 0.0.0.0 and false. But IP 0.0.0.0 is not valid anyway. - Matijn After some testing, I stand corrected. Wow, I wonder where I ran into the issue of negative numbers equating to false. while loops maybe... Strange. I must have ran into this issue years ago. I have always performed strict (===) comparisons because I thought PHP would equate negative numbers as false. Learn something new every day... -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: w.r.t. mail() function
On 23-05-2012 06:12, Ashwani Kesharwani wrote: Hi , I have a query w.r.t. mail() function in php. I have hosted my site and i have created an email account as well. when i am sending mail to different recipient from my php script using above function it is getting delivered to respective recipients as expected. However if I want to see those mail in the sent folder of my email account , i can not see those mails there. How can I achieve this. Any suggestions. Regards Ashwani Simply put: the email account you have created is being ignored by the mail() function. It doesn't matter if you created an email account or not; if I wanted to, I could make mail() send emails from presid...@whitehouse.gov or from kofi.an...@un.org. The mails would never appear in their outboxes, simply because an outbox or sent mail folder is a local copy of your mail, made by the mail client. It has nothing, intrinsically, to do with emailing anyone. If I try email someone, this happens: 1. I load my mail client 2. I type my mail and press send 3. My mail client stores a copy of this mail in the sent folder 4. My mail client contacts the server, and tells it that it has a mail from me, to a certain adress, and then hands it over. 5. My mail client tells me mail sent successfully If I use PHP's mail function, the following happens: 1. The PHP script is ran 2. The mail() function is invoked with the email message to send as a string 3. The mail() function starts up a local program called sendmail (or a program which does roughly the same thing), which it then gives the entire message to send to. 4. sendmail contacts the server, and tells it that it has a mail from me, to a certain adress, and then hands it over. 5. the mail() function says mail sent succesfully So, as you can see, the storage of the email in the sent box has nothing to do with actual sending of the mail, but purely with the use of your mail client, which PHP does not use (obviously). If you really do want to store the email, you'll have to do it yourself. admin (which is an annoying nickname on the internet! Please change it!) has already showed you a few ways to do so. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: w.r.t. mail() function
Hi Maciek, admin, Thanks for your responses. Its really helpful. Regards Ashwani On Wed, May 23, 2012 at 3:37 PM, Maciek Sokolewicz maciek.sokolew...@gmail.com wrote: On 23-05-2012 06:12, Ashwani Kesharwani wrote: Hi , I have a query w.r.t. mail() function in php. I have hosted my site and i have created an email account as well. when i am sending mail to different recipient from my php script using above function it is getting delivered to respective recipients as expected. However if I want to see those mail in the sent folder of my email account , i can not see those mails there. How can I achieve this. Any suggestions. Regards Ashwani Simply put: the email account you have created is being ignored by the mail() function. It doesn't matter if you created an email account or not; if I wanted to, I could make mail() send emails from presid...@whitehouse.gov or from kofi.an...@un.org. The mails would never appear in their outboxes, simply because an outbox or sent mail folder is a local copy of your mail, made by the mail client. It has nothing, intrinsically, to do with emailing anyone. If I try email someone, this happens: 1. I load my mail client 2. I type my mail and press send 3. My mail client stores a copy of this mail in the sent folder 4. My mail client contacts the server, and tells it that it has a mail from me, to a certain adress, and then hands it over. 5. My mail client tells me mail sent successfully If I use PHP's mail function, the following happens: 1. The PHP script is ran 2. The mail() function is invoked with the email message to send as a string 3. The mail() function starts up a local program called sendmail (or a program which does roughly the same thing), which it then gives the entire message to send to. 4. sendmail contacts the server, and tells it that it has a mail from me, to a certain adress, and then hands it over. 5. the mail() function says mail sent succesfully So, as you can see, the storage of the email in the sent box has nothing to do with actual sending of the mail, but purely with the use of your mail client, which PHP does not use (obviously). If you really do want to store the email, you'll have to do it yourself. admin (which is an annoying nickname on the internet! Please change it!) has already showed you a few ways to do so.
[PHP] Re: w.r.t. mail() function
On Wed, 23 May 2012 00:24:25 -0400, admin wrote: -Original Message- From: Ashwani Kesharwani [mailto:ashwani.kesharw...@gmail.com] Sent: Wednesday, May 23, 2012 12:13 AM To: php-general@lists.php.net Subject: [PHP] w.r.t. mail() function Hi , I have a query w.r.t. mail() function in php. I have hosted my site and i have created an email account as well. when i am sending mail to different recipient from my php script using above function it is getting delivered to respective recipients as expected. However if I want to see those mail in the sent folder of my email account , i can not see those mails there. How can I achieve this. Any suggestions. Bad quoting above by the below: You can change the settings of sendmail http://www.devshed.com/c/a/Administration/Getting-Started-with-Sendmail/12/ OR You can log text or database each email. $query = INSERT INTO mail_log (`subject`,`to`,`from`,`message`,`mail_date`) values ('.mysql_real_escape_string( $subject ).', '.mysql_real_escape_string( $to ).', '.mysql_real_escape_string( $from ).', '.mysql_real_escape_string( $message ).', '.date(Y-m-d H:i:s).') ; Or, you can Bcc: yourself and filter (procmail) the email into your sent-mail folder. Jonesy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: w.r.t. mail() function
On Wed, May 23, 2012 at 3:50 PM, Jonesy gm...@jonz.net wrote: On Wed, 23 May 2012 00:24:25 -0400, admin wrote: -Original Message- From: Ashwani Kesharwani [mailto:ashwani.kesharw...@gmail.com] Sent: Wednesday, May 23, 2012 12:13 AM To: php-general@lists.php.net Subject: [PHP] w.r.t. mail() function Hi , I have a query w.r.t. mail() function in php. I have hosted my site and i have created an email account as well. when i am sending mail to different recipient from my php script using above function it is getting delivered to respective recipients as expected. However if I want to see those mail in the sent folder of my email account , i can not see those mails there. How can I achieve this. Any suggestions. Bad quoting above by the below: You can change the settings of sendmail http://www.devshed.com/c/a/Administration/Getting-Started-with-Sendmail/12/ OR You can log text or database each email. $query = INSERT INTO mail_log (`subject`,`to`,`from`,`message`,`mail_date`) values ('.mysql_real_escape_string( $subject ).', '.mysql_real_escape_string( $to ).', '.mysql_real_escape_string( $from ).', '.mysql_real_escape_string( $message ).', '.date(Y-m-d H:i:s).') ; Or, you can Bcc: yourself and filter (procmail) the email into your sent-mail folder. Jonesy Or, if your mail server has IMAP access, use any PHP IMAP extension to connect to your IMAP server and send it from there. Then it will appear in your outbox. - Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: w.r.t. mail() function
On Wed, 2012-05-23 at 20:36 +0200, Matijn Woudt wrote: On Wed, May 23, 2012 at 3:50 PM, Jonesy gm...@jonz.net wrote: On Wed, 23 May 2012 00:24:25 -0400, admin wrote: -Original Message- From: Ashwani Kesharwani [mailto:ashwani.kesharw...@gmail.com] Sent: Wednesday, May 23, 2012 12:13 AM To: php-general@lists.php.net Subject: [PHP] w.r.t. mail() function Hi , I have a query w.r.t. mail() function in php. I have hosted my site and i have created an email account as well. when i am sending mail to different recipient from my php script using above function it is getting delivered to respective recipients as expected. However if I want to see those mail in the sent folder of my email account , i can not see those mails there. How can I achieve this. Any suggestions. Bad quoting above by the below: You can change the settings of sendmail http://www.devshed.com/c/a/Administration/Getting-Started-with-Sendmail/12/ OR You can log text or database each email. $query = INSERT INTO mail_log (`subject`,`to`,`from`,`message`,`mail_date`) values ('.mysql_real_escape_string( $subject ).', '.mysql_real_escape_string( $to ).', '.mysql_real_escape_string( $from ).', '.mysql_real_escape_string( $message ).', '.date(Y-m-d H:i:s).') ; Or, you can Bcc: yourself and filter (procmail) the email into your sent-mail folder. Jonesy Or, if your mail server has IMAP access, use any PHP IMAP extension to connect to your IMAP server and send it from there. Then it will appear in your outbox. - Matijn Are you sure? I connect to my email through Imap on both my desktop and my phone, and neither sees the others sent emails. I thought sent was just a local thing, unless the email client is specifically configured to do something special. -- Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Re: w.r.t. mail() function
On Wed, May 23, 2012 at 9:33 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: ** On Wed, 2012-05-23 at 20:36 +0200, Matijn Woudt wrote: On Wed, May 23, 2012 at 3:50 PM, Jonesy gm...@jonz.net wrote: On Wed, 23 May 2012 00:24:25 -0400, admin wrote: -Original Message- From: Ashwani Kesharwani [mailto:ashwani.kesharw...@gmail.com ashwani.kesharw...@gmail.com] Sent: Wednesday, May 23, 2012 12:13 AM To: php-general@lists.php.net Subject: [PHP] w.r.t. mail() function Hi , I have a query w.r.t. mail() function in php. I have hosted my site and i have created an email account as well. when i am sending mail to different recipient from my php script using above function it is getting delivered to respective recipients as expected. However if I want to see those mail in the sent folder of my email account , i can not see those mails there. How can I achieve this. Any suggestions. Bad quoting above by the below: You can change the settings of sendmail http://www.devshed.com/c/a/Administration/Getting-Started-with-Sendmail/12/ OR You can log text or database each email. $query = INSERT INTO mail_log (`subject`,`to`,`from`,`message`,`mail_date`) values ('.mysql_real_escape_string( $subject ).', '.mysql_real_escape_string( $to ).', '.mysql_real_escape_string( $from ).', '.mysql_real_escape_string( $message ).', '.date(Y-m-d H:i:s).') ; Or, you can Bcc: yourself and filter (procmail) the email into your sent-mail folder. Jonesy Or, if your mail server has IMAP access, use any PHP IMAP extension to connect to your IMAP server and send it from there. Then it will appear in your outbox. - Matijn Are you sure? I connect to my email through Imap on both my desktop and my phone, and neither sees the others sent emails. I thought sent was just a local thing, unless the email client is specifically configured to do something special. Yes, I have a few applications that send email through IMAP and they end up in my sent mail box. Both with this Gmail account, and a mail server on a different host. You're clients are probably configured to still use SMTP for sending, not IMAP. - Matijn
[PHP] Stuck on undefined function mysql_connect()
I have been stuck on this, and have no idea what is causing it. I have compiled PHP with mysqli support: ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/php --with-mcrypt=/usr/local/bin/mcrypt --with-mysqli --with-gettext=./ext/gettext --with-pear --with-libxml-dir=/usr/include/libxml2 --with-zlib --with-gd --enable-pcntl mysqli MysqlI Supportenabled Client API library version 5.1.49 Active Persistent Links 0 Inactive Persistent Links 0 Active Links 0 Client API header version 5.1.49 MYSQLI_SOCKET /var/run/mysqld/mysqld.sock DirectiveLocal ValueMaster Value mysqli.allow_local_infileOnOn mysqli.allow_persistentOnOn mysqli.default_host*no value**no value* mysqli.default_port33063306 mysqli.default_pw*no value**no value* mysqli.default_socket*no value**no value* mysqli.default_user*no value**no value* mysqli.max_linksUnlimitedUnlimited mysqli.max_persistentUnlimited Unlimited mysqli.reconnectOffOff However, there is no mysqli.so or mysql.so found anywhere? Please help, I have fallen behind because of this. Nick.
Re: [PHP] Stuck on undefined function mysql_connect()
On Thu, Oct 13, 2011 at 14:19, Nick Khamis sym...@gmail.com wrote: I have been stuck on this, and have no idea what is causing it. I have compiled PHP with mysqli support: Right which will use mysqli_connect(), et al. If you didn't compile it with straight MySQL support, then the mysql_*() functions won't be there. However, there is no mysqli.so or mysql.so found anywhere? Please help, I have fallen behind because of this. It's compiled into the core, not as an extension. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stuck on undefined function mysql_connect()
On Thu, Oct 13, 2011 at 14:33, Nick Khamis sym...@gmail.com wrote: I was just going to try recompilign with mysql instead of mysqli... I hope this fixes it. In terms of mysql being compiled into the core, does this mean I do not have to add extension=mysqli.so extension_dir=/usr/local/php/include/php/ext/ (Please don't top-post, and be sure to click reply-all so that the discussion remains on the list for the benefit of others as well.) Correct. Extensions, such as those found in the PECL repository, are added in that manner. Things compiled into the core, such as what you're doing with MySQLi, are automatically loaded regardless, because they're statically-built into the PHP binary itself. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stuck on undefined function mysql_connect()
I was just going to try recompilign with mysql instead of mysqli... I hope this fixes it. In terms of mysql being compiled into the core, does this mean I do not have to add extension=mysqli.so extension_dir=/usr/local/php/ include/php/ext/ Thanks in Advance,
Re: [PHP] Stuck on undefined function mysql_connect()
Correct. Extensions, such as those found in the PECL repository, are added in that manner. Things compiled into the core, such as what you're doing with MySQLi, are automatically loaded regardless, because they're statically-built into the PHP binary itself.
[PHP] Call to undefined function
I am running a scheduled task for the first time since switching from linux to Windows IIS I am getting an error when the task runs. Fatal error: Call to undefined function mysql_connect() I ran php.exe -m to see that the MySQL Module is loaded. I have no issues unless I am running a php file in the Scheduled task. Any help would be appreciated Richard L. Buskirk
Re: [PHP] Call to undefined function
Sent from a handheld device On 24-Jun-2011, at 5:53 AM, ad...@buskirkgraphics.com wrote: I am running a scheduled task for the first time since switching from linux to Windows IIS I am getting an error when the task runs. Fatal error: Call to undefined function mysql_connect() I ran php.exe -m to see that the MySQL Module is loaded. I have no issues unless I am running a php file in the Scheduled task. Any help would be appreciated Richard, Create a sample scheduled task with a sample.php file. In that file call phpinfo() and save that content. After finishing the task find the configuration file (php.ini) location in your saved content. Just make sure mysql is activated there. Good luck Richard L. Buskirk
RE: [PHP] Call to undefined function
Okay, I am just start apologizing for my own ignorance. In the task scheduler I told the php.exe to use a older configuration file. TOTALLY my fault, seems PHP.ini file I used for the web was not the one I pointed the task manager at. Resolved and I will crawl back under my rock and read more about the proper Arguments for task manager next time before I post. Thanks Shiplu, and Negin for all your help. Richard L. Buskirk -Original Message- From: Shiplu Mokaddim [mailto:muquad...@gmail.com] Sent: Thursday, June 23, 2011 9:42 PM To: ad...@buskirkgraphics.com Cc: php-general@lists.php.net Subject: Re: [PHP] Call to undefined function Sent from a handheld device On 24-Jun-2011, at 5:53 AM, ad...@buskirkgraphics.com wrote: I am running a scheduled task for the first time since switching from linux to Windows IIS I am getting an error when the task runs. Fatal error: Call to undefined function mysql_connect() I ran php.exe -m to see that the MySQL Module is loaded. I have no issues unless I am running a php file in the Scheduled task. Any help would be appreciated Richard, Create a sample scheduled task with a sample.php file. In that file call phpinfo() and save that content. After finishing the task find the configuration file (php.ini) location in your saved content. Just make sure mysql is activated there. Good luck Richard L. Buskirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: First PHP site - thanks - euca_phpmysql function library
On 2/8/2011 4:58 PM, Donovan Brooke wrote: Hello, Just wanted to say thanks to those that helped me get through my first PHP project (over the last month). As is with much of the work we server-side language people do, the back-end (non-public) side of this site is perhaps the more interesting. However, here is the link to the site: http://www.impactseven.org/ They have full control over the content in the admin pages, and much of this content will soon change as I simply copy/pasted some of their old site's content to the database fields. btw, I7 is a great source for working capitol if you are in the need, and if you are in Wisconsin, USA. ;-) Also, for good karma ;-), here is a link to a small function library containing just a few (mostly MySQL) functions that I created for this site: http://www.euca.us/downloads/euca_phpmysql.zip (4KB) (if used, please keep the 'www.euca.us' credit in place) It has 4 functions: dbconnect global_id list_formvars list_vars You can read all about them in the file, but here is the basic rundown. dbconnect - basic connection/error reporting for MySQL global_id - If you've ever run into data relations changing between related tables, you may want to look into this one. ;-) list_formvars - list all request vars (for testing) with the option to display only certain matched vars. list_vars - list all set vars (for testing) with option to display only certain matched vars. The later two I usually post either at the end of the page, or at the end of page within !-- -- for testing/development purposes. Lastly, I'm sure I will add to this library as time goes by, but if you find that you've used it and made changes, drop me the file so I can learn as well. Thanks again!, Donovan Suggestion: Design for XHTML 1.1. It really doesn't require any significant additional effort and you'll already be current when it becomes the W3C standard. I like it because it forces me to create better, cleaner html code. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: First PHP site - thanks - euca_phpmysql function library
From: Al On 2/8/2011 4:58 PM, Donovan Brooke wrote: Hello, Just wanted to say thanks to those that helped me get through my first PHP project (over the last month). As is with much of the work we server-side language people do, the back-end (non-public) side of this site is perhaps the more interesting. Suggestion: Design for XHTML 1.1. It really doesn't require any significant additional effort and you'll already be current when it becomes the W3C standard. I like it because it forces me to create better, cleaner html code. You should also use the HTML Validator plug-in for Firefox to make sure you are producing valid XHTML. That makes it so much easier to find those invisible problems. I can't count how many times it has pointed right at a logic flaw in my code. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: First PHP site - thanks - euca_phpmysql function library
On 9 February 2011 14:57, Bob McConnell r...@cbord.com wrote: From: Al On 2/8/2011 4:58 PM, Donovan Brooke wrote: Hello, Just wanted to say thanks to those that helped me get through my first PHP project (over the last month). As is with much of the work we server-side language people do, the back-end (non-public) side of this site is perhaps the more interesting. Suggestion: Design for XHTML 1.1. It really doesn't require any significant additional effort and you'll already be current when it becomes the W3C standard. I like it because it forces me to create better, cleaner html code. You should also use the HTML Validator plug-in for Firefox to make sure you are producing valid XHTML. That makes it so much easier to find those invisible problems. I can't count how many times it has pointed right at a logic flaw in my code. Bob McConnell Or go with the more likely candidate for a future html standard: html 5. Has the added benefit of easing you in to the new tags that will be used as standard in a few years but won't be in xhtml. Regards Peter -- hype WWW: plphp.dk / plind.dk LinkedIn: plind BeWelcome/Couchsurfing: Fake51 Twitter: kafe15 /hype -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: First PHP site - thanks - euca_phpmysql function library
From: Peter Lind On 9 February 2011 14:57, Bob McConnell r...@cbord.com wrote: From: Al On 2/8/2011 4:58 PM, Donovan Brooke wrote: Hello, Just wanted to say thanks to those that helped me get through my first PHP project (over the last month). As is with much of the work we server-side language people do, the back-end (non-public) side of this site is perhaps the more interesting. Suggestion: Design for XHTML 1.1. It really doesn't require any significant additional effort and you'll already be current when it becomes the W3C standard. I like it because it forces me to create better, cleaner html code. You should also use the HTML Validator plug-in for Firefox to make sure you are producing valid XHTML. That makes it so much easier to find those invisible problems. I can't count how many times it has pointed right at a logic flaw in my code. Or go with the more likely candidate for a future html standard: html 5. Has the added benefit of easing you in to the new tags that will be used as standard in a few years but won't be in xhtml. I don't believe HTML 5 will ever be completed. Microsoft is working hard behind the scenes to block it unless it only allows their codec's behind the video and canvas tags. (Their efforts are very reminiscent of their sabotage of ISO with the OOXML specification.) From a recent announcement(*), it appears that even the committee has given up ever having a usable consensus, but will accept whatever the browser developers want to implement even if they are incompatible with other browsers. That's not a standard. Bob McConnell (*) http://blog.whatwg.org/html-is-the-new-html5 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: First PHP site - thanks - euca_phpmysql function library
On 9 February 2011 17:22, Bob McConnell r...@cbord.com wrote: From: Peter Lind On 9 February 2011 14:57, Bob McConnell r...@cbord.com wrote: From: Al On 2/8/2011 4:58 PM, Donovan Brooke wrote: Hello, Just wanted to say thanks to those that helped me get through my first PHP project (over the last month). As is with much of the work we server-side language people do, the back-end (non-public) side of this site is perhaps the more interesting. Suggestion: Design for XHTML 1.1. It really doesn't require any significant additional effort and you'll already be current when it becomes the W3C standard. I like it because it forces me to create better, cleaner html code. You should also use the HTML Validator plug-in for Firefox to make sure you are producing valid XHTML. That makes it so much easier to find those invisible problems. I can't count how many times it has pointed right at a logic flaw in my code. Or go with the more likely candidate for a future html standard: html 5. Has the added benefit of easing you in to the new tags that will be used as standard in a few years but won't be in xhtml. I don't believe HTML 5 will ever be completed. Microsoft is working hard behind the scenes to block it unless it only allows their codec's behind the video and canvas tags. (Their efforts are very reminiscent of their sabotage of ISO with the OOXML specification.) From a recent announcement(*), it appears that even the committee has given up ever having a usable consensus, but will accept whatever the browser developers want to implement even if they are incompatible with other browsers. That's not a standard. Html 5 has a fair chance of not being completed (that's going by what Ian Hickson has stated as well as reading blogs and such on the matter - see http://en.wikipedia.org/wiki/HTML5 for a pointer or two). That's besides the point, though: html 5 *is* where the web is headed, as opposed to xhtml. In part this is happening by browsers implementing features piece by piece as they become stable - hence, you can already use some html 5 features and be rather certain they'll work as expected later on. MS may hate things not working how they like it, but big and stupid as they are they have in fact figured out that the web will happily move on without them - so they'll get round to implementing html 5 features as well, at some point, even if it doesn't use their proprietary code. Regards Peter -- hype WWW: plphp.dk / plind.dk LinkedIn: plind BeWelcome/Couchsurfing: Fake51 Twitter: kafe15 /hype -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] First PHP site - thanks - euca_phpmysql function library
Hello, Just wanted to say thanks to those that helped me get through my first PHP project (over the last month). As is with much of the work we server-side language people do, the back-end (non-public) side of this site is perhaps the more interesting. However, here is the link to the site: http://www.impactseven.org/ They have full control over the content in the admin pages, and much of this content will soon change as I simply copy/pasted some of their old site's content to the database fields. btw, I7 is a great source for working capitol if you are in the need, and if you are in Wisconsin, USA. ;-) Also, for good karma ;-), here is a link to a small function library containing just a few (mostly MySQL) functions that I created for this site: http://www.euca.us/downloads/euca_phpmysql.zip (4KB) (if used, please keep the 'www.euca.us' credit in place) It has 4 functions: dbconnect global_id list_formvars list_vars You can read all about them in the file, but here is the basic rundown. dbconnect - basic connection/error reporting for MySQL global_id - If you've ever run into data relations changing between related tables, you may want to look into this one. ;-) list_formvars - list all request vars (for testing) with the option to display only certain matched vars. list_vars - list all set vars (for testing) with option to display only certain matched vars. The later two I usually post either at the end of the page, or at the end of page within !-- -- for testing/development purposes. Lastly, I'm sure I will add to this library as time goes by, but if you find that you've used it and made changes, drop me the file so I can learn as well. Thanks again!, Donovan -- D Brooke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] include() and duplicate function definition
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 -- 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
[PHP] include() and duplicate function definition
Hi Thijs, :-) On Wed, Nov 3, 2010 at 18:18, Thijs Lensselink d...@lenss.nl wrote: 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? If the functions aren't named the same, my replacement function will never get called by the code that uses the WordPress theme code... Try to create a new function and call the original function from there if needed... Sadly, it wouldn't work for the above reason... But thanks for your answer. :-) David Nelson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include() and duplicate function definition
You can check with function_exists to see if a function is already defined. If not, create it. Regards Peter On Nov 3, 2010 11:40 AM, David Nelson comme...@traduction.biz wrote: Hi Thijs, :-) On Wed, Nov 3, 2010 at 18:18, Thijs Lensselink d...@lenss.nl wrote: 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? If the functions aren't named the same, my replacement function will never get called by the code that uses the WordPress theme code... Try to create a new function and call the original function from there if needed... Sadly, it wouldn't work for the above reason... But thanks for your answer. :-) David Nelson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include() and duplicate function definition
Hi Peter, :-) On Wed, Nov 3, 2010 at 18:44, Peter Lind peter.e.l...@gmail.com wrote: You can check with function_exists to see if a function is already defined. If not, create it. The function is definitely already defined, I just need to replace it without touching the file in which it's defined... David Nelson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include() and duplicate function definition
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. On Nov 3, 2010 11:55 AM, David Nelson comme...@traduction.biz wrote: Hi Peter, :-) On Wed, Nov 3, 2010 at 18:44, Peter Lind peter.e.l...@gmail.com wrote: You can check with function_exists to see if a function is already defined. If not, create it. The function is definitely already defined, I just need to replace it without touching the file in which it's defined... David Nelson
Re: [PHP] include() and duplicate function definition
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 -- 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
[PHP] include() and duplicate function definition
Hi Thijs, :-) On Wed, Nov 3, 2010 at 20:38, Thijs Lensselink d...@lenss.nl wrote: 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. It's a WordPress issue. When theme updates become available from the original vendor, you can update them from within the admin backend. In that case, any hacks you've applied (such as removing a function) get overwritten. So the evangelized solution is to create a child theme. The child theme incorporates only files that you've added or changed, with the original parent theme being used for all others. Easy peasy if you want to *add* a function. But, if you want to *modify* a function, you're faced with the problem of the original function still being present in the parent theme files and of your having to define a function of the same name in your child theme (if you change the function name, you then have to hack other code further upstream, and the work involved becomes not worth the bother). Somehow, I would need to make my hacked function *replace* the original function, *without* touching the original function... It seems like that's not possible and I'll have to find another solution... unless my explanation gives you any good ideas? Just to put the dots on the I's, the original actions.php contains a lot of *other* functions that I don't want to touch, and that I do want to leave exposed to the updates process. It's just one single function I want to hack... Sticky problem, huh? :-) In any case, thanks for your kind help, :-) David Nelson P.S. Sorry about the direct mails: I keep forgetting to hit the Replly to all button. -- 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 Thu, 2010-11-04 at 00:00 +0800, David Nelson wrote: Hi Thijs, :-) On Wed, Nov 3, 2010 at 20:38, Thijs Lensselink d...@lenss.nl wrote: 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. It's a WordPress issue. When theme updates become available from the original vendor, you can update them from within the admin backend. In that case, any hacks you've applied (such as removing a function) get overwritten. So the evangelized solution is to create a child theme. The child theme incorporates only files that you've added or changed, with the original parent theme being used for all others. Easy peasy if you want to *add* a function. But, if you want to *modify* a function, you're faced with the problem of the original function still being present in the parent theme files and of your having to define a function of the same name in your child theme (if you change the function name, you then have to hack other code further upstream, and the work involved becomes not worth the bother). Somehow, I would need to make my hacked function *replace* the original function, *without* touching the original function... It seems like that's not possible and I'll have to find another solution... unless my explanation gives you any good ideas? Just to put the dots on the I's, the original actions.php contains a lot of *other* functions that I don't want to touch, and that I do want to leave exposed to the updates process. It's just one single function I want to hack... Sticky problem, huh? :-) In any case, thanks for your kind help, :-) David Nelson P.S. Sorry about the direct mails: I keep forgetting to hit the Replly to all button. I am curious on how this would work, if for some reason they were using a different template? the function you want to overwrite, wont be used, and therefore, wouldn't your app/template/whatever be updated improperly than waht you expect it to be? Just curious... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include() and duplicate function definition
Hi guys, :-) Just FYI, I got this answer from the theme dev: David, You don't need the include statement. If you create your function in wp-content/themes/suffusion-child/functions.php it will get automatically included. Secondly, using the same function name wouldn't work, because it would require me to encase the original function definition in actions.php in a function_exists clause. I would suggest using a different function name, then using remove_action to remove the older action and add_action to add the new action. (http://www.aquoid.com/forum/viewtopic.php?f=4t=3070) I'm not yet confident about how to actually implement this in code... Any tips or advice would be gratefully heard. On Thu, Nov 4, 2010 at 00:13, Steve Staples sstap...@mnsi.net wrote: I am curious on how this would work, if for some reason they were using a different template? the function you want to overwrite, wont be used, and therefore, wouldn't your app/template/whatever be updated improperly than waht you expect it to be? Steve, maybe the above informs? In any case, the function to be overwritten is likely to remain fairly stable... All the best, :-) David Nelson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Filesystem path creation function
On 5 October 2010 09:07, Gary php-gene...@garydjones.name wrote: Does such a thing exist in php? My searches have lead nowhere. What I am looking for is a function which you would pass two parts of a path to (which might be a directory and a filename, say) and it would return a string containing the parameters separate by the correct number of path separators according to the current OS. For example: ?php $d = 'foo'; $f = 'bar'; $path = createPathString($d, $f); ? Would result in 'foo\bar' (Windows), 'foo/bar' (*n*x). And ?php $d = 'foo/'; // note the trailing slash $f = 'bar'; $path = createPathString($d, $f); ? on *n*x would also result in 'foo/bar' (i.e. the path would only contain one /). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Yep. function createPathString($d, $f){return $d. DIRECTORY_SEPARATOR . $f;} -- 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] Filesystem path creation function
On 5 October 2010 09:07, Gary php-gene...@garydjones.name wrote: Does such a thing exist in php? My searches have lead nowhere. What I am looking for is a function which you would pass two parts of a path to (which might be a directory and a filename, say) and it would return a string containing the parameters separate by the correct number of path separators according to the current OS. For example: ?php $d = 'foo'; $f = 'bar'; $path = createPathString($d, $f); ? Would result in 'foo\bar' (Windows), 'foo/bar' (*n*x). And ?php $d = 'foo/'; // note the trailing slash $f = 'bar'; $path = createPathString($d, $f); ? on *n*x would also result in 'foo/bar' (i.e. the path would only contain one /). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php http://www.php.net/manual/en/dir.constants.php -- 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
[PHP] Problem with pg_prepare function
Hi all. I'm receiving the following message when I try to use pg_prepare() function: Call to undefined function pg_prepare(). My application works very well with others pg_* commands... I already checked my configuration files and I have no more ideas about how to fix it. Any suggestions? Thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with pg_prepare function
On Fri, Apr 23, 2010 at 9:42 PM, Giancarlo Boaron gboa...@yahoo.com.brwrote: Hi all. I'm receiving the following message when I try to use pg_prepare() function: Call to undefined function pg_prepare(). My application works very well with others pg_* commands... I already checked my configuration files and I have no more ideas about how to fix it. Any suggestions? Thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Maybe something like this situation (a few years back, but perhaps still relevant): http://www.issociate.de/board/post/384415/Undefined_pg_prepare()_in_5.6.1.html http://www.issociate.de/board/post/384415/Undefined_pg_prepare()_in_5.6.1.html Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com
Re: [PHP] a trivial little function (PostToHost)
At 12:27 PM -0600 10/4/09, kirk.john...@zootweb.com wrote: tedd tedd.sperl...@gmail.com wrote on 10/04/2009 08:51:13 AM: [PHP] a trivial little function (PostToHost) tedd to: php-general 10/04/2009 09:05 AM Hi gang: The following 'trivial little' function I'm trying to get my head around: http://aspn.activestate.com/ASPN/Mail/Message/php-general/1259426 The article states: Either way, just generate your XML string and fire it at the remote machine. You will need to write code to handle the response, obviously. Okay, so how does one handle the response? I understand that one should have the script at host A sending data to host B, but I can't seem to get it to work. Does anyone have an example that works? My confusion here -- is the data sent by the function at host A accessible by host B via a POST, or does it write to a writable file, or what? Any help would be appreciated. Cheers, tedd Yes, this is just a standard HTTP POST, just like what a browser does when you click a submit button. So, there needs to be a script that handles a standard POST on server B. It will send whatever response it is designed to. Just think of server A as a browser submitting a form and server B is you writing a PHP script to handle the form submission :) Hi Kirk: Okay, but what specifically is that script? I have written a script at server B to print_r($_POST), but I don't get anything other than log errors (see below*). Here's an example: http://www.webbytedd.com/aa/send-form/index.php You can enter anything into the webbytedd.com form (Server A) and click submit, but the php1.net form (Server B) won't show anything -- what am I doing wrong? Cheers, tedd * Log errors: [05-Oct-2009 15:08:54] PHP Warning: PHP Startup: mm_create(0, /session_mm_cgi-fcgi522) failed, err mm:core: failed to open semaphore file (Permission denied) in Unknown on line 0 -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] a trivial little function (PostToHost)
tedd tedd.sperl...@gmail.com wrote on 10/05/2009 01:44:00 PM: [snip] Hi Kirk: Okay, but what specifically is that script? I have written a script at server B to print_r($_POST), but I don't get anything other than log errors (see below*). Here's an example: http://www.webbytedd.com/aa/send-form/index.php You can enter anything into the webbytedd.com form (Server A) and click submit, but the php1.net form (Server B) won't show anything -- what am I doing wrong? Cheers, tedd * Log errors: [05-Oct-2009 15:08:54] PHP Warning: PHP Startup: mm_create(0, /session_mm_cgi-fcgi522) failed, err mm:core: failed to open semaphore file (Permission denied) in Unknown on line 0 I am not familiar with this PHP error. Was this on server B? With PHP Startup in the error message, it looks like a setup problem on server B, rather than being related to the PostToHost operation. Once that error is cleared up, start simple for the PostToHost piece. Just have the script on server B return hello,world!, then echo out that response in the script on server A. The PostToHost function you found is correct. Make sure you are passing in valid arguments, so that you end up with a valid HTTP POST message. Kirk
[PHP] a trivial little function (PostToHost)
Hi gang: The following 'trivial little' function I'm trying to get my head around: http://aspn.activestate.com/ASPN/Mail/Message/php-general/1259426 The article states: Either way, just generate your XML string and fire it at the remote machine. You will need to write code to handle the response, obviously. Okay, so how does one handle the response? I understand that one should have the script at host A sending data to host B, but I can't seem to get it to work. Does anyone have an example that works? My confusion here -- is the data sent by the function at host A accessible by host B via a POST, or does it write to a writable file, or what? Any help would be appreciated. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] a trivial little function (PostToHost)
tedd tedd.sperl...@gmail.com wrote on 10/04/2009 08:51:13 AM: [PHP] a trivial little function (PostToHost) tedd to: php-general 10/04/2009 09:05 AM Hi gang: The following 'trivial little' function I'm trying to get my head around: http://aspn.activestate.com/ASPN/Mail/Message/php-general/1259426 The article states: Either way, just generate your XML string and fire it at the remote machine. You will need to write code to handle the response, obviously. Okay, so how does one handle the response? I understand that one should have the script at host A sending data to host B, but I can't seem to get it to work. Does anyone have an example that works? My confusion here -- is the data sent by the function at host A accessible by host B via a POST, or does it write to a writable file, or what? Any help would be appreciated. Cheers, tedd Yes, this is just a standard HTTP POST, just like what a browser does when you click a submit button. So, there needs to be a script that handles a standard POST on server B. It will send whatever response it is designed to. Just think of server A as a browser submitting a form and server B is you writing a PHP script to handle the form submission :) Typically, I write the fgets line a little differently. Instead of: while(!feof($fp)) { echo fgets($fp, 128); } I use: $response = ''; while(!feof($fp)) { $response .= fgets($fp, 128); } // parse the response and do something Kirk
[PHP] issue with mail function
I have recently been working a lot lately with arrays and printing them into html tables for email (like a user survey for example). I have been seeing odd things with the table lately, each unique to it's sending php file. I will get a space in a random spot. In one, I used an array to rename the Name values of input fields to more readable ones, whatadd becomes What to Add, only the word 'Add' is spelled 'Ad d'. With my recent mail script (submitting a customer profile change), I get it in a similar area, a Name value renamed and I get Emp loyee in the table cell. The adjacent cell is fine though, reading Needs Handicap Accommodations. I will post some of my code to show that I haven't misplaced a space: [code] 1. ?php 2. 3. //CHECKS TO SEE IF FIELDS WERE PROPERLY COMPLETED AND ASSIGNS VARIABLES TO INPUTS - OTHERWISE AN ERROR MESSAGE IS PRINTED 4. 5. $Employee = $_POST['Employee']; 6. 7. $fields2 = array(); 8. 9. $fields2{Employee} = Employee; 10. $fields2{IsHandicappedAccommodations} = Needs Handicap Accommodations; 11. 12. $body = We have received the following information:\n\nhtmlbodytable cellspacing='2' cellpadding='2'border= '1'tr valign='top'; 13. 14. 15. //FOREACH LOOP 16. 17. $headerlabel = '0'; 18. 19. foreach ($fields as $x = $y) { 20. $headerlabel = $headerlabel +1; 21. $body .= td{$headerlabel}brimg src=' http://lpacmarketing.hostzi.com/images/spacer.gif' width='120' height='1' /td; 22. } 23. 24. 25. $body .= /trtr valign='top'; 26. 27. foreach ($fields2 as $x = $y) 28. $body .= td{$y}/td; 29. 30. $body .= /trtr valign='top'; 31. 32. foreach ($fields2 as $x = $y) 33. $body .= td{$_REQUEST[$x]}/td; 34. 35. $body .= /trtr valign='top'td colspan='9'; 36. 37. foreach ($fields as $a = $b) { 38. $body .= sprintf(%s\n,$b); 39. } 40. 41. $body .= brbr; 42. 43. foreach ($fields as $a = $b) { 44. $body .= sprintf(%s\n,$_POST[$a]); 45. } 46. 47. $body .= /td/tr/table/body/html; 48. 49. //END FOREACH LOOPS [/code] This is all the code I think is really relevant, but if you think I left something out I'll be happy to share with you all the code. This is not a major issue for me, it is just so strange, and if someone could provide some insight, it would be great.
RE: [PHP] issue with mail function
From: Allen McCabe I have recently been working a lot lately with arrays and printing them into html tables for email (like a user survey for example). I have been seeing odd things with the table lately, each unique to it's sending php file. I will get a space in a random spot. In one, I used an array to rename the Name values of input fields to more readable ones, whatadd becomes What to Add, only the word 'Add' is spelled 'Ad d'. With my recent mail script (submitting a customer profile change), I get it in a similar area, a Name value renamed and I get Emp loyee in the table cell. The adjacent cell is fine though, reading Needs Handicap Accommodations. I will post some of my code to show that I haven't misplaced a space: How far apart are these spaces? Is something on your server injecting new lines on lines of text it thinks are too long? This would be displayed by the browser as a space. View source at the browser to see what was actually added. If this is the case, I suspect you are running on a Microsoft platform and forgot to set binary mode somewhere. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Page or URL function?
I've been searching php.net for a function to do this: if page_url('browse.php') { $default = A; } $letter = isset($_GET['letter'])? $_GET['letter'] :$default ; else { $letter = isset($_GET['letter'])? $_GET['letter'] : ; } I want to say if the page is browse, default to the A listings, if the page is not browse show no default listings (because there is other data on the page and I don't want this to output) I thought there was url functionsam I calling it something different? Terion -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Call to object function, want to PHP interpret returned string
Hi At the top of a webpage I have: ?php include_once(furniture.php); $myFurniture = new furniture(); echo $myFurniture-getTop(my company title); ? to deliver the first lines of HTML, everything in HEAD and the first bits of page furniture (menu, etc). In the furniture object in getTop(), I want to return a string that includes the CSS file that I call with an include_once. But the include_once isn't interpreted by PHP, it's just outputted. So from: $toReturn = !DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' ?php include_once('styles3.txt'); ? ...; return $toReturn; I get ?php include_once('styles3.txt'); ? in my code. Do I really have to break up my echo $myFurniture-getTop(my company title); call to getTopTop, then include my CSS, then call getTopBottom, or can I get PHP to interpret that text that came back? PS. I may be stupid, this may be obvious .. I don't program PHP every day Thanks in advance for your help :-) Cheers J -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] error in printer_open function
hi, i am using local server to print a simple text i config the php.ini file as ;extension=php_printer.dll added in the extension list and add [printer] printer.default_printer = Send To OneNote 2007 in this file and write a sim ple page as- Prabal Cable Network
[PHP] Re: pdf_new() uncalled Function
Alice Wei wrote: Hi, I use Linux, and I had installed PHP using yum install php. I am trying to use the pdf_new function to create pdfs from existing text files, but I get this error PHP Fatal error: Call to undefined function pdf_new() I have noticed that when I run the phpinfo() command, I cannot find the PDF phrase at all. My php.ini file does not even have these two lines extension=php_pdf.dll extension=php_cpdf.dll Could anyone suggest me what kind of command I should use if I need to build PDFs using PHP on a Linux system? Thanks in advance. Alice _ Express yourself with gadgets on Windows Live Spaces http://discoverspaces.live.com?source=hmtag1loc=us If you have pear/pecl installed you can run: pecl install pdflib If not: yum install php-pear -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with function
Jason Pruim wrote: So, I am fighting with a problem function... I have used this function on a previous project and it worked just fine, so I'm not sure what changed... The only difference is that on this site, I'm using mod_rewrite to write all non-existent folder requests into a php file to process what to do with it. here's some code: processing file: ?PHP require(php.ini.php); require(dbmysqliconnect.php); require(defaults.php); require(notify_email.php); $link = dbmysqliconnect($server, $username, $password, $database, $link); $date = time(); //Do NOT insert or update sales rep database through this method... Only included to be supplied to the notify_email function. JP $salesRepID = $_POST['txtSalesRepID']; $Record= $_POST['txtRecord']; notify_email($Record, $salesRepID); $stmt = mysqli_stmt_init($link); //Create the statement mysqli_stmt_prepare($stmt, UPDATE purl.schreur SET FName = ?, LName = ?, email = ?, phone = ?, record = ?, subscribed = ?, date = ?, IPAddress = ?, Business = ?, Address1 = ?, City = ?, State = ?, Zip = ?, Coffee = ?, Meeting = ?, time = ?) or die(prepare error . mysqli_error($link)); mysqli_stmt_bind_param($stmt, '', $_POST['txtFName'], $_POST['txtLName'], $_POST['txtEmail'], $_POST['txtPhone'], $_POST['record'], $_POST['subscribed'], $date, $_SERVER['REMOTE_ADDR'], $_POST['txtBusiness'], $_POST['txtAddress1'], $_POST['txtCity'], $_POST['txtState'], $_POST['txtZip'], $_POST['rdoCoffee'], $_POST['rdoTime'], $_POST['areaPlans']) or die( bind error . mysqli_error($link)); //Add the record mysqli_stmt_execute($stmt) or die( execute error . mysqli_error($link)); ? notify_email.php file: ?PHP function notify_email($Record, $salesRepID) { require(defaults.php); require(func.sendemail.php); require(dbmysqliconnect.php); $salesRep = array(1 = [EMAIL PROTECTED], [EMAIL PROTECTED], 2 = [EMAIL PROTECTED], [EMAIL PROTECTED], 3 =[EMAIL PROTECTED], 4=[EMAIL PROTECTED]); echo 1; $link1 = dbmysqliconnect($server, $username, $password, $database, $link); echo 2; $sql = SELECT * FROM schreur WHERE record='{$Record}'; $row[] = mysqli_query($link1, $sql) or die(Could not perform query: .mysqli_errno($link1)); echo 3; $result = $row[0]; echo 4; //$dataSet = array(); //while ($row = mysqli_fetch_assoc($result)) { //echo brwhileBR; //$dataSet[] = $row; //} $from= [EMAIL PROTECTED]; echo 5; $returnPath = [EMAIL PROTECTED]; $replyTo = [EMAIL PROTECTED]; echo $Record; echo 6; //echo brJust before while in notify_email.phpbr; //echo brdirectly above whilebr; //echo BRdataset print: ; //print_r($dataSet); //echo BR; //echo brdirectly above foreachbr; //foreach ( $dataSet AS $row ) { echo 6; while ($row = mysqli_fetch_assoc($result)) { echo inside while; //Build the e-mail headers $ID = $row['salesRep']; $to = $salesRep[$ID]; $headers = From: .$from.\n; $headers .= Return-Path: .$returnPath.\n; $headers .= Reply-To: .$replyTo.\n; $subject = {$row['FName']} wants coffee!; $message = First Name: {$row['FName']} \n; $message .= Last Name: {$row['LName']}\n; $message .= Company . $row['Business'] . \n; $message .= Email: .$row['email'] . \n; $message .= Phone: .$row['phone'] . \n; $message .= Address: . $row['Address1'] . \n; $message .= City: . $row['City'] . \n; $message .= State: .$row['State'] . \n; $message .= Zip: . $row['Zip'] . \n; $message .= Coffee of choice: .$row['Coffee'] . \n\n; $message .= When a good time would be: \n.$row['Meeting'] . \n\n; $message .= Current plans: \n\n
Re: [PHP] Re: Problem with function
On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote: Jason Pruim wrote: nothing obvious to me.. so debug more! ?PHP function notify_email($Record, $salesRepID) { echo in notify_email . PHP_EOL; require(defaults.php); echo already loaded and required defaults loaded . PHP_EOL; require(func.sendemail.php); echo require func.sendemail.php loaded . PHP_EOL; require(dbmysqliconnect.php); echo already loaded and required dbmysqliconnect loaded . PHP_EOL; will tell you where it's breaking I'd assume.. Okay, when I had that in the notify_email.php file it looked like it all loaded just fine... the echo's were displayed. When I put that in my process.php file I got this output: already loaded and required defaults loaded Just before send_email functionjust after send_email funtion require func.sendemail.php loaded already loaded and required dbmysqliconnect loaded execute error Duplicate entry '0' for key 1 So I think Jochem might be right... Problem with mysqli? -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with function
On Sep 12, 2008, at 9:21 AM, Jason Pruim wrote: On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote: Jason Pruim wrote: nothing obvious to me.. so debug more! ?PHP function notify_email($Record, $salesRepID) { echo in notify_email . PHP_EOL; require(defaults.php); echo already loaded and required defaults loaded . PHP_EOL; require(func.sendemail.php); echo require func.sendemail.php loaded . PHP_EOL; require(dbmysqliconnect.php); echo already loaded and required dbmysqliconnect loaded . PHP_EOL; will tell you where it's breaking I'd assume.. Okay, when I had that in the notify_email.php file it looked like it all loaded just fine... the echo's were displayed. When I put that in my process.php file I got this output: already loaded and required defaults loaded Just before send_email functionjust after send_email funtion require func.sendemail.php loaded already loaded and required dbmysqliconnect loaded execute error Duplicate entry '0' for key 1 So I think Jochem might be right... Problem with mysqli? Okay scratch that... I was attempting to update the auto_increment field so when I changed that, it got rid of the error but didn't fix the problem :) -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with function
Jason Pruim wrote: On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote: Jason Pruim wrote: nothing obvious to me.. so debug more! ?PHP function notify_email($Record, $salesRepID) { echo in notify_email . PHP_EOL; require(defaults.php); echo already loaded and required defaults loaded . PHP_EOL; require(func.sendemail.php); echo require func.sendemail.php loaded . PHP_EOL; require(dbmysqliconnect.php); echo already loaded and required dbmysqliconnect loaded . PHP_EOL; will tell you where it's breaking I'd assume.. Okay, when I had that in the notify_email.php file it looked like it all loaded just fine... the echo's were displayed. When I put that in my process.php file I got this output: already loaded and required defaults loaded Just before send_email functionjust after send_email funtion require func.sendemail.php loaded already loaded and required dbmysqliconnect loaded execute error Duplicate entry '0' for key 1 So I think Jochem might be right... Problem with mysqli? -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] actually on closer inspection the problem looks here.. following requires 16 params: mysqli_stmt_prepare($stmt, UPDATE purl.schreur SET FName = ?, LName = ?, email = ?, phone = ?, record = ?, subscribed = ?, date = ?, IPAddress = ?, Business = ?, Address1 = ?, City = ?, State = ?, Zip = ?, Coffee = ?, Meeting = ?, time = ?) or die(prepare error . mysqli_error($link)); 17 params bound AND rdoTime + areaPlans are in wrong order or are just wrong.. mysqli_stmt_bind_param($stmt, '', $_POST['txtFName'], $_POST['txtLName'], $_POST['txtEmail'], $_POST['txtPhone'], $_POST['record'], $_POST['subscribed'], $date, $_SERVER['REMOTE_ADDR'], $_POST['txtBusiness'], $_POST['txtAddress1'], $_POST['txtCity'], $_POST['txtState'], $_POST['txtZip'], $_POST['rdoCoffee'], $_POST['rdoTime'], $_POST['areaPlans']) or die( bind error . mysqli_error($link)); may help; probable causing the duplciate error problem; (doesn't explain first error though) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with function
Nathan Rixham wrote: Jason Pruim wrote: On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote: Jason Pruim wrote: nothing obvious to me.. so debug more! [snip snip snip] have to say this: error_reporting( E_ALL ); at the top would help; + display_errors on in php.ini and problem is probably due to duplciate variable/constant definition in default.php or dbmysqliconnect.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with function
On Sep 12, 2008, at 9:34 AM, Nathan Rixham wrote: Nathan Rixham wrote: Jason Pruim wrote: On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote: Jason Pruim wrote: nothing obvious to me.. so debug more! [snip snip snip] have to say this: error_reporting( E_ALL ); at the top would help; + display_errors on in php.ini and problem is probably due to duplciate variable/ constant definition in default.php or dbmysqliconnect.php I could agree more... which is why I have this: ini_set('error_reporting', E_ALL); But the log isn't showing anything... My error log for the site has this: [Fri Sep 12 09:40:54 2008] [debug] mod_rewrite.c(1643): [client 192.168.0.253] mod_rewrite's internal redirect status: 0/10. -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with function
Jason Pruim schreef: On Sep 12, 2008, at 9:34 AM, Nathan Rixham wrote: Nathan Rixham wrote: Jason Pruim wrote: On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote: Jason Pruim wrote: nothing obvious to me.. so debug more! [snip snip snip] have to say this: error_reporting( E_ALL ); at the top would help; + display_errors on in php.ini and problem is probably due to duplciate variable/constant definition in default.php or dbmysqliconnect.php I could agree more... which is why I have this: ini_set('error_reporting', E_ALL); But the log isn't showing anything... php.ini is what he said. My error log for the site has this: [Fri Sep 12 09:40:54 2008] [debug] mod_rewrite.c(1643): [client 192.168.0.253] mod_rewrite's internal redirect status: 0/10. -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with function
On Sep 12, 2008, at 9:46 AM, Jochem Maas wrote: Jason Pruim schreef: On Sep 12, 2008, at 9:34 AM, Nathan Rixham wrote: Nathan Rixham wrote: Jason Pruim wrote: On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote: Jason Pruim wrote: nothing obvious to me.. so debug more! [snip snip snip] have to say this: error_reporting( E_ALL ); at the top would help; + display_errors on in php.ini and problem is probably due to duplciate variable/ constant definition in default.php or dbmysqliconnect.php I could agree more... which is why I have this: ini_set('error_reporting', E_ALL); But the log isn't showing anything... php.ini is what he said. isn't it the same difference? -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with function
Jochem Maas wrote: Jason Pruim schreef: On Sep 12, 2008, at 9:34 AM, Nathan Rixham wrote: Nathan Rixham wrote: Jason Pruim wrote: On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote: Jason Pruim wrote: nothing obvious to me.. so debug more! [snip snip snip] have to say this: error_reporting( E_ALL ); at the top would help; + display_errors on in php.ini and problem is probably due to duplciate variable/constant definition in default.php or dbmysqliconnect.php I could agree more... which is why I have this: ini_set('error_reporting', E_ALL); But the log isn't showing anything... php.ini is what he said. My error log for the site has this: [Fri Sep 12 09:40:54 2008] [debug] mod_rewrite.c(1643): [client 192.168.0.253] mod_rewrite's internal redirect status: 0/10. -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] display_errors in php.ini is what you want; makes life easier while developing; and good to have E_STRICT and E_ALL set for err reporting; then you can catch every tiny potential future bug as well :) ps did you read the one about your bind variables being in the wrong order and too many? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP]About the magic function __call
Hi there! I'm working with the following code: ?php abstract class Foo{ protected $a; protected $b; protected $c; function __construct($arg){ $this-a = $arg; } function __call($function, $args){ $this-b = $function; $this-c = $args; $this-doWhatever(); } private doWhatever(){ } } class Boo extends Foo{ protected $e; public function __construct(){ parent::__construct('Blah'); } public function drive(){ $e = 'testing'; parent::drive($e); } } $br = new Boo(); $br-drive(); But I get a Fatal error: Call to undefined method Foo::drive() The magic fuction __call don't catch the drive(). Why not? I need another idea for this problem and avoid edit the abstract class. Sorry about the english. Thanks for any help
Re: [PHP]About the magic function __call
On Wed, Aug 27, 2008 at 1:35 PM, Paulo Sousa [EMAIL PROTECTED]wrote: Hi there! I'm working with the following code: ?php abstract class Foo{ protected $a; protected $b; protected $c; function __construct($arg){ $this-a = $arg; } function __call($function, $args){ $this-b = $function; $this-c = $args; $this-doWhatever(); } private doWhatever(){ } } class Boo extends Foo{ protected $e; public function __construct(){ parent::__construct('Blah'); } public function drive(){ $e = 'testing'; parent::drive($e); } } $br = new Boo(); $br-drive(); But I get a Fatal error: Call to undefined method Foo::drive() The magic fuction __call don't catch the drive(). Why not? I need another idea for this problem and avoid edit the abstract class. looks like __call() might not work through a subclass if defined in the parent; i might poke around in the .phpt tests that come w/ the php source to ensure this is the correct behavior. in the meantime you can get away w/ some variant this ugliness, class B extends A { function __call($method, $args) { return parent::__call($method, $args); } } -nathan
Re: [PHP]About the magic function __call
On Wed, Aug 27, 2008 at 1:49 PM, Nathan Nobbe [EMAIL PROTECTED]wrote: On Wed, Aug 27, 2008 at 1:35 PM, Paulo Sousa [EMAIL PROTECTED]wrote: ... this *should* work, here is a test, tests/classes/__call_005.phpt, you can take the part beneath the --FILE-- section and see if it blows up on your system or not. right now, im getting errors on a php5.2.5 system, and its working as expected on a php5.2.6 system. --TEST-- When __call() is invoked via ::, ensure private implementation of __call() in superclass is accessed without error. --FILE-- ?php class A { private function __call($strMethod, $arrArgs) { echo In . __METHOD__ . ($strMethod, array( . implode(',',$arrArgs) . ))\n; var_dump($this); } } class B extends A { function test() { A::test1(1,'a'); B::test2(1,'a'); self::test3(1,'a'); parent::test4(1,'a'); } } $b = new B(); $b-test(); ? --EXPECTF-- In A::__call(test1, array(1,a)) object(B)#1 (0) { } In A::__call(test2, array(1,a)) object(B)#1 (0) { } In A::__call(test3, array(1,a)) object(B)#1 (0) { } In A::__call(test4, array(1,a)) object(B)#1 (0) { } also, i found in the code you posted, you are missing a 'function' in front of doWhatever (cause a parse error, which is why i mention it); w/ the following modification to your code, its running fine on a php 5.2.6 system, and choking on 5.2.5; function __call($function, $args){ var_dump($function); var_dump($args); $this-doWhatever(); } private function doWhatever() { } [EMAIL PROTECTED] ~/unpack/php-5.2.6RC3/tests/classes $ php testOtherStuff.php string(5) drive array(1) { [0]= string(7) testing } -nathan (sorry for the long-winded post)
Re: [PHP]About the magic function __call
My information was incomplete: I'm running php 5.1.2 (a requirement from the customer). I found this http://bugs.php.net/bug.php?id=42937 I coded this without testing, using only the idea. Thanks! Thanks for the help Nathan! 2008/8/27 Nathan Nobbe [EMAIL PROTECTED] On Wed, Aug 27, 2008 at 1:49 PM, Nathan Nobbe [EMAIL PROTECTED]wrote: On Wed, Aug 27, 2008 at 1:35 PM, Paulo Sousa [EMAIL PROTECTED] wrote: ... this *should* work, here is a test, tests/classes/__call_005.phpt, you can take the part beneath the --FILE-- section and see if it blows up on your system or not. right now, im getting errors on a php5.2.5 system, and its working as expected on a php5.2.6 system. --TEST-- When __call() is invoked via ::, ensure private implementation of __call() in superclass is accessed without error. --FILE-- ?php class A { private function __call($strMethod, $arrArgs) { echo In . __METHOD__ . ($strMethod, array( . implode(',',$arrArgs) . ))\n; var_dump($this); } } class B extends A { function test() { A::test1(1,'a'); B::test2(1,'a'); self::test3(1,'a'); parent::test4(1,'a'); } } $b = new B(); $b-test(); ? --EXPECTF-- In A::__call(test1, array(1,a)) object(B)#1 (0) { } In A::__call(test2, array(1,a)) object(B)#1 (0) { } In A::__call(test3, array(1,a)) object(B)#1 (0) { } In A::__call(test4, array(1,a)) object(B)#1 (0) { } also, i found in the code you posted, you are missing a 'function' in front of doWhatever (cause a parse error, which is why i mention it); w/ the following modification to your code, its running fine on a php 5.2.6 system, and choking on 5.2.5; function __call($function, $args){ var_dump($function); var_dump($args); $this-doWhatever(); } private function doWhatever() { } [EMAIL PROTECTED] ~/unpack/php-5.2.6RC3/tests/classes $ php testOtherStuff.php string(5) drive array(1) { [0]= string(7) testing } -nathan (sorry for the long-winded post)
[PHP] Randomly missing a function
An online signup script is randomly missing part of the task. These scripts are involved: sub_signup.php include/cc_proc.php - does the CC (credit card) processing include/user_maint.php - inserts the new subscriber into the database When the CC processing finishes, with the success flag, user_maint.php is included, and a few lines later the createUser($params) function therein is called to create the user. Every mysql_ function in user_maint.php is backstopped with a die() if it fails. But sometimes it appears that the call to this script, or the createUser() function just isn't made. What seems to happen, randomly, is that the script charges on so to speak, sending an advisory email to the office manager that there is a new subscriber, and calling sub_signup_thanks.php, which displays a completion message, etc. In all of these cases the credit card processing has succeeded. Sometimes people have tried to sign up two or three times, the card processes, but no addition is made to the database. It's driving us nuts! Any thoughts? Regards - Miles Infrastructure: Apache 2.2, PHP 5.x, MySQL 5 Code: switch ($ret) { case CC_SUCCESS: require 'include/user_maint.php'; $cctype = cc_getCardType($cc); if ($cctype == 'Visa') $cctype = 'VISA'; elseif ($cctype == 'MasterCard') $cctype = 'M-C'; //Shouldn't happen in case CC_SUCCESS, but better safe than sorry else die('We don\'t support this credit card'); $params = array( 'firstname' = $first, // various fields 'postal_code' = $postal_code, 'pay_method' = $cctype ); // createUser is a function in user_maint createUser($params); // sendEmail is func in user_maint, advises office manager sendEmail('New subscriber!!!', Already paid $amount by credit card, $fields); require 'sub_signup_thanks.php';//Grabs authCode from $result return; } //other situations dealt with, and properly closed
Re: [PHP] Randomly missing a function
Try returning a value from CreateUser and checking it before sending the E-Mail. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Miles Thompson wrote: An online signup script is randomly missing part of the task. These scripts are involved: sub_signup.php include/cc_proc.php - does the CC (credit card) processing include/user_maint.php - inserts the new subscriber into the database When the CC processing finishes, with the success flag, user_maint.php is included, and a few lines later the createUser($params) function therein is called to create the user. Every mysql_ function in user_maint.php is backstopped with a die() if it fails. But sometimes it appears that the call to this script, or the createUser() function just isn't made. What seems to happen, randomly, is that the script charges on so to speak, sending an advisory email to the office manager that there is a new subscriber, and calling sub_signup_thanks.php, which displays a completion message, etc. In all of these cases the credit card processing has succeeded. Sometimes people have tried to sign up two or three times, the card processes, but no addition is made to the database. It's driving us nuts! Any thoughts? Regards - Miles Infrastructure: Apache 2.2, PHP 5.x, MySQL 5 Code: switch ($ret) { case CC_SUCCESS: require 'include/user_maint.php'; $cctype = cc_getCardType($cc); if ($cctype == 'Visa') $cctype = 'VISA'; elseif ($cctype == 'MasterCard') $cctype = 'M-C'; //Shouldn't happen in case CC_SUCCESS, but better safe than sorry else die('We don\'t support this credit card'); $params = array( 'firstname' = $first, // various fields 'postal_code' = $postal_code, 'pay_method' = $cctype ); // createUser is a function in user_maint createUser($params); // sendEmail is func in user_maint, advises office manager sendEmail('New subscriber!!!', Already paid $amount by credit card, $fields); require 'sub_signup_thanks.php';//Grabs authCode from $result return; } //other situations dealt with, and properly closed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Randomly missing a function
Micah Gersten wrote: Try returning a value from CreateUser and checking it before sending the E-Mail. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Exactly! You'll find that CreateUser() is called, however for whatever reason the user isn't created. Do as Micah suggests and also add so error checking to CreateUser() to find out why the user isn't created. -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Randomly missing a function
MIcah, Duh!! So damned obvious. We'll try that. Thanks - Miles On Thu, Jul 17, 2008 at 5:42 PM, Micah Gersten [EMAIL PROTECTED] wrote: Try returning a value from CreateUser and checking it before sending the E-Mail. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Miles Thompson wrote: An online signup script is randomly missing part of the task. These scripts are involved: sub_signup.php include/cc_proc.php - does the CC (credit card) processing include/user_maint.php - inserts the new subscriber into the database When the CC processing finishes, with the success flag, user_maint.php is included, and a few lines later the createUser($params) function therein is called to create the user. Every mysql_ function in user_maint.php is backstopped with a die() if it fails. But sometimes it appears that the call to this script, or the createUser() function just isn't made. What seems to happen, randomly, is that the script charges on so to speak, sending an advisory email to the office manager that there is a new subscriber, and calling sub_signup_thanks.php, which displays a completion message, etc. In all of these cases the credit card processing has succeeded. Sometimes people have tried to sign up two or three times, the card processes, but no addition is made to the database. It's driving us nuts! Any thoughts? Regards - Miles Infrastructure: Apache 2.2, PHP 5.x, MySQL 5 Code: switch ($ret) { case CC_SUCCESS: require 'include/user_maint.php'; $cctype = cc_getCardType($cc); if ($cctype == 'Visa') $cctype = 'VISA'; elseif ($cctype == 'MasterCard') $cctype = 'M-C'; //Shouldn't happen in case CC_SUCCESS, but better safe than sorry else die('We don\'t support this credit card'); $params = array( 'firstname' = $first, // various fields 'postal_code' = $postal_code, 'pay_method' = $cctype ); // createUser is a function in user_maint createUser($params); // sendEmail is func in user_maint, advises office manager sendEmail('New subscriber!!!', Already paid $amount by credit card, $fields); require 'sub_signup_thanks.php';//Grabs authCode from $result return; } //other situations dealt with, and properly closed
Re: [PHP] Beware of round() function
On Mon, 24 Mar 2008 13:10:17 -0600, [EMAIL PROTECTED] wrote: Beware: round() apparently has changed its behavior from PHP 4. For certain special numbers that seem to be multiples of 100,000, the return value is in exponential format, rather than the usual decimal format. Some of these special values are 120, 140, 230, which are returned as 1.2E+6, 1.4E+6, etc. You can generate your own list of these special numbers using this code: ?php for( $tmp = 0, $i = 0; $i 100; $i++ ) { $tmp += 10; echo round($tmp),\n; } ? I now have a list of 3 ways this change in behavior can bite you and result in a failed transaction. In the examples below, assume that the value passed to round() is '120', so that the value returned from round() is '1.2E+6'. 1. When interpolating the value into xml, resulting in an xsd validation error: ? $xml = 'AnnualIncome' . round($income) . '/AnnualIncome'; ? 2. When validating user input, resulting in a false positive: ? if(!ereg(^[0-9]{1,10}$, round($_POST['income']))) { $errors .= liIncome should be whole dollars only (10 digits max)./li; } ? 3. When interpolating a value into a stored procedure call, resulting in a type mismatch between the value passed in and the database column data type (which is likely decimal for a monetary value): ? $sql = exec update_loan_financials @application_id='$appID', @total_debt= . round($totalDebt); ? BTW, a previous poster pointed out that this is a change in behavior of the float type, in general, not of the round() function, in particular. If you care. I don't. I just know I have broken code to fix and customers to apologize to. Kirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Beware of round() function
[EMAIL PROTECTED] wrote: On Mon, 24 Mar 2008 13:10:17 -0600, [EMAIL PROTECTED] wrote: Beware: round() apparently has changed its behavior from PHP 4. For certain special numbers that seem to be multiples of 100,000, the return value is in exponential format, rather than the usual decimal format. Some of these special values are 120, 140, 230, which are returned as 1.2E+6, 1.4E+6, etc. You can generate your own list of these special numbers using this code: ?php for( $tmp = 0, $i = 0; $i 100; $i++ ) { $tmp += 10; echo round($tmp),\n; } ? I now have a list of 3 ways this change in behavior can bite you and result in a failed transaction. In the examples below, assume that the value passed to round() is '120', so that the value returned from round() is '1.2E+6'. 1. When interpolating the value into xml, resulting in an xsd validation error: ? $xml = 'AnnualIncome' . round($income) . '/AnnualIncome'; ? 2. When validating user input, resulting in a false positive: ? if(!ereg(^[0-9]{1,10}$, round($_POST['income']))) { $errors .= liIncome should be whole dollars only (10 digits max)./li; } ? For the above test, is there any reason you couldn't use is_numeric() Looks like it would work in this case. ?php if ( ! is_numeric($_POST['income']) ) { $errors .= liIncome should be whole dollars only . (10 digits max)./li; } ? 3. When interpolating a value into a stored procedure call, resulting in a type mismatch between the value passed in and the database column data type (which is likely decimal for a monetary value): ? $sql = exec update_loan_financials @application_id='$appID', @total_debt= . round($totalDebt); ? BTW, a previous poster pointed out that this is a change in behavior of the float type, in general, not of the round() function, in particular. If you care. I don't. I just know I have broken code to fix and customers to apologize to. Kirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Beware of round() function
At 10:55 AM -0600 3/25/08, [EMAIL PROTECTED] wrote: Thanks for the info, Jeremy. Regardless of the technical details, my code still broke. I am little discouraged that an operation that should be so simple has these sorts of gotchas. Not that this helps/hurts your observation. What I find interesting is that the round function has a bias to round down. I've proved it, but it takes a lot of calculations to demonstrate any significant difference. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Beware of round() function
Thanks for the info, Jeremy. Regardless of the technical details, my code still broke. I am little discouraged that an operation that should be so simple has these sorts of gotchas. BTW, I ended up casting to int as my solution. Kirk Jeremy Privett [EMAIL PROTECTED] wrote on 03/24/2008 02:04:48 PM: Jeremy Privett wrote: [EMAIL PROTECTED] wrote: Beware: round() apparently has changed its behavior from PHP 4. This is actually a change in the behavior of the float type, not the round function. Replace your round() with a cast to float and you'll see the exact same result. Also, as a side-note, the only way I've found to get these numbers to print properly is through either printf or sprintf. Also, you could cast back to an integer, if you explicitly don't need floats. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Beware of round() function
Beware: round() apparently has changed its behavior from PHP 4. For certain special numbers that seem to be multiples of 100,000, the return value is in exponential format, rather than the usual decimal format. Some of these special values are 120, 140, 230, which are returned as 1.2E+6, 1.4E+6, etc. You can generate your own list of these special numbers using this code: ?php for( $tmp = 0, $i = 0; $i 100; $i++ ) { $tmp += 10; echo round($tmp),\n; } ? The exponential format is fine as long as the number is only used internally to PHP. However, we have found two cases so far where the exponential format has caused errors resulting in failed transactions. One, if you interpolate a value in exponential format into xml, as in this example, then you will likely end up with an xsd validation error and a failed transaction: 'AnnualIncome' . round($income) . '/AnnualIncome' Two, if you have field validation code like below, this will falsely indicate an error when the consumer enters one of the special values for income, e.g., 120, which is returned as 1.2E+6: if(!ereg(^[0-9]{1,10}$, round($_POST['income']))) { $errors .= liIncome should be whole dollars only (10 digits max)./li; } Needless to say, not a good user experience. I reported this as a bug to the PHP dev team, but it was rejected. Regardless of what it is, it will bite you if you're not careful. http://bugs.php.net/?id=44223edit=2 - Kirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Beware of round() function
[EMAIL PROTECTED] wrote: Beware: round() apparently has changed its behavior from PHP 4. This is actually a change in the behavior of the float type, not the round function. Replace your round() with a cast to float and you'll see the exact same result. -- Jeremy Privett C.E.O. C.S.A. Omega Vortex Corporation http://www.omegavortex.net Please note: This message has been sent with information that could be confidential and meant only for the intended recipient. If you are not the intended recipient, please delete all copies and inform us of the error as soon as possible. Thank you for your cooperation. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Beware of round() function
Jeremy Privett wrote: [EMAIL PROTECTED] wrote: Beware: round() apparently has changed its behavior from PHP 4. This is actually a change in the behavior of the float type, not the round function. Replace your round() with a cast to float and you'll see the exact same result. Also, as a side-note, the only way I've found to get these numbers to print properly is through either printf or sprintf. Also, you could cast back to an integer, if you explicitly don't need floats. -- Jeremy Privett C.E.O. C.S.A. Omega Vortex Corporation http://www.omegavortex.net Please note: This message has been sent with information that could be confidential and meant only for the intended recipient. If you are not the intended recipient, please delete all copies and inform us of the error as soon as possible. Thank you for your cooperation. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Beware of round() function
On Mon, 24 Mar 2008 13:10:17 -0600, [EMAIL PROTECTED] wrote: Beware: round() apparently has changed its behavior from PHP 4. For certain special numbers that seem to be multiples of 100,000, the return value is in exponential format, rather than the usual decimal format. Some of these special values are 120, 140, 230, which are returned as 1.2E+6, 1.4E+6, etc. You can generate your own list of these special numbers using this code: ?php for( $tmp = 0, $i = 0; $i 100; $i++ ) { $tmp += 10; echo round($tmp),\n; } ? Use (int)round($tmp) to get integer format. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Help for openssl_pkcs7_verify function
I need help for this function to verify a p7m file . The funcion return always error value ( -1 ) this is the sintax that I use to verify the sign on the file openssl_pkcs7_verify(prova.p7m, PKCS7_BINARY ,prova.pdf, array(c:\cert.pem) ); I 'm a winXP user and the path of PHP is place in the system path as mentioned in the setup note why it don't work ? where is the problem ? somebody could help me ?
Re: [PHP] Help for openssl_pkcs7_verify function
On 17 Mar 2008, at 21:34, Carlo Carbone wrote: I need help for this function to verify a p7m file . The funcion return always error value ( -1 ) this is the sintax that I use to verify the sign on the file openssl_pkcs7_verify(prova.p7m, PKCS7_BINARY ,prova.pdf, array(c:\cert.pem) ); I 'm a winXP user and the path of PHP is place in the system path as mentioned in the setup note why it don't work ? where is the problem ? somebody could help me ? Just guessing since I'm not familiar with the function, but on a basic PHP syntax level you need to escape the \... openssl_pkcs7_verify(prova.p7m, PKCS7_BINARY ,prova.pdf, array(c:\\cert.pem) ); -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with imagefontwidth function, It looks to be unavailable...
You probably do not have GD installed... Does ?php phpinfo();? list GD as one of your extensions? If not, install it. On Thu, February 7, 2008 6:57 am, Legolas wood wrote: Hi Thank you for reading my post I am trying to run a php based application using php5 and apache. but I receive an error like: *Fatal error*: Call to undefined function imagefontwidth() in */var/www/v603/includes/functions.php* on line *28* when line 28 and its surrounding lines are: ## create an image not a text for the pin $font = 6; $width = imagefontwidth($font) * strlen($generated_pin); $height = ImageFontHeight($font); $im = @imagecreate ($width,$height); $background_color = imagecolorallocate ($im, 219, 239, 249); //cell background $text_color = imagecolorallocate ($im, 0, 0,0);//text color imagestring ($im, $font, 0, 0, $generated_pin, $text_color); touch($image_url . 'uplimg/site_pin_' . $full_pin . '.jpg'); imagejpeg($im, $image_url . 'uplimg/site_pin_' . $full_pin . '.jpg'); $image_output = 'img src=' . $image_url . 'uplimg/site_pin_' . $full_pin . '.jpg'; imagedestroy($im); return $image_output; Can you tell me what is wrong with this code and how I can resolve the problem. Thanks -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with imagefontwidth function, It looks to be unavailable...
On Thursday 07 February 2008 17:17:30 David Giragosian wrote: On 2/7/08, Daniel Brown [EMAIL PROTECTED] wrote: On Feb 7, 2008 8:23 AM, Jochem Maas [EMAIL PROTECTED] wrote: Legolas wood schreef: Hi Thank you for reading my post I am trying to run a php based application using php5 and apache. but I receive an error like: *Fatal error*: Call to undefined function imagefontwidth() in */var/www/v603/includes/functions.php* on line *28* mostly likely you'll have to ask your sys admin to install/activate this extension ... and if you have cheaphosting then likely the answer will be no we don't do that - in which case find other hosting? plug shame=false / PilotPig has GD, ImageMagick, and all kinds of other things already installed, and will install any server software (when reasonable) upon request at no charge. Check it out: http://www.pilotpig.net/ /plug ;-P -- /Dan I can attest to what Daniel is saying about PilotPig. I've had a site hosted there for about 5 months now and have been really happy with everything: costs are reasonable, lots of modules available, respectful and timely reponses to questions and/or concerns. Just a great overall experience. David am I readin an comercial -- --- Børge Holen http://www.arivene.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with imagefontwidth function, It looks to be unavailable...
On Feb 8, 2008 2:50 PM, Børge Holen [EMAIL PROTECTED] wrote: am I readin an comercial but wait, there's more! Order within the next 6.3 seconds and you'll receive a cloned version of my first born, ABSOLUTELY FREE! -- /Dan Daniel P. Brown Senior Unix Geek ? while(1) { $me = $mind--; sleep(86400); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problem with imagefontwidth function, It looks to be unavailable...
Hi Thank you for reading my post I am trying to run a php based application using php5 and apache. but I receive an error like: *Fatal error*: Call to undefined function imagefontwidth() in */var/www/v603/includes/functions.php* on line *28* when line 28 and its surrounding lines are: ## create an image not a text for the pin $font = 6; $width = imagefontwidth($font) * strlen($generated_pin); $height = ImageFontHeight($font); $im = @imagecreate ($width,$height); $background_color = imagecolorallocate ($im, 219, 239, 249); //cell background $text_color = imagecolorallocate ($im, 0, 0,0);//text color imagestring ($im, $font, 0, 0, $generated_pin, $text_color); touch($image_url . 'uplimg/site_pin_' . $full_pin . '.jpg'); imagejpeg($im, $image_url . 'uplimg/site_pin_' . $full_pin . '.jpg'); $image_output = 'img src=' . $image_url . 'uplimg/site_pin_' . $full_pin . '.jpg'; imagedestroy($im); return $image_output; Can you tell me what is wrong with this code and how I can resolve the problem. Thanks
Re: [PHP] problem with imagefontwidth function, It looks to be unavailable...
Legolas wood schreef: Hi Thank you for reading my post I am trying to run a php based application using php5 and apache. but I receive an error like: *Fatal error*: Call to undefined function imagefontwidth() in */var/www/v603/includes/functions.php* on line *28* that would tend to indicate that it's unavailable yes. you don't have the [php] GD extension loaded (and probably not even installed) php.net/gd mostly likely you'll have to ask your sys admin to install/activate this extension ... and if you have cheaphosting then likely the answer will be no we don't do that - in which case find other hosting? when line 28 and its surrounding lines are: ## create an image not a text for the pin $font = 6; $width = imagefontwidth($font) * strlen($generated_pin); $height = ImageFontHeight($font); $im = @imagecreate ($width,$height); $background_color = imagecolorallocate ($im, 219, 239, 249); //cell background $text_color = imagecolorallocate ($im, 0, 0,0);//text color imagestring ($im, $font, 0, 0, $generated_pin, $text_color); touch($image_url . 'uplimg/site_pin_' . $full_pin . '.jpg'); imagejpeg($im, $image_url . 'uplimg/site_pin_' . $full_pin . '.jpg'); $image_output = 'img src=' . $image_url . 'uplimg/site_pin_' . $full_pin . '.jpg'; imagedestroy($im); return $image_output; Can you tell me what is wrong with this code and how I can resolve the problem. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with imagefontwidth function, It looks to be unavailable...
On Feb 7, 2008 8:23 AM, Jochem Maas [EMAIL PROTECTED] wrote: Legolas wood schreef: Hi Thank you for reading my post I am trying to run a php based application using php5 and apache. but I receive an error like: *Fatal error*: Call to undefined function imagefontwidth() in */var/www/v603/includes/functions.php* on line *28* mostly likely you'll have to ask your sys admin to install/activate this extension ... and if you have cheaphosting then likely the answer will be no we don't do that - in which case find other hosting? plug shame=false / PilotPig has GD, ImageMagick, and all kinds of other things already installed, and will install any server software (when reasonable) upon request at no charge. Check it out: http://www.pilotpig.net/ /plug ;-P -- /Dan Daniel P. Brown Senior Unix Geek ? while(1) { $me = $mind--; sleep(86400); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with imagefontwidth function, It looks to be unavailable...
On 2/7/08, Daniel Brown [EMAIL PROTECTED] wrote: On Feb 7, 2008 8:23 AM, Jochem Maas [EMAIL PROTECTED] wrote: Legolas wood schreef: Hi Thank you for reading my post I am trying to run a php based application using php5 and apache. but I receive an error like: *Fatal error*: Call to undefined function imagefontwidth() in */var/www/v603/includes/functions.php* on line *28* mostly likely you'll have to ask your sys admin to install/activate this extension ... and if you have cheaphosting then likely the answer will be no we don't do that - in which case find other hosting? plug shame=false / PilotPig has GD, ImageMagick, and all kinds of other things already installed, and will install any server software (when reasonable) upon request at no charge. Check it out: http://www.pilotpig.net/ /plug ;-P -- /Dan I can attest to what Daniel is saying about PilotPig. I've had a site hosted there for about 5 months now and have been really happy with everything: costs are reasonable, lots of modules available, respectful and timely reponses to questions and/or concerns. Just a great overall experience. David
[PHP] Re: Fatal error: Function name must be a string
Adam Williams wrote: I'm getting the following error and I don't see whats wrong with my line. Any ideas? *Fatal error*: Function name must be a string in */var/www/sites/intra-test/contract/perform.php* on line *57* and my snippet of code is: if ( $_POST[perform] == View Contracts ) { $mysqli_get_userid = SELECT user_id from user where email = '.$_SESSION[username].'; $mysqli_get_userid_result = $mysqli_query($mysqli, // line 57 $mysqli_get_userid) or die(mysqli_error($mysqli)); $mysqli_query should be mysqli_query (note: no $ ). You have an unset value, ie. null and you can't have a function called NULL (as the value). while ($userid_result = mysqli_fetch_array($mysqli_get_userid_result)) { $user_id = $userid_result[user_id]; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problem with pcode function
I have this postcode selector working on my localhost but remotely it gives a parse error. It should only call the function when the postcode is submitted. Any ideas? The error is: Parse error: parse error, unexpected T_NEW in /homepages/3/d154908384/htdocs/legalsuk/consultants/nearest.php on line 26 ?php function pcaStoredNearest($origin, $units, $distance, $items, $account_code, $license_code, $machine_id) { //Build the url $url = http://services.postcodeanywhere.co.uk/xml.aspx?;; $url .= action=stored_nearest; $url .= origin= . urlencode($origin); $url .= units= . urlencode($units); $url .= distance= . urlencode($distance); $url .= items= . urlencode($items); $url .= account_code= . urlencode($account_code); $url .= license_code= . urlencode($license_code); $url .= machine_id= . urlencode($machine_id); //Make the request $data = simplexml_load_string(file_get_contents($url)); //Check for an error if ($data-Schema['Items']==2) { throw new exception ($data-Data-Item['message']); } //Create the response foreach ($data-Data-children() as $row) { $rowItems=; foreach($row-attributes() as $key = $value) { $rowItems[$key]=strval($value); } $output[] = $rowItems; } //Return the result return $output; } } ? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; head meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 / title/title ?php include ('../pageElements/doc_head.php'); ? style type=text/css table { width:400px; } th { text-align:right; text-decoration:none; font-weight:normal; } td{ width:400px; } /style link href=../css/lss.css rel=stylesheet type=text/css / /head body id=services div id=container ?php include ('../pageElements/header.php'); ? div id=content-top /div div id=content-middle /div Find Your Nearest Consultant by Entering Your Postcode Belowbr /br / form action= method=post input name=pcode type=text style=width:100px; input name= type=submit style=width:50px; /form /div div id=result ?php if (isset($_POST['pcode'])){ $result = pcaStoredNearest($pcode, 'MILES', 'STRAIGHT', '2', 'x', 'x', ''); echo $result[0]['description']; } ? /div /div -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] default values in function call behaves differently in PHP5.2.4 and PHP5.0.4
Hi list. I am quite new in the area. I found a difference between PHP 5.2.4 to 5.0.4 in case of passing parameter to function, with default value: f1($par=0); in 5.2.4 the par is assigned to zero AFTER function call and thus, par is always ZERO ! The desired code in 5.2.4 should probably be: $par=0; f1($par); in 5.0.4 in is INITIALIZED to zero, BEFORE function call! and the return value is according to f1. Am I right? Is it a bug? Is it documented? Thanks Dor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: About DOM function in PHP
Kelvin Park wrote: I'm getting the following fatal error message: *Fatal error*: Cannot instantiate non-existent class: domdocument in * /home/hosting/infotechnow_com/htdocs/admin/inventory/catalog.php* on line *3 * when running this code: // Initialize new object for DOMDocument $doc = new DOMDocument(); What's the problem? ** You don't have the DOM extension installed (req. PHP5 in case you're not running that either)... seems pretty obvious to me :) www.php.net/dom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: About DOM function in PHP
On 7/8/07, M. Sokolewicz [EMAIL PROTECTED] wrote: You don't have the DOM extension installed (req. PHP5 in case you're not There is no DOM extension it is part of the PHP5 core; this from the DOM documantation http://www.php.net/manual/en/ref.dom.php in the online handbook: *Installation There is no installation needed to use these functions; they are part of the PHP core.* This leads me to beleive OP is using PHP4. Kelvin, create a phpinfo() script to determine if youre running PHP4 or PHP5. -nathan On 7/8/07, M. Sokolewicz [EMAIL PROTECTED] wrote: Kelvin Park wrote: I'm getting the following fatal error message: *Fatal error*: Cannot instantiate non-existent class: domdocument in * /home/hosting/infotechnow_com/htdocs/admin/inventory/catalog.php* on line *3 * when running this code: // Initialize new object for DOMDocument $doc = new DOMDocument(); What's the problem? ** You don't have the DOM extension installed (req. PHP5 in case you're not running that either)... seems pretty obvious to me :) www.php.net/dom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: About DOM function in PHP
Actually, I'll have to correct you on that. Everything in PHP is an extension, even the standard functions (which are part of the 'standard' extension). Some extensions are built-in while others are not (ie. standard, in PHP5, the DOM module is built-in). However, this does not mean they are also enabled! There are hosts which build php with --disable-dom, there are also hosts which build php with --disable-libxml thus disabling all xml-related functionality. - Tul Nathan Nobbe wrote: On 7/8/07, M. Sokolewicz [EMAIL PROTECTED] wrote: You don't have the DOM extension installed (req. PHP5 in case you're not There is no DOM extension it is part of the PHP5 core; this from the DOM documantation http://www.php.net/manual/en/ref.dom.php in the online handbook: *Installation There is no installation needed to use these functions; they are part of the PHP core.* This leads me to beleive OP is using PHP4. Kelvin, create a phpinfo() script to determine if youre running PHP4 or PHP5. -nathan On 7/8/07, M. Sokolewicz [EMAIL PROTECTED] wrote: Kelvin Park wrote: I'm getting the following fatal error message: *Fatal error*: Cannot instantiate non-existent class: domdocument in * /home/hosting/infotechnow_com/htdocs/admin/inventory/catalog.php* on line *3 * when running this code: // Initialize new object for DOMDocument $doc = new DOMDocument(); What's the problem? ** You don't have the DOM extension installed (req. PHP5 in case you're not running that either)... seems pretty obvious to me :) www.php.net/dom -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php