0
<?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

  • 1
    Can you please post your code? And you should really consider moving to mysqli or PDO, mysql_* functions are deprecated and will not be supported in the future. – Drown Nov 20 '14 at 19:28
  • Please, [don't use `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php), They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared statements](http://en.wikipedia.org/wiki/Prepared_statement) instead, and use [PDO](http://us1.php.net/pdo) or [MySQLi](http://us1.php.net/mysqli). You will also want to [Prevent SQL Injection!](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) – Jay Blanchard Nov 20 '14 at 19:38
  • Connection comes first in `mysqli` – Funk Forty Niner Nov 20 '14 at 19:48

2 Answers2

1
mysqli_select_db('testdb', $link);

change to

mysqli_select_db($link,"testdb");
ashkufaraz
  • 5,179
  • 6
  • 51
  • 82
0

Please call database with mysqli_connect

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

Please refer this link for more information

Venkat
  • 243
  • 2
  • 11