Hej alle sammen min Mysqli kode i PHP OOP Siger denne fejl : Catchable fatal error: Argument 1 passed to Users::test() must be an instance of mysqli, none given, called in C:\SERVER\htdocs\ZinXan Social Network\index.php on line 3 and defined in C:\SERVER\htdocs\ZinXan Social Network\core\classes\Users\Users.php on line 11
Min connection fil :
- <?php
- $MySqli = new mysqli("localhost", "root", "", "ZX");
- ?>
Min indsættelse fil :
- public static function test(MySQLi $Mysqli) {
- global $mysqli;
- $username = "Hej";
- if($stmt=$mysqli->prepare('INSERT INTO `users`(`username`) VALUES (?)')) {
- $stmt->bind_param('s', $username);
- $stmt->execute();
- $stmt->close();
- echo 'Your user is now created';
- } else {
- echo 'There was an error with inserting your new user to the database. Try again and if that not work pleese contant us on : zinxan@gmail.com';
- }
- }