0

I've checked my code a thousand time and it never pops up right so I tried a PHP Checker/Tester. It tells me Call to undefined function test_input() in /home4/phptest/public_html/code.php70(5) : eval()'d code:4 Stack trace: #0 /home4/phptest/public_html/code.php70(5): eval() #1 {main} thrown on line number 4 What does this mean? Help Please!

<?php

        ($_SERVER["REQUEST_METHOD"] == "GET");
        $charName = test_input($_GET["charName"]);
        $charType = test_input($_GET["charType"]);
        $healthTokens = test_input($_GET["healthTokens"]);
        $expTokens = test_input($_GET["expTokens"]);
        $supplyTokens = test_input($_GET["supplyTokens"]);


        $charName = $_POST['charName'];
        $charType = $_POST['charType'];
        $healthTokens = $_POST['healthTokens'];
        $expTokens = $_POST['expTokens'];
        $supplyTokens = $_POST['supplyTokens'];

        if (strtolower($password) == "php123")
        {
            $goldSpent = $healthTokens / 10 + $expTokens / 2 + $supplyTokens / 25;

            print("<h1>You have created $charName the $charType!</h1>");
            print("<p>$charName has $healthTokens health tokens,
                        $expTokens experience tokens, and 
                        $supplyTokens supply tokens.</p>");
            print("<p>$charName has spent $goldSpent gold pieces.</p>");
        }
        else
        {
            print ("<p>Sorry! That password is NOT correct. Please try again</p>");
        }
?>
Hannah
  • 1
  • 1
  • `test_input` is defined where? –  Oct 23 '18 at 21:39
  • 1
    `test_input` is not a built-in PHP function. It's not defined in this code, and you aren't including any files before that that could define it, so it's not defined. If you copied this code from another file, maybe you missed the includes? – Don't Panic Oct 23 '18 at 21:40
  • you probably want a if\else for get vs post also –  Oct 23 '18 at 21:43
  • I don't see where you've assigned `$password`. – Funk Forty Niner Oct 23 '18 at 21:47
  • `($_SERVER["REQUEST_METHOD"] == "GET");` you forgot the `if` and using `;` after a condition ends the condition block, essentially this line does nothing but return true or false. And if it did do something these wouldn't work `$_POST['charName']`. But it doesn't (you intended if/else here, maybe) .... `print(..)` doesn't need these brackets as its a language construct and not a function (however it will work with them) – ArtisticPhoenix Oct 23 '18 at 21:47

1 Answers1

0

You call a function that is not defined in your code:

$charName = test_input($_GET["charName"]);

That function may be defined in another file that you don't include in your script.