Good day!

php -v 

PHP 7.0.24 (cli) (built: Sep 30 2017 10:10:28) (NTS)
Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies

When trying to run a script

 $user='test'; $password='test'; $database='test'; $host='localhost'; $link = mysqli($host, $user, $password, $database) or die (mysqli_error($link)); $q="select * from workers limit 1"; $result=mysqli_query($link,$q); echo $result; ?> 

an error is issued

PHP Fatal error: Uncaught Error: Call to undefined function mysqli () in /usr/share/nginx/html/test/index.php:6
Stack trace:
#0 {main}
thrown in /usr/share/nginx/html/test/index.php on line 6

In Google one answer connect the library php_mysqli.dll

But I have a cloud on my owncloud on owncloud and it works fine with the base. What could be the reason?

  • 2
    It is necessary to add new mysqli(...) . new operator - And
  • Did I do something wrong? $ link = new mysqli_connect ($ host, $ user, $ password, $ database) or die (mysqli_error ($ link)); PHP Fatal error: Uncaught Error: Class 'mysqli_connect' not found in /usr/share/nginx/html/test/index.php:6 - Eugene
  • or so PHP Fatal error: Uncaught Error: Class 'mysqli' not found in /usr/share/nginx/html/test/index.php:6 - Eugene
  • You call the mysqli function - which does not exist, since you are using an object, then you need to work with the $link object and its methods and properties, and for this you need to use the new operator before the name of the class mysqli . - And
  • Can you please for dull? tried to do by analogy with the theory.phphtml.net/books/php/sql item Establish a connection with the database - Eugene

3 answers 3

The mysqli place will be mysqli_connect

  • same PHP Fatal error: Uncaught Error: Call to undefined function mysqli_connect () in /usr/share/nginx/html/test/index.php:6 - Eugene
  • You have not installed the mysqli extension. In the PHP config add extension = mysqli.so - MrColT
  • PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/mysqli.so' - /usr/lib64/php/modules/mysqli.so: can not be shared line 0 - Eugene

Try this: OOP option: $link = new mysqli(params); Procedural option: $link = mysqli_connect(params); If the same error occurs, check whether the MySQLi (MySQL Improved) extension is installed by calling the php_info () function.

  • In the output of the command php_info () really did not find anything about mysql. How to install it now? - Eugene
  • Do not fool yourself if you are a beginner. Better download and install OSPanel. It includes everything that is possible and well tuned, and if you need extra. customization - that is, extensive documentation. For a beginner (and not only) you can’t think of anything better - Mikhail Oleynikov
  • Thanks for the advice already have Denver and php storm. Yes, just decided to make a test page on your VPS. Practical sense is no habit to finish until the end gives rest :) - Eugene

When I try to install yum install php-mysqli, we get the Error Error: php71w-common conflicts with php70w-common-7.0.24-1.w7.x86_64 I decided in a slightly different way I found that I will provide php-mysqli in php70w here link https: // webtatic. com / packages / php70 / php70w-mysql php-mysqli, php_database php70w-mysqlnd php-mysqli, php_database

I put php70w-mysql, the error is gone now "Object of class mysqli_result could not be converted to string" But this is more likely my logical or syntax error in the code. Thank you all for the answers!