-5

Aaalright, i really need some help to this, because im really confused. Im trying to connect to a database on phpmyadmin.

<?php
mysql_connect('localhost', 'root', '');
mysql_select_db('test_database');
?>

Here im using "mysql_connect". When i run it, it says that this extension deprecated/outdated and that i have to use "mysqli_connect".

So now i'm just using the same code as above, but just with the "i" at the end instead.

What am I doing wrong?

In advance, thanks!

PS: My first language is NOT english. Hope you will understand it.

user2713996
  • 139
  • 2
  • 2
  • 9
  • The database isn't on phpmyadmin, it's on a MySQL server; phpmyadmin is simply one of several applications that has been written to communicate with a MySQL database allowing you to work with the data stored in it – Mark Baker Jul 26 '14 at 16:10
  • *"Here im using "mysql_connect". When i run it, it says that this extension deprecated/outdated and that i have to use "mysqli_connect"."* - So do it. – Funk Forty Niner Jul 26 '14 at 16:10
  • [`mysqli`](http://php.net/manual/en/book.mysqli.php) [standing for _mysql improved_] is another extension. Read its manual and update your code accordingly. – moonwave99 Jul 26 '14 at 16:11
  • **Good riddance!**, the use of `mysql_` is 10 years *outdated*. Start using the newer mysqli or PDO extensions. This will require rewriting the affected portions of code. – user2864740 Jul 26 '14 at 16:11
  • [mysql vs mysqli](http://stackoverflow.com/questions/548986/mysql-vs-mysqli-in-php) – Mark Baker Jul 26 '14 at 16:11
  • Parameters/order are not the same between `mysql_` and `mysqli_`, for example -> `mysql_query($query [,$dbconnection])` vs. `msyqli_query($dbconnection, $query)`. Unfortunately it is not simply changing `mysql_` to `msyqli_` (adding the `i`). – Sean Jul 26 '14 at 16:34

3 Answers3

1

Php has changed to mysqli, so you will have to use mysqli instead of mysql. In mysqli, you don't just add an i and it's done. Read this for all the mysqli functions http://php.net/manual/en/book.mysqli.php

    <?php
$con = mysqli_connect('localhost', 'root', '', 'test_database');
mysqli_query($con, "UPDATE `table` SET id='1'");


?>

ex. of mysqli query^^

jadbalout
  • 25
  • 5
0

mysqli_select_db parameters are different. Read their documentation: http://us3.php.net/manual/en/mysqli.select-db.php

klandaika
  • 357
  • 3
  • 11
0

You are using mysql_connect.You must replace it with mysql_connect and learn about its functions.

This link would be a nice read

Avinash Babu
  • 6,171
  • 3
  • 21
  • 26