-3

This is my database image :

enter image description here

Error in this line:

$con = mysql_connect("localhost","root","");

Error:

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\xampp\htdocs\Trial\insert.php:6 Stack trace: #0 {main} thrown in C:\xampp\htdocs\Trial\insert.php on line 6

halfer
  • 19,471
  • 17
  • 87
  • 173
  • 2
    which PHP version are you using? mysql_* lib has been removed from PHP7. –  Feb 22 '19 at 05:06
  • 3
    Possible duplicate of [Undefined function mysql\_connect()](https://stackoverflow.com/questions/13825108/undefined-function-mysql-connect) –  Feb 22 '19 at 05:15

2 Answers2

1

check your php version my calling echo phpinfo();, i guess its the version issue, php 7 doesnt support mysql functionalities, use mysqli instead, it will work for you

ashir haroon
  • 251
  • 1
  • 7
0

Unless you are on PHP 5.6 or below, mysql functions will not work. That function is removed in PHP 7.0+. You should use mysqli (see below) or PDO.

// If your local DB connection is default
$host = 'localhost';
$username = 'root';
$password = '';
$database = 'YOUR_DB_NAME';

$con = mysqli_connect('$host',$username',$password,$database);
halfer
  • 19,471
  • 17
  • 87
  • 173