dpenguin71 Posted June 23, 2015 Share Posted June 23, 2015 Lines 84-88: if (empty($_POST['HomeInfo'])) { $infoErr = "Information about your home is required. "; } else { $HomeInfo = test_input($_POST['HomeInfo']); } Lines 120-125: function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } So, why is it saying it is undefined, when it clearly is defined? And, more importantly,how do I fix it? Link to comment https://forums.phpfreaks.com/topic/296972-call-to-undefined-function-but-it-is-defined-help/ Share on other sites More sharing options...
mac_gyver Posted June 23, 2015 Share Posted June 23, 2015 Lines 120-125 are probably inside of a conditional statement, so that they don't become defined until that conditional statement is true. function definitions should all be grouped together and come near the start of your code or even be in a separate file that gets included near the start of your code. Link to comment https://forums.phpfreaks.com/topic/296972-call-to-undefined-function-but-it-is-defined-help/#findComment-1514655 Share on other sites More sharing options...
dpenguin71 Posted June 24, 2015 Author Share Posted June 24, 2015 Thank you! I moved the function definition to the top of the file and it worked great. I don't know why I didn't think of that before, but I appreciate the suggestion!! Link to comment https://forums.phpfreaks.com/topic/296972-call-to-undefined-function-but-it-is-defined-help/#findComment-1514766 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.