I'm trying to connect my website to a database, by adding whatever someone writes from the form to a table in my database, but so far I've only gotten errors and nothing appears on my MySQL database.
The error that I keep getting are these two:
Notice: Undefined index: fill
Warning: mysql_close() expects parameter 1 to be resource, object given in (folder)
How do I proceed to solve this problem?
<form action="insert.php" method="post">
<label for="fill">Add:</label>
<input type="text" name="fill">
<input type="submit" value="Insert!">
</form>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "database";
$conn = mysqli_connect($servername,$username,$password,$dbname);
if ($conn->connect_error) {
die ("connection failed: " . $conn->connect_error);
}
else
{
echo 'Connected to database';
}
mysql_select_db($dbname);
$sql = "INSERT INTO card_refill ('refill') VALUES ('$_POST[fill]')";
mysql_close($conn)
?>
mysql_*andmysqli_*functions. That won't work.$connis mysqli object. You are trying to close as mysql object