Can someone check my code for database connection, its a simple connection but i'm an amateur and i don't know where i'm going wrong [duplicate]

33
January 13, 2019, at 04:10 AM

This question already has an answer here:

  • How to display errors for my MySQLi query? [duplicate] 3 answers
  • When to use single quotes, double quotes, and back ticks in MySQL 12 answers
  • Reference - What does this error mean in PHP? 32 answers
  • Can I mix MySQL APIs in PHP? 4 answers

Yea this is it, would like if someone could tell me where i'm going wrong

if (isset($_POST['submit'])) {

require 'dbh.php';
$Name = $_POST['Name'];
$Grade = $_POST['Grade'];
$School = $_POST['School'];
$Day = $_POST['Day of the Week']; 
$Time = $_POST['When'];
$Rate = $_POST['Rate'];
$Payment = $_POST['$$'];
if (empty($Name) || empty($Grade) || empty($School) || empty($Day) ||
empty($Time) || empty($Rate) || empty($Payment)) {
  header("Location: NEWENTRY.php?error=emptyfields");
exit();
}
else {
    $sql = "INSERT INTO studentdetails(Name, Grade, School, Day of the Week, studentdetails_time, Rate, Has the payment been made) VALUES(?, ?, ?, ?, ?, ?, ?)";
    $stmt = mysqli_stmt_init($conn);
    if (!mysqli_stmt_init($stmt, $sql)) {
      header("Location: NEWENTRY.php?error=sqlerror");
      exit();
    }
} 
if (mysqli_bind_param($stmt, "sissdds", $Name, $Grade, $School, $Day, $Time, $Rate, $Payment)) {
    mysqli_stmt_execute($stmt);
    header("Location: NEWENTRY.php?signupsuccess");
    exit();
  }

mysqli_stmt_close($stmt); mysql_close($conn);

}

READ ALSO
INNER JOIN with Condition - Mysql

INNER JOIN with Condition - Mysql

I'm trying to make an inner join if a condition is true but it does not work, I've tried these 2 ways:

34
How do I preserve a UTF8 character set when doing an update into MySQL, from a Google Sheet?

How do I preserve a UTF8 character set when doing an update into MySQL, from a Google Sheet?

I have an app to upload a spreadsheet into my MySQL databaseSome of the fields contain Unicode characters from Northwest Indian languages

50
In C Language, store MySQL row data as variable to avoid segmentation fault with RPi/GPIO stuffs

In C Language, store MySQL row data as variable to avoid segmentation fault with RPi/GPIO stuffs

This is most-likely a stupid beginners questionFor starters, here's my C code [segment]:

50