I have a form:
<form action="createPoll.php" method="POST">
<!-contents->
<input type="submit" value="Submit">
</form>
When the submit button is clicked it runs createPoll.php which contains:
<?php
ini_set('session.gc_maxlifetime', 3600);
session_set_cookie_params(3600);
session_start();
//contents
$conn = new mysqli ($host, $dbusername, $dbpassword, $dbname);
if(mysqli_connect_error()){
die("Connection Error (" .mysql_connect_errno(). ") " . mysql_connect_error());
header('Location: user.php');
}
else{
$sql="select count(poll_id) from poll_info where poll_id=$poll_id;";
while(mysqli_query($conn,"SELECT count(poll_id) from table where poll_id=$poll_id") >=1){
$poll_id= random_int(0,1000000);
}
$sql= "INSERT INTO poll_info (poll_id, username, input_date_time, open_time, data) values('$poll_id','$username','$input_date_time','$open_time','$data')"; //defined above in contents
if($conn->query($sql)){
echo "<script>alert('success!')</script>";
}
else{
echo"Error: ". $sql ."<br>". $conn->error;
}
}
$conn->close;
?>
The problem is that I get this error:
Notice: Undefined property: mysqli::$close in C:\xampp\htdocs\createPoll.php in line 61
which refers to the $conn->close(); I have similar code elsewhere (for logging in and signing up) and it works fine there (connection closes fine) but I seem to get an error here for some reason. Any ideas?