0

A few years ago I had to setup a internal webpage for work, one that included connecting to a mysql DB, is did this with this simple code:

<?php

function openDB(){
    # first get a mysql connection -
    $conn=mysql_connect("127.0.0.1","users","pass") or die("Could not connect to the exceptions server");
    $db=mysql_selectdb("db",$conn);
}

function closeDB(){
    mysql_close($conn);
}
?>

Now, that server is being decommissioned and it is now running on a new server. After investigating I found that the server is running a newer version of MYSQL (ver 8) and the mysql_connect command had been replaced.

I want to do the exact same thing but not sure what to do, I tried using a few mysqli commands but it keeps failing.

I didn't want to over complicate or re-invent the wheel of this web page, any help would be appreciated in recreating this for mysqli.

Dharman
  • 26,923
  • 21
  • 73
  • 125
  • 1
    It's not MySQL that's changed here, it's php. The `mysql_` API has been removed in favor of [`mysqli_`](https://www.php.net/manual/en/book.mysqli.php) or [`PDO`](https://www.php.net/manual/en/book.pdo.php). Both work well. – O. Jones Sep 17 '21 at 13:48

0 Answers0