EmmanuelP89 Posted February 18, 2014 Share Posted February 18, 2014 Hi i'm fairly new to PHP and have been going through Learning PHP, MySQL, Javascript and CSS by Robin Nixon 2nd edition and found the following problem in the following example that I could not figure out. I would appreciate any help to fixing it. Thanks <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <?php /* * */ $f = $c = ""; if (isset($_POST['f'])) { $f = sanitizeString($_POST['f']); } if (isset($_POST['c'])) { $c = sanitizeString($_POST['c']); } // degree symbol done by alt + 0176 if ($f != '') { $c = intval((5 / 9) * ($f - 32)); $out = "$f °f equals $c °c"; } elseif($c != '') { $f = intval((9 / 5) * $c + 32); $out = "$c °c equals $f °f"; } else { $out = ""; } echo <<<_END <html> <head> <title>Temprature Converter</title> </head> <body> <pre> Enter either Fahrenheit or Celsius and click Convert <b>$out</b> <form method="post" action="convert.php"> Fahrenheit <input type="text" name="f" size="7" /> Celsius <input type="text" name="c" size="7" /> <input type="submit" value="Convert" /> </form> </pre> </body> </html> _END; function sanitizeString($var) { $var = stripslashes($var); $var = htmlentitites($var); $var = strip_tags($var); return $var; } ?> </body> </html> ***************************************************************************************************** This is what happens after running the converter ( ! ) Fatal error: Call to undefined function htmlentitites() in C:\wamp\www\Chapter10\Chapter11\convert.php on line 68 Call Stack # Time Memory Function Location 1 0.0004 260784 {main}( ) ..\convert.php:0 2 0.0004 261616 sanitizeString( ) ..\convert.php:22 Quote Link to comment https://forums.phpfreaks.com/topic/286297-sanitizing-input/ Share on other sites More sharing options...
Ch0cu3r Posted February 18, 2014 Share Posted February 18, 2014 (edited) htmlentitites should be htmlentities ( entities spelt with two t's not three) Edited February 18, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/286297-sanitizing-input/#findComment-1469440 Share on other sites More sharing options...
Solution EmmanuelP89 Posted February 18, 2014 Author Solution Share Posted February 18, 2014 Ok thx, now it works!!! Emberrased to say i've wasted so much time on that!!! Quote Link to comment https://forums.phpfreaks.com/topic/286297-sanitizing-input/#findComment-1469441 Share on other sites More sharing options...
AbraCadaver Posted February 18, 2014 Share Posted February 18, 2014 This will never strips tags: $var = htmlentities($var); $var = strip_tags($var); Maybe reverse them. Quote Link to comment https://forums.phpfreaks.com/topic/286297-sanitizing-input/#findComment-1469444 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.