Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Call to undefined function mysql_connect()" after upgrade to php-7 [duplicate]

Tags:

php

php-7

debian

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.

like image 362
bytecode77 Avatar asked Dec 04 '15 12:12

bytecode77


1 Answers

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'); 
like image 101
Abhishek Sharma Avatar answered Sep 29 '22 18:09

Abhishek Sharma