dink87522 Posted June 21, 2009 Share Posted June 21, 2009 Hi, I'm new to PHP and am having trouble with the following code. Error " Fatal error: Function name must be a string in C:\xampp\htdocs\stringsWork.php on line 12" strings.php <!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=utf-8" /> <title>String Manipulation</title> </head> <body> <textarea name="text" rows="10" columns="125"></textarea> <p> <form methord="post" action="stringsWork.php"> <input type="radio" name="fcn" value="strlen" /> Find the text length <br /> <input type="radio" name="fcn" value="strrev" /> Reverse the text <br /> <input type="radio" name="fcn" value="strtoupper" /> Make the text uppercase <br /> <input type="radio" name="fcn" value="strtolower" /> Make the text lowercase <br /> <input type="radio" name="fcn" value="ucwords" /> Capitalize the first letter of each word <br /> <p> <input type="submit" value = "manipulate the text!" /> </form> </body> </html> stringsWork.php <!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=utf-8" /> <title>String Manipulation</title> </head> <body> <textarea name="text" rows="10" columns="125"></textarea> <p> <form methord="post" action="stringsWork.php"> <input type="radio" name="fcn" value="strlen" /> Find the text length <br /> <input type="radio" name="fcn" value="strrev" /> Reverse the text <br /> <input type="radio" name="fcn" value="strtoupper" /> Make the text uppercase <br /> <input type="radio" name="fcn" value="strtolower" /> Make the text lowercase <br /> <input type="radio" name="fcn" value="ucwords" /> Capitalize the first letter of each word <br /> <p> <input type="submit" value = "manipulate the text!" /> </form> </body> </html> It must be something simple, I'm just not seeing it. Link to comment https://forums.phpfreaks.com/topic/163124-function-name-must-be-a-string-error/ Share on other sites More sharing options...
Ken2k7 Posted June 21, 2009 Share Posted June 21, 2009 Those are just HTML. No PHP? Link to comment https://forums.phpfreaks.com/topic/163124-function-name-must-be-a-string-error/#findComment-860655 Share on other sites More sharing options...
dink87522 Posted June 21, 2009 Author Share Posted June 21, 2009 Sorry i posted the wrong one lol. stringsWork.php <!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=utf-8" /> <title>Untitled Document</title> </head> <body> <?php $fcn = $_POST['fcn']; //echo("fcn: $fcn"); $text = $_POST['text']; //$modifiedText = ($fcn($text)); echo( fcn($text )); ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/163124-function-name-must-be-a-string-error/#findComment-860658 Share on other sites More sharing options...
Ken2k7 Posted June 21, 2009 Share Posted June 21, 2009 What is fcn($text)? Where's the function defined? Link to comment https://forums.phpfreaks.com/topic/163124-function-name-must-be-a-string-error/#findComment-860661 Share on other sites More sharing options...
dink87522 Posted June 21, 2009 Author Share Posted June 21, 2009 That should be $fcn($text) $fcn is the function. Link to comment https://forums.phpfreaks.com/topic/163124-function-name-must-be-a-string-error/#findComment-860667 Share on other sites More sharing options...
Ken2k7 Posted June 21, 2009 Share Posted June 21, 2009 $_POST['text'] won't work because the field is not in the form tag. Look over your HTML. Link to comment https://forums.phpfreaks.com/topic/163124-function-name-must-be-a-string-error/#findComment-860670 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.