0

Error shown is as follow:

connected Fatal error: Class 'mysql_connect' not found in C:\xampp\htdocs\new test\connection.php on line 27

$conn = new mysql_connect($username, $password);

    $sql="INSERT INTO account(username, password) values('$username','$password')";
    if($conn->query($sql))
    {
        echo"new record is inserted succesfully";
    }
    else
    {
        echo"Error:".sql."<br>".$conn->error;
    }
    $conn->close();
}
Nigel Ren
  • 56,122
  • 11
  • 43
  • 55
AkashWagh
  • 55
  • 5
  • 1
    `mysql_*` functions are removed since php 7. You should use a more up to date tutorial/book that uses `mysqli` or `PDO` – Sindhara Mar 29 '19 at 06:29
  • https://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php – Nigel Ren Mar 29 '19 at 06:47

1 Answers1

1

mysql_connect is not a class but a function. Als the arguments are different. Please look at https://www.php.net/manual/en/function.mysql-connect.php

Mark Baaijens
  • 496
  • 5
  • 6