-7

Im developed PHP user login and registration system, i have a displayed always this error in my local host , how to fix it?

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead (C:\wamp\www\registerations\db.php on line 9)

this is my code db.php

<?php
$connection = mysql_connect('localhost', 'root', '');
if (!$connection){
    die("Database Connection Failed" . mysql_error());
}
$select_db = mysql_select_db('register');
if (!$select_db){
    die("Database Selection Failed" . mysql_error());
}
?>
vimuth
  • 5,064
  • 33
  • 79
  • 116
Wraith King
  • 192
  • 2
  • 19
  • 2
    The error speaks for itself – DirtyBit Sep 26 '15 at 05:32
  • Please, please please - *search* before asking another question. – user2864740 Sep 26 '15 at 05:34
  • @DirtyBit not really. There are lots of different PHP manager platforms. How do you install mysqli in arbitrary managed environments? How do you port the calls? There are a few stages to negotiate and some of them are showstoppers. E.g. environments where PHP modules aren't installable. – Shiv Apr 07 '19 at 23:00

2 Answers2

3
  <?php
$con = mysqli_connect("localhost","root","","register");

// Check connection
if (mysqli_connect_errno())
 {
 echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
?> 

// try this..

avktech
  • 92
  • 1
  • 11
0

In case if you're still struggling, this is what you should be looking into:

<?php
$mysqli = new mysqli('localhost', 'your_username_here', 'your_password_here', 'your_db_name_here');


if ($mysqli->connect_error) {
    die('Connect Error (' . $mysqli->connect_errno . ') '
            . $mysqli->connect_error);
}

PHP Manual

DirtyBit
  • 16,613
  • 4
  • 34
  • 55