66

After I upgraded php5 to php7, I get an error 500 with

PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect()

I put this into my apt sources in order to get php7 right now:

deb http://packages.dotdeb.org jessie all
deb-src http://packages.dotdeb.org jessie all

What I basically did is:

apt-get remove php5
apt-get install php7-*

I'm using the current version of Debian Jessie.

But I still get this. There are a lot of questions here on SO and I definitely checked them all out. But I didn't find an answer there yet.

7
  • 15
    MYSQL is deprecated from 5.5 and its fully removed in PHP 7 .. There are MYSQLi and PDO libs to connect mysql.. 2-3 years was the period for moving all old apps into the new None MYSQL way.. Commented Dec 4, 2015 at 12:26
  • In the migration document, it tells you that mysql_ is removed. Also, entire SO is screaming about this removal for several years now. There are no such functions any more and you can't use them. If your project depends on it, revert back to php version that supports it. Commented Dec 4, 2015 at 12:33
  • I think you need to read and digest the PHP7 release notes and also the Migration notes Before attempting any move to PHP7. Its a very different beast now Commented Dec 4, 2015 at 12:36
  • 3
    Why all the down-votes? This guy asked a reasonable question, and got a reasonable answe! Commented Dec 22, 2015 at 23:39
  • 2
    You can manually install the mysql extension and it works with PHP7 - see github.com/php/pecl-database-mysql Commented Apr 22, 2016 at 8:45

1 Answer 1

88

From the PHP Manual:

Warning This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide. Alternatives to this function include:

mysqli_connect()

PDO::__construct()

use MySQLi or PDO

<?php
$con = mysqli_connect('localhost', 'username', 'password', 'database');
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.