-1

It is 3rd day I am unable to send data to MySQL.
here are the resources db name: school table name: staff connection.php contains

<?php
$db = mysqli_connect('localhost', 'root', '', 'school') or die("Unable to connect to MySQL");
?>

and add-teacher.php contains

<form method="post" action="add-teacher.php" >
    <input type="text" name="firstname"  />
    <input type="text" name="lastname"   />

    <input type="submit" name="submit" value="Confirm" />
</form>

<?php
if (isset($_POST['submit'])) {
    $firstname = $_POST['firstname'];
    $lastname = $_POST['lastname'];

    $query = "INSERT INTO `staff` (`fname`, `lname`) VALUES ('$firstname', '$lastname')";

    if (!mysql_query($query)) {
        die("DAMMIT");
    } else {
        echo "Success";
    }
}
?>

I could not fins any error despite no row found at phpmyadmin.
add-teacher.php:
add-teacher.php

Cœur
  • 37,241
  • 25
  • 195
  • 267
Cheeta
  • 11
  • 2

1 Answers1

1

You are establish connection using mysqli and use mysql in run query. As mysql is totally removed in current version.

Use

if(!mysqli_query($db,$query))

Instead of

if(!mysql_query($query))
Ajay Korat
  • 716
  • 4
  • 14