-3

My website is not connecting.

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /home/site/web/site/public_html/conn.php:3 Stack trace: #0 /home//public_html/origin/index.php(147): include() #1 {main} thrown in /home/site/web/site/public_html/conn.php on line 3

<?php
$link = mysql_connect('localhost', 'user', 'pass') 
    or die('Unable to connect: ' . mysql_error());
mysql_select_db('database');
mysql_query("SET NAMES 'utf8'");
mysql_query('SET character_set_connection=utf8');
mysql_query('SET character_set_client=utf8');
mysql_query('SET character_set_results=utf8');
?> 
Ralf K
  • 17
  • 1
  • 6
  • `mysql_*` functions have been eliminated in PHP7. Use the `mysqli_*` function equivalents, or possibly `PDO`. See [this answer](https://stackoverflow.com/a/12860046/7644018) for more info. – Paul T. Mar 08 '20 at 21:31

1 Answers1

0

The mysql extension has long been deprecated and can no longer be used in PHP7.

You have these options:

  • Convert your code to mysqli or, better, PDO.
  • If this is not feasible because it's not your code or not being actively developed:
    • Use php7-mysql-shim which "emulates" the mysql extension. Make sure to read the readme!
    • Or, if this doesn't provide enough compatibility (or other errors related to PHP7-incompatibility surface) use PHP5.6 for the time being and try to find updates to the software as soon as possible
CherryDT
  • 25,571
  • 5
  • 49
  • 74