runnerjp Posted May 27, 2008 Share Posted May 27, 2008 hey guys i keep getting Call to undefined function check_form() which is on this line of code i have provided if(isset($_POST["basic"])) { check_form(); } else { show_form(); } function check_form() { global $HTTP_POST_VARS, $error, $print_again; $error['error'] = false; if (($_POST["first_name"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["first_name"]))) { $error['first_name'] = true; $print_again = true; $message = "The first name field is either empty or incorrect data was input.<br>"; } if (($_POST["last_name"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["first_name"]))) { $error['last_name'] = true; $print_again = true; $message="The last name field is either empty or incorrect data was input.<br>"; } any reason why its not allowing it? Quote Link to comment https://forums.phpfreaks.com/topic/107505-solved-call-to-undefined-function-even-though-function-is-there/ Share on other sites More sharing options...
jonsjava Posted May 27, 2008 Share Posted May 27, 2008 missing a "{"? <?php if(isset($_POST["basic"])) { check_form(); } else { show_form(); } function check_form() { global $HTTP_POST_VARS, $error, $print_again; $error['error'] = false; if (($_POST["first_name"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["first_name"]))) { $error['first_name'] = true; $print_again = true; $message = "The first name field is either empty or incorrect data was input.<br>"; } if (($_POST["last_name"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["first_name"]))) { $error['last_name'] = true; $print_again = true; $message="The last name field is either empty or incorrect data was input.<br>"; } } Quote Link to comment https://forums.phpfreaks.com/topic/107505-solved-call-to-undefined-function-even-though-function-is-there/#findComment-551060 Share on other sites More sharing options...
DarkWater Posted May 27, 2008 Share Posted May 27, 2008 Try placing the function above the function call, if that other solution doesn't work. Quote Link to comment https://forums.phpfreaks.com/topic/107505-solved-call-to-undefined-function-even-though-function-is-there/#findComment-551061 Share on other sites More sharing options...
runnerjp Posted May 27, 2008 Author Share Posted May 27, 2008 nope niether worked :S <? } if(isset($_POST["basic"])) { check_form(); } else { show_form(); } function check_form() { global $HTTP_POST_VARS, $error, $print_again; $error['error'] = false; if (($_POST["first_name"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["first_name"]))) { $error['first_name'] = true; $print_again = true; $message = "The first name field is either empty or incorrect data was input.<br>"; } if (($_POST["last_name"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["first_name"]))) { $error['last_name'] = true; $print_again = true; $message="The last name field is either empty or incorrect data was input.<br>"; } if($_POST["club"]=="") { $error['club'] = true; $print_again = true; $message="Please select a club<br>"; } if($_POST["birthyear"]=="-DAY-") { $error['birthyear'] = true; $print_again = true; $message="Please select a dob<br>"; } if($_POST["birthmonth"]=="-MONTH-") { $error['birthmonth'] = true; $print_again = true; $message="Please select a dob<br>"; } if($_POST["birthday"]=="-YEAR-") { $error['birthday'] = true; $print_again = true; $message="Please select a dob<br>"; } if($print_again) { show_form(); } else { show_form(); $message="<span class='style1'>Your profile has been created</span>"; $id = mysql_real_escape_string( $_POST['id']); $club = mysql_real_escape_string( $_POST['club']); $first_name = mysql_real_escape_string( $_POST['first_name']); $last_name = mysql_real_escape_string( $_POST['last_name']); $gender = mysql_real_escape_string( $_POST['gender']); $birthyear = mysql_real_escape_string( $_POST['birthyear']); $birthmonth = mysql_real_escape_string( $_POST['birthmonth']); $birthday = mysql_real_escape_string( $_POST['birthday']); $dob = $birthday.'-'.$birthmonth.'-'.$birthyear; $update = "UPDATE users SET new_user='1',dob='$dob', club= '$club', first_name = '$first_name', gender = '$gender', last_name = '$last_name' WHERE id='$id' "; $result = mysql_query($update); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$result) { $er = 'Invalid query: ' . mysql_error() . "\n"; $er .= 'Whole query: ' . $query; die($er); }} echo ' <p class="error">' . $message . '</p>' . "\n"; } }?> here is full code... i use it twice as i have this if($pnew == 0){shows the form} esle {shows the form with sum bits missing} Quote Link to comment https://forums.phpfreaks.com/topic/107505-solved-call-to-undefined-function-even-though-function-is-there/#findComment-551074 Share on other sites More sharing options...
jonsjava Posted May 27, 2008 Share Posted May 27, 2008 all I can see is bracket issues again: <?php if(isset($_POST["basic"])) { check_form(); } else { show_form(); } function check_form() { global $HTTP_POST_VARS, $error, $print_again; $error['error'] = false; if (($_POST["first_name"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["first_name"]))) { $error['first_name'] = true; $print_again = true; $message = "The first name field is either empty or incorrect data was input.<br>"; } if (($_POST["last_name"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["first_name"]))) { $error['last_name'] = true; $print_again = true; $message="The last name field is either empty or incorrect data was input.<br>"; } if($_POST["club"]=="") { $error['club'] = true; $print_again = true; $message="Please select a club<br>"; } if($_POST["birthyear"]=="-DAY-") { $error['birthyear'] = true; $print_again = true; $message="Please select a dob<br>"; } if($_POST["birthmonth"]=="-MONTH-") { $error['birthmonth'] = true; $print_again = true; $message="Please select a dob<br>"; } if($_POST["birthday"]=="-YEAR-") { $error['birthday'] = true; $print_again = true; $message="Please select a dob<br>"; } if($print_again) { show_form(); } else { show_form(); $message="<span class='style1'>Your profile has been created</span>"; $id = mysql_real_escape_string( $_POST['id']); $club = mysql_real_escape_string( $_POST['club']); $first_name = mysql_real_escape_string( $_POST['first_name']); $last_name = mysql_real_escape_string( $_POST['last_name']); $gender = mysql_real_escape_string( $_POST['gender']); $birthyear = mysql_real_escape_string( $_POST['birthyear']); $birthmonth = mysql_real_escape_string( $_POST['birthmonth']); $birthday = mysql_real_escape_string( $_POST['birthday']); $dob = $birthday.'-'.$birthmonth.'-'.$birthyear; $update = "UPDATE users SET new_user='1',dob='$dob', club= '$club', first_name = '$first_name', gender = '$gender', last_name = '$last_name' WHERE id='$id' "; $result = mysql_query($update); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$result) { $er = 'Invalid query: ' . mysql_error() . "\n"; $er .= 'Whole query: ' . $query; die($er); }} echo ' <p class="error">' . $message . '</p>' . "\n"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/107505-solved-call-to-undefined-function-even-though-function-is-there/#findComment-551076 Share on other sites More sharing options...
runnerjp Posted May 27, 2008 Author Share Posted May 27, 2008 humm nope used it and still getting the Call to undefined function check_form() Quote Link to comment https://forums.phpfreaks.com/topic/107505-solved-call-to-undefined-function-even-though-function-is-there/#findComment-551082 Share on other sites More sharing options...
imdead Posted May 27, 2008 Share Posted May 27, 2008 <?php function check_form() { global $HTTP_POST_VARS, $error, $print_again; $error['error'] = false; if (($_POST["first_name"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["first_name"]))) { $error['first_name'] = true; $print_again = true; $message = "The first name field is either empty or incorrect data was input.<br>"; } if(isset($_POST["basic"])) { check_form(); } else { show_form(); } if (($_POST["last_name"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["first_name"]))) { $error['last_name'] = true; $print_again = true; $message="The last name field is either empty or incorrect data was input.<br>"; } if($_POST["club"]=="") { $error['club'] = true; $print_again = true; $message="Please select a club<br>"; } if($_POST["birthyear"]=="-DAY-") { $error['birthyear'] = true; $print_again = true; $message="Please select a dob<br>"; } if($_POST["birthmonth"]=="-MONTH-") { $error['birthmonth'] = true; $print_again = true; $message="Please select a dob<br>"; } if($_POST["birthday"]=="-YEAR-") { $error['birthday'] = true; $print_again = true; $message="Please select a dob<br>"; } if($print_again) { show_form(); } else { show_form(); $message="<span class='style1'>Your profile has been created</span>"; $id = mysql_real_escape_string( $_POST['id']); $club = mysql_real_escape_string( $_POST['club']); $first_name = mysql_real_escape_string( $_POST['first_name']); $last_name = mysql_real_escape_string( $_POST['last_name']); $gender = mysql_real_escape_string( $_POST['gender']); $birthyear = mysql_real_escape_string( $_POST['birthyear']); $birthmonth = mysql_real_escape_string( $_POST['birthmonth']); $birthday = mysql_real_escape_string( $_POST['birthday']); $dob = $birthday.'-'.$birthmonth.'-'.$birthyear; $update = "UPDATE users SET new_user='1',dob='$dob', club= '$club', first_name = '$first_name', gender = '$gender', last_name = '$last_name' WHERE id='$id' "; $result = mysql_query($update); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$result) { $er = 'Invalid query: ' . mysql_error() . "\n"; $er .= 'Whole query: ' . $query; die($er); }} echo ' <p class="error">' . $message . '</p>' . "\n"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/107505-solved-call-to-undefined-function-even-though-function-is-there/#findComment-551173 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.