user3672491
user3672491

Reputation: 1

Couldn't able to connect to database

<?php 

$link = mysql_connect("localhost", "root", "") or die("Could not connect");

$db = mysql_select_db("goal123", $link) or die("Could not select database");

?>

I got two error messages "The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\wamp\www\Online Banking\db_connect.php on line 3"

and "Warning: mysql_connect(): in C:\wamp\www\Online Banking\db_connect.php on line 3"

After trying something like this

<?php 

$link = mysqli_connect('localhost', 'user', '');
mysqli_select_db('testdb', $link);

?>

I'm still getting a warning message that says "Warning: mysqli_select_db() expects parameter 1 to be mysqli, string given in C:\wamp\www\Online Banking\db_connect.php on line 4"

Can somebody help me out

Upvotes: 0

Views: 184

Answers (2)

Venkat
Venkat

Reputation: 263

Please call database with mysqli_connect

$link = mysqli_connect('localhost', 'user', '','testdb');

Please refer this link for more information

Upvotes: 0

ashkufaraz
ashkufaraz

Reputation: 5297

mysqli_select_db('testdb', $link);

change to

mysqli_select_db($link,"testdb");

Upvotes: 1

Related Questions