1) php7 unpacked into the c:\apps\php7 . I can not run the following script:

 <?php $link = mysql_connect("localhost", "qwe", "qwe"); ?> 

I get the error:

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

As I understood the problem is that the extension for mysql is not loaded. But in order to download it you need to uncomment the corresponding line in the php.ini . But I could not find such a file.

2) I tried to do the following.

 <?php dl('php_mysqli.dll'); $link = mysql_connect("localhost", "root", "root"); ?> 

But again I got an error:

 Warning: PHP Startup: Unable to load dynamic library 'C:\php\php_mysqli.dll' 

Apparently php looking for the extension is not where necessary.

Help me to understand.

  • 1000 years did not work with pure mysql, but I remember that in mysqli function mysqli_connect, and not mysql_connect. for mysql_connect there must be another extension - vitidev
  • php.net/manual/en/function.mysql-connect.php : This has been deprecated in PHP 5.5.0. Instead, the MySQLi or PDO_MySQL extension - E_p
  • Just in case, I inform you: the mysqli extension contains functions whose names begin with mysqli_ =) - Dmitriy Simushev
  • Changed on mysqli_connect. The error still remained. PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\php_mysqli.dll' - pank
  • And the file itself is there? - Dmitriy Simushev

1 answer 1

The mysql extension has been deprecated since PHP 5.5.0 and completely removed in PHP 7. It seems you should go to more modern tools for working with the database:

  • mysqli - a more modern version of the vendor-specific connector to MySQL. The functional interface of this library allows you to smooth the transition from mysql to mysqli . Most mysqli functions have signatures similar to mysql functions (for example, mysqli_query and mysql_query ). However, I highly recommend using the object interface of this library.

  • PDO is a library, which is a complete OOP toolkit for working with databases. The interface of this library allows you to abstract from the base with which the work occurs. (Although the differences in SQL syntax still remain.)

As a supplement, I will provide a link to another question on the comparison of PDO and mysqli.