Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
strip_tags stripping hyphen

Posted by dabbler (dabbler), 18 June 2003

I'm having trouble with a script which is validating data provided in a form field, it's removing the hyphen/dash.

     $HTTP_VARS['email']= trim(str_replace('>',' ', strip_tags($HTTP_VARS['email'])));

When I remove strip_tags, it no longer removes the hyphens, which seems completely bizarre as it's only supposed to remove the html and php tags. Is there a better workaround than removing it completely from all occurences? This does not seem to be a problem for other people, and I'm thinking this may be a quirk of my server's php setup (IIS5) somehow. Unless I'm completely overlooking something else.  

Posted by admin (Graham Ellis), 18 June 2003
Very odd one - nothing obvious that I can see.   Can you reproduce the problem in a smaller program?   Here's a very simple piece of PHP based on your code:


$HTTP_VARS['email'] = $_GET[email];
$HTTP_VARS['email'] = trim(str_replace('>',' ', strip_tags($HTTP_VARS['email'])));
print $HTTP_VARS['email'];

<form> <input name=email></form>

That's a complete working example and it DID work for me - stripping out tags, leaving - signs alone.  If you can run my program on your server and find a string for which it fails ... then try it out on my machine and see if it's a problem there ... should at least help give some clues.  

Posted by dabbler (dabbler), 18 June 2003
Thanks! Still strips the hyphen, it ignores every other symbol except the hyphen. However it works fine when I use it on your server, as I expected.

Is this a bug in my hosts version of php or a configuration problem that I can make them aware of?

PHP Version 4.3.2RC3

System  Windows NT GALILEO 5.0 build 2195  
Build Date  May 16 2003 00:32:10  
Server API  CGI/FastCGI  
Virtual Directory Support  enabled  
Configuration File (php.ini) Path  C:\WINNT\php.ini  
PHP API  20020918  
PHP Extension  20020429  
Zend Extension  20021010  

I found this, sounds suspiciously like my problem:

I've let my host know.

Posted by admin (Graham Ellis), 18 June 2003
Yep,  that's the one  

Your ISP is running a test version of PHP - a "release candidate". RC versions are expected to be released, but the last stage of testing is to have them out there with people for a short while to find any last minute problems.   Personally, I would run a release candidate on my development system, but I wouldn't put it on a main live server, especially if that server had a lot of users doing many different things.

Your ISP is using 4.3.2RC3 (something of a clue here - it's the THIRD release candidate!) and the problem report is for RC4.  The fix was applied in the source tree on 16th May - that's prior to the full release on 29th May of 4.3.2.

In other words
    * Naughty ISP - using test software versions!
    * There is now a released, fixed version they should upgrade to

Posted by dabbler (dabbler), 18 June 2003
Thanks for the clue, wasn't aware what rc meant. Now I know, and will whip them into shape. I can't complain too much, they are affordable, for small timers like me.

Thanks for the help though. Appreciated. I'll remove the offending function temporarily and restore it later when they've updated, as they have already assured me they would schedule it.

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho