Php Error - Unexpected require_once expecting function

后端 未结 4 1835
后悔当初
后悔当初 2021-01-16 11:50

I\'m currently trying to fetch the medoo framework so that I can begin easily retrieving data from my MySQL database... and for some reason it doesn\'t work!

here\'s

相关标签:
4条回答
  • 2021-01-16 12:09

    I might be wrong, but doesn't require_once 'medoo.min.php'; require parentheses? like so: require_once ('medoo.min.php');

    0 讨论(0)
  • 2021-01-16 12:24

    Try this, its likely to work

    <?
        require_once 'medoo.min.php';
        use Medoo\Medoo; //If this line raises errors, remove it
    
        // Initialize DB
        $database = new Medoo(
        // required
        'database_type' => 'mysql',
        'database_name' => 'name',
        'server' => 'localhost',
        'username' => 'your_username',
        'password' => 'your_password',
        );
    
        $email = $database->get('MM_Users', 'Email', [
            'ID' => 1
        ]);
          return $email;
        }
    ?>
    

    One other bug I noticed is that you instantiated a the Medoo object (in other words, you called the Medoo class) using a Lowercase M of which shouldn't be the case. In addition remember to pass in the correct Database & Server values.

    See this for more info if you're still facing challenges on that.

    0 讨论(0)
  • 2021-01-16 12:28

    This line:

    require_once('signin.php');
    

    is inside a class but outside a method, which is not possible in PHP.

    0 讨论(0)
  • 2021-01-16 12:34

    You can't have require_once inside a class without a function. That's the main reason.

    Try putting the require_once in the construct.

    To be exact :

    class foo 
    {
        require_once('bar.php');
    }
    

    will throw an error.

    0 讨论(0)
提交回复
热议问题