# Changing PHP Version - Common Errors

[PHP](https://www.ionos.ca/digitalguide/websites/website-creation/learn-php-our-all-encompassing-php-tutorial-for-beginners/ "Learn PHP: our all-encompassing PHP tutorial for beginners") is under constant development, therefore updates and new versions are available at irregular intervals. Sometimes updates cause scripts to stop working and therefore need to be adjusted. **A tip in advance:** A simple update of your CMS or plugin to a current version often helps.

In this article we want to discuss with you common bugs in PHP version changes and work out solutions to fix them.

## Conversion of SQL functions when updating from PHP5 to PHP7

The development of [PHP 7](https://www.ionos.ca/digitalguide/websites/web-development/how-php7-speeds-up-the-internet/ "How PHP7 speeds up the internet") partially abandoned backwards compatibility. You can find more backgrounds in the [Migration guides of the PHP project](http://php.net/manual/de/migration70.php "PHP project") . One of the most common errors that occurs when updating from PHP5 to PHP7 is the change from PHP function **mysql()** to **mysqli()**.

In concrete terms, the function **mysql()** no longer works. This function has been replaced by **mysqli()**. Many functions can be corrected by adding a **"i"** to the existing mysql() function.

The following error message tells you that you are using a database driver that is no longer supported:

```none
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in… line…
```

## Connection Identifier

To switch to the new database version, use the new connection identifier in addition to the mysql(i) functions. In our example this is called: **$link**

```none
<?php  
// old: mysql() establish connection:
mysql_connect("localhost", "root", "", "test");
// new: mysqli() establish connection:
$link = mysqli_connect("localhost", "root", "", "test");
?>
```

## Reading data from the DB table

Here an example of a simple data query:

```none
<?php
$link = mysqli_connect("localhost", "root", "", "test");
// Read datarecords (example)
 $datarecords = mysqli_query($link,
 "SELECT `name`, `text`, `date` FROM `news`");
// Read data records
while (list($name, $text, $date) = mysqli_fetch_array($datarecords)) {
 echo "<p>$name - $titel - $text - $date</p>";
}
?>
```

If you want to know more about our background: The following external article provides an introduction and background to the possibilities available to you in developing a PHP application that needs to interact with a MySQL database. [call article](http://php.net/manual/en/mysqli.overview.php "PHP Overview")


This is a markdown version of: [https://www.ionos.ca/digitalguide/websites/web-development/frequent-errors-when-changing-php-versions/](https://www.ionos.ca/digitalguide/websites/web-development/frequent-errors-when-changing-php-versions/) for AI/LLM consumption.