php-general Digest 18 Apr 2010 12:59:40 -0000 Issue 6699
php-general Digest 18 Apr 2010 12:59:40 - Issue 6699 Topics (messages 304163 through 304170): Re: How define if javascript is on with php 304163 by: Paulo-WORK 304166 by: Manuel Lemos Re: PHP include security 304164 by: Micky Hulse 304165 by: Micky Hulse compile php 5.3.2 with php-fpm error,HELP ME 304167 by: Sharl.Jimh.Tsin 304168 by: Daniel Egeberg 304169 by: Sharl.Jimh.Tsin Replacing a special character 304170 by: Michael Stroh Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On 17/04/2010 23:13, tedd wrote: At 11:43 AM +0200 4/17/10, Michiel Sikma wrote: By having regular content and overriding it with Javascript It's probably best that you use the term progressive enhancement rather than overriding. The point being is that you have a site that delivers it's content for those with javascript turned off and those who have javascript turned on, can enjoy an enhanced version of the presentation, but not have something provided that other's can't get. Cheers, tedd I agree. Now that i know what to do, the end result will be displaying exactlly the same content and look regardless if JS is on or off. ---End Message--- ---BeginMessage--- Hello, on 04/16/2010 08:50 AM Paulo-WORK said the following: Hello and thanks for any replies that this message may get. I have a issue to solve regarding PHP. My website relies heavlly on jquery and does not dowgrade properly. I use codeigniter framework as this website has a backend . Is it possible to detect if js is on with php? And if so can it be set into a variable? Paulo Carvalho This class does exactly what you are asking: http://www.phpclasses.org/package/5297-PHP-Check-whether-Javascript-is-enabled-in-the-browser.html -- Regards, Manuel Lemos Find and post PHP jobs http://www.phpclasses.org/jobs/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ ---End Message--- ---BeginMessage--- Hi Michiel! Thanks for the help, I really appreciate it. :) It depends. What's exactly do you want to prevent? It doesn't seem like a ...snip... include, say, additional HTML content, use file_get_contents() instead. Very good points. My goal was to write a plugin that would allow me to include some static HTML template file and get the ?php include...? tags out of my CMS template. With that said, I think the only people using this code will be the developers of the templates, and not your standard user. I opted to use output buffering and readfile() for the speed, and include() would be an option if developers want to execute the code in the included file. Would file_get_contents() be faster than readfile and output buffering? Would using file_get_conents() and eval() be faster than using include() and output buffering? Without boring you all to death, I am mostly interested in learning new stuff! I actually don't think anyone will use this code other than myself. :D But I definitely agree with all your points. Thanks so much for you help! Have a great day! Cheers, Micky ---End Message--- ---BeginMessage--- What do ya'll think? Any suggestions? Sorry for the duplicate posting... I had some problems signing-up for the list. :( Also, I moved my test code to sniplr: http://snipplr.com/view/32192/php-security-include-path-cleansing/ TIA! Cheers M ---End Message--- ---BeginMessage--- Hi,everyone i download the php source tarball from php.net. and check out lastest version of php-fpm from SVN. then,i run the ./configure --prefix=/usr/local/php --bindir=/usr/local/bin --sbindir=/usr/local/sbin --sysconfdir=/etc/sysconfig --enable-embed=shared --enable-fpm --enable-safe-mode --enable-sigchild --enable-magic-quotes --enable-fd-setsize=100 --enable-calendar --enable-dba=shared --enable-exif --enable-ftp --enable-gd-native-ttf --enable-intl --enable-mbstring --enable-embedded-mysqli --enable-pcntl --disable-phar --enable-shmop --enable-soap --enable-sockets --enable-wddx --enable-zip --enable-zend-multibyte --with-libxml-dir --with-libevent-dir=/usr/local/libevent --with-fpm-user=php --with-fpm-group=php --with-config-file-path=/etc --with-exec-dir=/usr/local/bin --with-openssl --with-kerberos --with-pcre-regex --with-zlib --with-bz2 --with-curl --with-gd --with-mhash --with-imap --with-imap-ssl --with-ldap --with-ldap-sasl --with-mcrypt --with-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-mysqli=/usr/local/bin/mysql_config --with-pdo-mysql=/usr/local/bin/mysql_config --with-xmlrpc --with-pear it seems to be ok,and run make command.it looks like NO error appears,too but when i run the make install,it gives some
[PHP] compile php 5.3.2 with php-fpm error,HELP ME
Hi,everyone i download the php source tarball from php.net. and check out lastest version of php-fpm from SVN. then,i run the ./configure --prefix=/usr/local/php --bindir=/usr/local/bin --sbindir=/usr/local/sbin --sysconfdir=/etc/sysconfig --enable-embed=shared --enable-fpm --enable-safe-mode --enable-sigchild --enable-magic-quotes --enable-fd-setsize=100 --enable-calendar --enable-dba=shared --enable-exif --enable-ftp --enable-gd-native-ttf --enable-intl --enable-mbstring --enable-embedded-mysqli --enable-pcntl --disable-phar --enable-shmop --enable-soap --enable-sockets --enable-wddx --enable-zip --enable-zend-multibyte --with-libxml-dir --with-libevent-dir=/usr/local/libevent --with-fpm-user=php --with-fpm-group=php --with-config-file-path=/etc --with-exec-dir=/usr/local/bin --with-openssl --with-kerberos --with-pcre-regex --with-zlib --with-bz2 --with-curl --with-gd --with-mhash --with-imap --with-imap-ssl --with-ldap --with-ldap-sasl --with-mcrypt --with-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-mysqli=/usr/local/bin/mysql_config --with-pdo-mysql=/usr/local/bin/mysql_config --with-xmlrpc --with-pear it seems to be ok,and run make command.it looks like NO error appears,too but when i run the make install,it gives some information below: [r...@powerpc php-5.3.2]# make install /bin/sh /root/php-5.3.2/libtool --silent --preserve-dup-deps --mode=install cp ext/dba/dba.la /root/php-5.3.2/modules Installing PHP SAPI module: fpm Installing PHP CLI binary:/usr/local/bin/ Installing PHP CLI man page: /usr/local/php/man/man1/ Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/ Installing PHP FPM binary:/usr/local/sbin/ Installing PHP FPM config:/etc/sysconfig/ Installing PHP FPM man page: /usr/local/php/man/man1/ Installing build environment: /usr/local/php/lib/php/build/ Installing header files: /usr/local/php/include/php/ Installing helper programs: /usr/local/bin/ program: phpize program: php-config Installing man pages: /usr/local/php/man/man1/ page: phpize.1 page: php-config.1 Installing PEAR environment: /usr/local/php/lib/php/ make[1]: *** [install-pear-installer] Segmentation fault make: *** [install-pear] Error 2 I Do Not know what caused it.. and i run the php-fpm ,it returns Segmentation fault Want your helps,my friends Best regards, Sharl.Jimh.Tsin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] compile php 5.3.2 with php-fpm error,HELP ME
On Sun, Apr 18, 2010 at 09:47, Sharl.Jimh.Tsin amoiz.sh...@gmail.com wrote: Hi,everyone i download the php source tarball from php.net. and check out lastest version of php-fpm from SVN. then,i run the ./configure *snip* it seems to be ok,and run make command.it looks like NO error appears,too but when i run the make install,it gives some information below: [r...@powerpc php-5.3.2]# make install *snip* I Do Not know what caused it.. and i run the php-fpm ,it returns Segmentation fault Want your helps,my friends Best regards, Sharl.Jimh.Tsin Hi, Could you possibly get a backtrace [1] and submit a PHP bug [2]? [1] http://bugs.php.net/bugs-generating-backtrace.php [2] http://bugs.php.net/report.php -- Daniel Egeberg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] compile php 5.3.2 with php-fpm error,HELP ME
all right,i submit it as a bug into the bugs.php.net Best regards, Sharl.Jimh.Tsin 2010/4/18 Daniel Egeberg degeb...@php.net: On Sun, Apr 18, 2010 at 09:47, Sharl.Jimh.Tsin amoiz.sh...@gmail.com wrote: Hi,everyone i download the php source tarball from php.net. and check out lastest version of php-fpm from SVN. then,i run the ./configure *snip* it seems to be ok,and run make command.it looks like NO error appears,too but when i run the make install,it gives some information below: [r...@powerpc php-5.3.2]# make install *snip* I Do Not know what caused it.. and i run the php-fpm ,it returns Segmentation fault Want your helps,my friends Best regards, Sharl.Jimh.Tsin Hi, Could you possibly get a backtrace [1] and submit a PHP bug [2]? [1] http://bugs.php.net/bugs-generating-backtrace.php [2] http://bugs.php.net/report.php -- Daniel Egeberg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Replacing a special character
I have this form that people use to add entries into a MySQL database. Recently I've had some users insert − in their entries instead of - which is causing some issues with scripts down the line. I'd like to replace the − character with -. Originally I had something like $name = mysql_escape_string($_POST[name]); which would convert the offending character to #8722; before entering it into the database. It's this encoding that is causing the problems since some scripts send out emails with this entry in their subject line which looks messy. I've tried adding the following line after the previous line to help fix this issue, however, I just got another entry with the same problem. preg_replace('/#8722;/','-',$name); Any suggestions on how others would fix this problem? I'd just like to fix it before the entry hits the database instead of creating fixes on the other end of things. Cheers, Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Does PHP support multi-thread ?
Hello, everyone, please answer me. Thank you. Does PHP support multi-thread ?
Re: [PHP] Does PHP support multi-thread ?
Oh No ! Not again ! Please !! This was the subject of a very long and heated discussion a while ago. No - it does not support multi threading. - Original Message - From: ttplayer f...@qq.com To: php-general php-general@lists.php.net Sent: Sunday, April 18, 2010 11:17 PM Subject: [PHP] Does PHP support multi-thread ? Hello, everyone, please answer me. Thank you. Does PHP support multi-thread ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Does PHP support multi-thread ?
Not all libraries are thread safe, so no. 2 seconds with a google search would have given you the same answer. Bastien Sent from my iPod On Apr 18, 2010, at 9:17 AM, ttplayer f...@qq.com wrote: Hello, everyone, please answer me. Thank you. Does PHP support multi-thread ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replacing a special character
On Apr 18, 2010, at 8:59 AM, Michael Stroh st...@astroh.org wrote: I have this form that people use to add entries into a MySQL database. Recently I've had some users insert − in their entries ins tead of - which is causing some issues with scripts down the line. I 'd like to replace the − character with -. Originally I had something like $name = mysql_escape_string($_POST[name]); which would convert the offending character to #8722; before entering it into the database. It's this encoding that is causing the problems since some scripts send out emails with this entry in their subject line which looks messy. I've tried adding the following line after the previous line to help fix this issue, however, I just got another entry with the same problem. preg_replace('/#8722;/','-',$name); Any suggestions on how others would fix this problem? I'd just like to fix it before the entry hits the database instead of creating fixes on the other end of things. Cheers, Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php One option is to send an HTML email which would have the email reader interpret that code correctly Bastien -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replacing a special character
On 18 April 2010 16:40, Phpster phps...@gmail.com wrote: On Apr 18, 2010, at 8:59 AM, Michael Stroh st...@astroh.org wrote: I have this form that people use to add entries into a MySQL database. Recently I've had some users insert − in their entries instead of - which is causing some issues with scripts down the line. I'd like to replace the − character with -. Originally I had something like $name = mysql_escape_string($_POST[name]); which would convert the offending character to #8722; before entering it into the database. It's this encoding that is causing the problems since some scripts send out emails with this entry in their subject line which looks messy. I've tried adding the following line after the previous line to help fix this issue, however, I just got another entry with the same problem. preg_replace('/#8722;/','-',$name); Any suggestions on how others would fix this problem? I'd just like to fix it before the entry hits the database instead of creating fixes on the other end of things. Cheers, Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php One option is to send an HTML email which would have the email reader interpret that code correctly Bastien Another option would be to use mysql_real_escape_string and make sure that your code and the database are using utf-8. Then when the email is sent, make sure that uses utf-8 as well. Regards Peter -- hype WWW: http://plphp.dk / http://plind.dk LinkedIn: http://www.linkedin.com/in/plind Flickr: http://www.flickr.com/photos/fake51 BeWelcome: Fake51 Couchsurfing: Fake51 /hype -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Does PHP support multi-thread ?
yup, check out forking though for related Phpster wrote: Not all libraries are thread safe, so no. 2 seconds with a google search would have given you the same answer. Bastien Sent from my iPod On Apr 18, 2010, at 9:17 AM, ttplayer f...@qq.com wrote: Hello, everyone, please answer me. Thank you. Does PHP support multi-thread ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Mail Function Using PEAR Issues
Hi, After several days, I have rebuilt my system on Linux using Ubuntu, installed PEAR and such. Thankfully, when I execute the code, it no longer gives me the error that the class is not found. Yet, when I submit the form now, I can always see the confirmation message telling me that my message has been sent, but I cannot see it even in another mailbox. Here is the code: require_once(Mail.php); $mail = Mail::factory(mail); $your_name = $_POST['your_name']; $email = $_POST['email']; $question = $_POST['question']; $comments= $_POST['comments']; $submit = $_POST['submit']; $from = localhost; $to = $email; $subject = Comments; $body = From: $your_name\n E-Mail: $email\n Reason Contact: $question\n Comments:\n $comments; $host = localhost; $headers = array ('From' = $from,'To' = $to,'Subject' = $subject); $mail -send($to, $headers, $body); if (PEAR::isError($mail)) echo p . $mail-getMessage() . /p; else { echo pMessage successfully sent!/p div id='main' h1Thank You For Contacting Us/h1 pWe will contact you within the next b24 business hours/b./p pHere is what you have input:/p ulliYour Name is b . $your_name . /b/li liYour Email is b . $email . /b/li liYou contacted us because you have a b . $question . /b/li liHere are your comments: b . $comments . /b/li/ul h1Have a Nice Day!/h1/div; } } Can anyone on the list please give me some pointers on what might have been wrong here? I have not edited anything in the php.ini file regarding SMTP. Thanks. Alice _ The New Busy is not the old busy. Search, chat and e-mail from your inbox. http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3
Re: [PHP] Replacing a special character
On 18 April 2010 16:46, Peter Lind peter.e.l...@gmail.com wrote: On 18 April 2010 16:40, Phpster phps...@gmail.com wrote: On Apr 18, 2010, at 8:59 AM, Michael Stroh st...@astroh.org wrote: I have this form that people use to add entries into a MySQL database. Recently I've had some users insert − in their entries instead of - which is causing some issues with scripts down the line. I'd like to replace the − character with -. Originally I had something like $name = mysql_escape_string($_POST[name]); which would convert the offending character to #8722; before entering it into the database. It's this encoding that is causing the problems since some scripts send out emails with this entry in their subject line which looks messy. I've tried adding the following line after the previous line to help fix this issue, however, I just got another entry with the same problem. preg_replace('/#8722;/','-',$name); Any suggestions on how others would fix this problem? I'd just like to fix it before the entry hits the database instead of creating fixes on the other end of things. Cheers, Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php One option is to send an HTML email which would have the email reader interpret that code correctly Bastien Another option would be to use mysql_real_escape_string and make sure that your code and the database are using utf-8. Then when the email is sent, make sure that uses utf-8 as well. Regards Peter Make sure the database connection is also utf8: set names 'utf8'; Typically, you should keep everything in utf8 unless you have a very good reason not to. And as Peter mentioned, the proper way to escape MySQL inserts (that is, if you're not already using a framework that does this competently) is mysql_real_escape_string(). Michiel
Re: [PHP] PHP include security
On 18 April 2010 02:08, Micky Hulse mickyhulse.li...@gmail.com wrote: Hi Michiel! Thanks for the help, I really appreciate it. :) It depends. What's exactly do you want to prevent? It doesn't seem like a ...snip... include, say, additional HTML content, use file_get_contents() instead. Very good points. My goal was to write a plugin that would allow me to include some static HTML template file and get the ?php include...? tags out of my CMS template. With that said, I think the only people using this code will be the developers of the templates, and not your standard user. I opted to use output buffering and readfile() for the speed, and include() would be an option if developers want to execute the code in the included file. Would file_get_contents() be faster than readfile and output buffering? Would using file_get_conents() and eval() be faster than using include() and output buffering? I would prefer to use include() since it runs the code in the same context, and using both file_get_contents() and eval() is a bit of a detour. eval() also tends to be a lot slower than included code (though I'm not exactly sure how slow). I'm also not entirely sure whether file_get_contents() is slower than readfile(), but file_get_contents() is useful if you want to do something with your data rather than printing it right away. Michiel
Re: [PHP] solution
On 17 April 2010 13:03, Paulo-WORK pauloworkm...@googlemail.com wrote: I have reached a solution for my problem with js. Following all the sugestions and using jquery turned out to be quite simple. using .hide( ) and .show( ) i am able to change the #div with Js enabled content and no js. That's the best way to go. After all, the only real way to detect Javascript is to *use* Javascript :) Michiel
Re: [PHP] Does PHP support multi-thread ?
2010/4/18 Angus Mann angusm...@pobox.com: Oh No ! Not again ! Please !! This was the subject of a very long and heated discussion a while ago. No - it does not support multi threading. +1 - Original Message - From: ttplayer f...@qq.com To: php-general php-general@lists.php.net Sent: Sunday, April 18, 2010 11:17 PM Subject: [PHP] Does PHP support multi-thread ? Hello, everyone, please answer me. Thank you. Does PHP support multi-thread ? ttplayer: here is the subject if you want to read more [PHP] Will PHP ever grow up and have threading?. it got 257+ replys ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ** Hans Åhlin Tel: +46761488019 http://www.kronan-net.com/ irc://irc.freenode.net:6667 - TheCoin ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replacing a special character
Thanks for the advice. I've changed the code to use mysql_real_escape_string. So now it is $name = mysql_real_escape_string($name); preg_replace('/#8722;/','-',$name); but it's still not replacing the #8722; string. I've also changed the field in the database so that now it is using the collation utf8_general_ci. I've also tried preg_replace('/−/','-',$name); $name = mysql_real_escape_string($name); preg_replace('/#8722;/','-',$name); and that also did not work. Any ideas? Michael On Apr 18, 2010, at 1:08 PM, Michiel Sikma wrote: On 18 April 2010 16:46, Peter Lind peter.e.l...@gmail.com wrote: On 18 April 2010 16:40, Phpster phps...@gmail.com wrote: On Apr 18, 2010, at 8:59 AM, Michael Stroh st...@astroh.org wrote: I have this form that people use to add entries into a MySQL database. Recently I've had some users insert − in their entries instead of - which is causing some issues with scripts down the line. I'd like to replace the − character with -. Originally I had something like $name = mysql_escape_string($_POST[name]); which would convert the offending character to #8722; before entering it into the database. It's this encoding that is causing the problems since some scripts send out emails with this entry in their subject line which looks messy. I've tried adding the following line after the previous line to help fix this issue, however, I just got another entry with the same problem. preg_replace('/#8722;/','-',$name); Any suggestions on how others would fix this problem? I'd just like to fix it before the entry hits the database instead of creating fixes on the other end of things. Cheers, Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php One option is to send an HTML email which would have the email reader interpret that code correctly Bastien Another option would be to use mysql_real_escape_string and make sure that your code and the database are using utf-8. Then when the email is sent, make sure that uses utf-8 as well. Regards Peter Make sure the database connection is also utf8: set names 'utf8'; Typically, you should keep everything in utf8 unless you have a very good reason not to. And as Peter mentioned, the proper way to escape MySQL inserts (that is, if you're not already using a framework that does this competently) is mysql_real_escape_string(). Michiel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replacing a special character
Maybe you could try to assign the return value of preg_replace to a variable so you can use it later, like: $name = preg_replace('/#8722;/','-',$name); On Apr 18, 2010, at 11:38 AM, Michael Stroh wrote: Thanks for the advice. I've changed the code to use mysql_real_escape_string. So now it is $name = mysql_real_escape_string($name); preg_replace('/#8722;/','-',$name); but it's still not replacing the #8722; string. I've also changed the field in the database so that now it is using the collation utf8_general_ci. I've also tried preg_replace('/−/','-',$name); $name = mysql_real_escape_string($name); preg_replace('/#8722;/','-',$name); and that also did not work. Any ideas? Michael On Apr 18, 2010, at 1:08 PM, Michiel Sikma wrote: On 18 April 2010 16:46, Peter Lind peter.e.l...@gmail.com wrote: On 18 April 2010 16:40, Phpster phps...@gmail.com wrote: On Apr 18, 2010, at 8:59 AM, Michael Stroh st...@astroh.org wrote: I have this form that people use to add entries into a MySQL database. Recently I've had some users insert − in their entries instead of - which is causing some issues with scripts down the line. I'd like to replace the − character with -. Originally I had something like $name = mysql_escape_string($_POST[name]); which would convert the offending character to #8722; before entering it into the database. It's this encoding that is causing the problems since some scripts send out emails with this entry in their subject line which looks messy. I've tried adding the following line after the previous line to help fix this issue, however, I just got another entry with the same problem. preg_replace('/#8722;/','-',$name); Any suggestions on how others would fix this problem? I'd just like to fix it before the entry hits the database instead of creating fixes on the other end of things. Cheers, Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php One option is to send an HTML email which would have the email reader interpret that code correctly Bastien Another option would be to use mysql_real_escape_string and make sure that your code and the database are using utf-8. Then when the email is sent, make sure that uses utf-8 as well. Regards Peter Make sure the database connection is also utf8: set names 'utf8'; Typically, you should keep everything in utf8 unless you have a very good reason not to. And as Peter mentioned, the proper way to escape MySQL inserts (that is, if you're not already using a framework that does this competently) is mysql_real_escape_string(). Michiel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replacing a special character
That did it! Thanks! Michael On Apr 18, 2010, at 2:44 PM, Mari Masuda wrote: Maybe you could try to assign the return value of preg_replace to a variable so you can use it later, like: $name = preg_replace('/#8722;/','-',$name); On Apr 18, 2010, at 11:38 AM, Michael Stroh wrote: Thanks for the advice. I've changed the code to use mysql_real_escape_string. So now it is $name = mysql_real_escape_string($name); preg_replace('/#8722;/','-',$name); but it's still not replacing the #8722; string. I've also changed the field in the database so that now it is using the collation utf8_general_ci. I've also tried preg_replace('/−/','-',$name); $name = mysql_real_escape_string($name); preg_replace('/#8722;/','-',$name); and that also did not work. Any ideas? Michael On Apr 18, 2010, at 1:08 PM, Michiel Sikma wrote: On 18 April 2010 16:46, Peter Lind peter.e.l...@gmail.com wrote: On 18 April 2010 16:40, Phpster phps...@gmail.com wrote: On Apr 18, 2010, at 8:59 AM, Michael Stroh st...@astroh.org wrote: I have this form that people use to add entries into a MySQL database. Recently I've had some users insert − in their entries instead of - which is causing some issues with scripts down the line. I'd like to replace the − character with -. Originally I had something like $name = mysql_escape_string($_POST[name]); which would convert the offending character to #8722; before entering it into the database. It's this encoding that is causing the problems since some scripts send out emails with this entry in their subject line which looks messy. I've tried adding the following line after the previous line to help fix this issue, however, I just got another entry with the same problem. preg_replace('/#8722;/','-',$name); Any suggestions on how others would fix this problem? I'd just like to fix it before the entry hits the database instead of creating fixes on the other end of things. Cheers, Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php One option is to send an HTML email which would have the email reader interpret that code correctly Bastien Another option would be to use mysql_real_escape_string and make sure that your code and the database are using utf-8. Then when the email is sent, make sure that uses utf-8 as well. Regards Peter Make sure the database connection is also utf8: set names 'utf8'; Typically, you should keep everything in utf8 unless you have a very good reason not to. And as Peter mentioned, the proper way to escape MySQL inserts (that is, if you're not already using a framework that does this competently) is mysql_real_escape_string(). Michiel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP include security
On Sun, Apr 18, 2010 at 10:23 AM, Michiel Sikma mich...@thingmajig.org wrote: I would prefer to use include() since it runs the code in the same context, ...snip... with your data rather than printing it right away. Thanks for the reply Michiel, I really appreciate it. :) For some benchmarks on the different types of inclusion functions/language constructs, this page has some good info: http://www.raditha.com/wiki/Readfile_vs_include The results are interesting. Thanks again! Have an excellent day. Cheers, Micky -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mail Function Using PEAR Issues
Hey Alice, Again, try throwing the MIME in. $headers = 'MIME-Version: 1.0' . \r\n; $headers .= 'Content-type: text/html; charset=utf-8' . \r\n; Karl On Apr 18, 2010, at 10:11 AM, Alice Wei wrote: Hi, After several days, I have rebuilt my system on Linux using Ubuntu, installed PEAR and such. Thankfully, when I execute the code, it no longer gives me the error that the class is not found. Yet, when I submit the form now, I can always see the confirmation message telling me that my message has been sent, but I cannot see it even in another mailbox. Here is the code: require_once(Mail.php); $mail = Mail::factory(mail); $your_name = $_POST['your_name']; $email = $_POST['email']; $question = $_POST['question']; $comments= $_POST['comments']; $submit = $_POST['submit']; $from = localhost; $to = $email; $subject = Comments; $body = From: $your_name\n E-Mail: $email\n Reason Contact: $question\n Comments:\n $comments; $host = localhost; $headers = array ('From' = $from,'To' = $to,'Subject' = $subject); $mail -send($to, $headers, $body); if (PEAR::isError($mail)) echo p . $mail-getMessage() . /p; else { echo pMessage successfully sent!/p div id='main' h1Thank You For Contacting Us/h1 pWe will contact you within the next b24 business hours/ b./p pHere is what you have input:/p ulliYour Name is b . $your_name . /b/li liYour Email is b . $email . /b/li liYou contacted us because you have a b . $question . /b/li liHere are your comments: b . $comments . /b/ li/ul h1Have a Nice Day!/h1/div; } } Can anyone on the list please give me some pointers on what might have been wrong here? I have not edited anything in the php.ini file regarding SMTP. Thanks. Alice _ The New Busy is not the old busy. Search, chat and e-mail from your inbox. http://www.windowslive.com/campaign/thenewbusy? ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3 Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to do i18n better?
Hi everyone, I posted this in the PHP-i18n list, however got no answer so trying here). We are making a blog platform (http://oire.org/) which is provided in several languages (currently they are Russian, Ukrainian, and English). Now the i18n process is made as follows: we set a cookie on the site and depending on it we select the language to display the site in. We have three (currently) interface files: rus.lng, ukr.lng, and enu.lng (for English US). the format is the following: define (MSG379, Welcome!); etc. I know that PHP does support somehow exporting the strings into a .pod file. Maybe it would be better to do that? If so, how can I do it? Could you suggest me maybe a better solution than we currently have? Thanks a lot! -- With best regards from Ukraine, Andre http://oire.org/ - The Fantasy blogs of Oire Skype: Francophile; WlmMSN: arthaelon @ yandex.ru; Jabber: arthaelon @ jabber.org Twitter: http://twitter.com/m_elensule -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to do i18n better?
Andre Polykanine wrote: Hi everyone, I posted this in the PHP-i18n list, however got no answer so trying here). We are making a blog platform (http://oire.org/) which is provided in several languages (currently they are Russian, Ukrainian, and English). Now the i18n process is made as follows: we set a cookie on the site and depending on it we select the language to display the site in. We have three (currently) interface files: rus.lng, ukr.lng, and enu.lng (for English US). the format is the following: define (MSG379, Welcome!); etc. I know that PHP does support somehow exporting the strings into a .pod file. Maybe it would be better to do that? If so, how can I do it? Could you suggest me maybe a better solution than we currently have? Thanks a lot! A lot of systems just use conditional includes and a language array. So the following: Some main file: ?php $lang = tell_me_what_the_lang_code_is(); require_once( lang/messages.$lang.php ); ? And then in lang/messages.eng.php: ?php $messages['Welcome!']= 'Welcome!'; $messages['login-label'] = 'Login:'; $messages['blah-blah'] = 'Blah blah'; ? And then in lang/messages.fra.php you might have: ?php $messages['Welcome!']= 'Bienvenu!'; $messages['login-label'] = 'Accès :'; $messages['blah-blah'] = 'Le blah blah'; ? There's lots of variations on this also, but the above is a very common method. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mail Function Using PEAR Issues
Karl DeSaulniers wrote: Hey Alice, Again, try throwing the MIME in. $headers = 'MIME-Version: 1.0' . \r\n; $headers .= 'Content-type: text/html; charset=utf-8' . \r\n; Also: $headers .= 'Errors-to: myworkingemailaddr...@foo.com' . \r\n; Which I suggested on your previous thread. Also, I see you have $from set to equal localhost. Many SMTP servers will reject this I *think*, because localhost is a hostname, not a working mailbox. Try making $from equal to a real working address - possibly the same one as your Errors-to: header.. My $0.02, KDK On Apr 18, 2010, at 10:11 AM, Alice Wei wrote: Hi, After several days, I have rebuilt my system on Linux using Ubuntu, installed PEAR and such. Thankfully, when I execute the code, it no longer gives me the error that the class is not found. Yet, when I submit the form now, I can always see the confirmation message telling me that my message has been sent, but I cannot see it even in another mailbox. Here is the code: require_once(Mail.php); $mail = Mail::factory(mail); $your_name = $_POST['your_name']; $email = $_POST['email']; $question = $_POST['question']; $comments= $_POST['comments']; $submit = $_POST['submit']; $from = localhost; $to = $email; $subject = Comments; $body = From: $your_name\n E-Mail: $email\n Reason Contact: $question\n Comments:\n $comments; $host = localhost; $headers = array ('From' = $from,'To' = $to,'Subject' = $subject); $mail -send($to, $headers, $body); if (PEAR::isError($mail)) echo p . $mail-getMessage() . /p; else { echo pMessage successfully sent!/p div id='main' h1Thank You For Contacting Us/h1 pWe will contact you within the next b24 business hours/b./p pHere is what you have input:/p ulliYour Name is b . $your_name . /b/li liYour Email is b . $email . /b/li liYou contacted us because you have a b . $question . /b/li liHere are your comments: b . $comments . /b/li/ul h1Have a Nice Day!/h1/div; } } Can anyone on the list please give me some pointers on what might have been wrong here? I have not edited anything in the php.ini file regarding SMTP. Thanks. Alice -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Mail Function Using PEAR Issues
Date: Sun, 18 Apr 2010 21:02:29 -0500 From: k...@daleco.biz To: aj...@alumni.iu.edu CC: k...@designdrumm.com; php-general@lists.php.net Subject: Re: [PHP] Mail Function Using PEAR Issues Karl DeSaulniers wrote: Hey Alice, Again, try throwing the MIME in. $headers = 'MIME-Version: 1.0' . \r\n; $headers .= 'Content-type: text/html; charset=utf-8' . \r\n; Also: $headers .= 'Errors-to: myworkingemailaddr...@foo.com' . \r\n; Which I suggested on your previous thread. Also, I see you have $from set to equal localhost. Many SMTP servers will reject this I *think*, because localhost is a hostname, not a working mailbox. Try making $from equal to a real working address - possibly the same one as your Errors-to: header.. My $0.02, KDK On Apr 18, 2010, at 10:11 AM, Alice Wei wrote: Hi, After several days, I have rebuilt my system on Linux using Ubuntu, installed PEAR and such. Thankfully, when I execute the code, it no longer gives me the error that the class is not found. Yet, when I submit the form now, I can always see the confirmation message telling me that my message has been sent, but I cannot see it even in another mailbox. Here is the code: require_once(Mail.php); $mail = Mail::factory(mail); $your_name = $_POST['your_name']; $email = $_POST['email']; $question = $_POST['question']; $comments= $_POST['comments']; $submit = $_POST['submit']; $from = localhost; $to = $email; $subject = Comments; $body = From: $your_name\n E-Mail: $email\n Reason Contact: $question\n Comments:\n $comments; $host = localhost; $headers = array ('From' = $from,'To' = $to,'Subject' = $subject); $mail -send($to, $headers, $body); if (PEAR::isError($mail)) echo p . $mail-getMessage() . /p; else { echo pMessage successfully sent!/p div id='main' h1Thank You For Contacting Us/h1 pWe will contact you within the next b24 business hours/b./p pHere is what you have input:/p ulliYour Name is b . $your_name . /b/li liYour Email is b . $email . /b/li liYou contacted us because you have a b . $question . /b/li liHere are your comments: b . $comments . /b/li/ul h1Have a Nice Day!/h1/div; } } Can anyone on the list please give me some pointers on what might have been wrong here? I have not edited anything in the php.ini file regarding SMTP. Thanks. Alice Hi, Here is the revised version, and I don't think I have experienced any changes in terms of the output on the screen. Plus, I still get no email. ?php require_once(Mail.php); $mail = Mail::factory(mail); $your_name = $_POST['your_name']; $email = $_POST['email']; $question = $_POST['question']; $comments= $_POST['comments']; $submit = $_POST['submit']; $from = aj...@alumni.iu.edu; $to = elite.engl...@gmail.com; $subject = Comments; $body = From: $your_name\n E-Mail: $email\n Reason Contact: $question\n Comments:\n $comments; $headers = 'MIME-Version: 1.0' . \r\n; $headers .= 'Content-type: text/html; charset=utf-8' . \r\n; $headers .= 'Errors-to: elite.engl...@gmail.com' . \r\n; $mail -send($to, $headers, $body); if (PEAR::isError($mail)) echo p . $mail-getMessage() . /p; else { echo pMessage successfully sent!/p div id='main' h1Thank You For Contacting Us/h1 pHere is what you have input:/p ulliYour Name is b . $your_name . /b/li liYour Email is b . $email . /b/li liYou contacted us because you have a b . $question . /b/li liHere are your comments: b . $comments . /b/li/ul h1Have a Nice Day!/h1/div; } I have made sure that my $from and $to addresses are different, Could there be anything else wrong here? I have not edited anything in php.ini regarding this issue. Would I need to? Thanks for your help. Alice _ The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail. http://www.windowslive.com/campaign/thenewbusy?tile=multiaccountocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4
Re: [PHP] Mail Function Using PEAR Issues
Is there any need for this line if you are using the Errors-to: ? Maybe take it out and see what Errors-to gives you without it. On Apr 18, 2010, at 9:27 PM, Alice Wei wrote: if (PEAR::isError($mail)) echo p . $mail-getMessage() . OAN - That sendmail script I posted, I know works on Linux servers if you want to compare notes with it. Best, Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mail Function Using PEAR Issues
Alice Wei wrote: Date: Sun, 18 Apr 2010 21:02:29 -0500 From: k...@daleco.biz To: aj...@alumni.iu.edu CC: k...@designdrumm.com; php-general@lists.php.net Subject: Re: [PHP] Mail Function Using PEAR Issues Karl DeSaulniers wrote: Hey Alice, Again, try throwing the MIME in. $headers = 'MIME-Version: 1.0' . \r\n; $headers .= 'Content-type: text/html; charset=utf-8' . \r\n; Also: $headers .= 'Errors-to: myworkingemailaddr...@foo.com' . \r\n; Which I suggested on your previous thread. Also, I see you have $from set to equal localhost. Many SMTP servers will reject this I *think*, because localhost is a hostname, not a working mailbox. Try making $from equal to a real working address - possibly the same one as your Errors-to: header.. My $0.02, KDK On Apr 18, 2010, at 10:11 AM, Alice Wei wrote: Hi, After several days, I have rebuilt my system on Linux using Ubuntu, installed PEAR and such. Thankfully, when I execute the code, it no longer gives me the error that the class is not found. Yet, when I submit the form now, I can always see the confirmation message telling me that my message has been sent, but I cannot see it even in another mailbox. Here is the code: require_once(Mail.php); $mail = Mail::factory(mail); $your_name = $_POST['your_name']; $email = $_POST['email']; $question = $_POST['question']; $comments= $_POST['comments']; $submit = $_POST['submit']; $from = localhost; $to = $email; $subject = Comments; $body = From: $your_name\n E-Mail: $email\n Reason Contact: $question\n Comments:\n $comments; $host = localhost; $headers = array ('From' = $from,'To' = $to,'Subject' = $subject); $mail -send($to, $headers, $body); if (PEAR::isError($mail)) echo p . $mail-getMessage() . /p; else { echo pMessage successfully sent!/p div id='main' h1Thank You For Contacting Us/h1 pWe will contact you within the next b24 business hours/b./p pHere is what you have input:/p ulliYour Name is b . $your_name . /b/li liYour Email is b . $email . /b/li liYou contacted us because you have a b . $question . /b/li liHere are your comments: b . $comments . /b/li/ul h1Have a Nice Day!/h1/div; } } Can anyone on the list please give me some pointers on what might have been wrong here? I have not edited anything in the php.ini file regarding SMTP. Thanks. Alice Hi, Here is the revised version, and I don't think I have experienced any changes in terms of the output on the screen. Plus, I still get no email. ?php require_once(Mail.php); $mail = Mail::factory(mail); $your_name = $_POST['your_name']; $email = $_POST['email']; $question = $_POST['question']; $comments= $_POST['comments']; $submit = $_POST['submit']; $from = aj...@alumni.iu.edu; $to = elite.engl...@gmail.com; $subject = Comments; $body = From: $your_name\n E-Mail: $email\n Reason Contact: $question\n Comments:\n $comments; $headers = 'MIME-Version: 1.0' . \r\n; $headers .= 'Content-type: text/html; charset=utf-8' . \r\n; $headers .= 'Errors-to: elite.engl...@gmail.com' . \r\n; $mail -send($to, $headers, $body); if (PEAR::isError($mail)) echo p . $mail-getMessage() . /p; else { echo pMessage successfully sent!/p div id='main' h1Thank You For Contacting Us/h1 pHere is what you have input:/p ulliYour Name is b . $your_name . /b/li liYour Email is b . $email . /b/li liYou contacted us because you have a b . $question . /b/li liHere are your comments: b . $comments . /b/li/ul h1Have a Nice Day!/h1/div; } I have made sure that my $from and $to addresses are different, Could there be anything else wrong here? I have not edited anything in php.ini regarding this issue. Would I need to? Well, it's a Good Thing(tm) to know what those settings are. Have they changed since your last thread? KDK -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php