/    Sign up×
Community /Pin to ProfileBookmark

Error – cannot redeclare function

I have a very simple error handling function as such:

function checknull($tocheck){ //Verifies Form data isn’t null. REturns 0 instead if it is.//
if ($tocheck == Null)
{return (0);}
else
{return ($tocheck);}
}

Then I call it in the same php file as such:
//Assign user’s choices to variables//
$mc = checknull($_POST[‘MC’]);
$ca = checknull($_
POST[‘CA’]);
$cb = checknull($_POST[‘CB’]);
$cc = checknull($_
POST[‘CC’]);
$cd = checknull($_POST[‘CD’]);
$ce = checknull($_
POST[‘CE’]);
$cf = checknull($_POST[‘CF’]);
$cg = checknull($_
POST[‘CG’]);

Now, if I move the function to my my_functions.php file (which I already have included), I get the error that I cannot redeclare the function checknull()…

What am I missing this time? This is a learning exercise for me, and I have tried to solve my own problem with online tutorials, etc. but am stumped.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@scragarMar 31.2008 — not sure as to exactly what the problem is, but I think it may have something to do with number 2:
[list]
  • [*]NULL is all upper case

  • [*]you don't need the brackets around the return value, since return isn't a function, it's a keyword.
  • [/list]
    ×

    Success!

    Help @GimmeAName spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.26,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...