Jump to content

[SOLVED] Call to undefined function even though function is there


runnerjp

Recommended Posts

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?

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>";
    }
}

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}

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";
}
?>

<?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";
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.