I feel like a total n00b for not understanding what I’m doing wrong, but here goes.
I’m writing a simple web form that’s storing information in a MySQL database. I’m getting this error:
mysqli_stmt_init() expects parameter 1 to be mysqli, null given in /myfile.php
Here’s my code:
$server = 'localhost'; $username = 'myusername'; $password = 'mypassword'; $db = 'mydb'; $link = mysqli_connect($server, $username, $password, $db); . . . $stmt = mysqli_stmt_init($link); /*This line throws the error*/
Any ideas? Thanks in advance.
Are you 100% sure you are successfully connecting to the database?
Add at the top of your script:
Also add right below your connection line: