mysqli_connect/mysql_connect error:

Hi!

Getting error:

Fatal error: Call to undefined function mysqli_connect() in Y:\OpenServer\domains\localhost\index.php on line 2

PHP:

<?php
$link= mysqli_connect('localhost', 'root','', 'TEST');
?>

P.S. MYSQL database connected throught DATABASE

6 comments
  • Check that you PHP Folder contains php.ini.
  • In php.ini check that these strings are uncommented:

extension_dir = "<_Path to PHP folder_>\ext" 
extension=php_mysql.dll
extension=php_mysqli.dll
0

P.S.S ... Problem only in PHPSTORM debugger on adress http://localhost:63342/localhost/index.php .... on default http://localhost/index.php works fine... so some problem with PHPSTORM configuration...

0

Check your php.ini -- check what config file is used (top table from phpinfo() output) and see if MYSQL extensions are loaded.

PhpStorm has *nothing* to do with that -- it's all about php configuration and where it searches for config files.

Problem only in PHPSTORM debugger on adress http://localhost:63342/localhost/index.php .... on default http://localhost/index.php works fine

Then do not use localhost:63342 URLs ...

0

Phpstorm by default use  http://localhost:63342/localhost/index.php for debugging...  and it is not possible to change to http://localhost/index.php ... You just saying that i should not use Debbugger ??)))

What problem can be in php.ini if on default adress http://localhost/index.php is all fine... and same problem was with php when you did not set up it...

0
You just saying that i should not use Debbugger ??)))

No.

Phpstorm by default use  http://localhost:63342/localhost/index.php for debugging...  and it is not possible to change to http://localhost/index.php

This means that you have not set up any deployment entry ("Settings | Deployment" -- "In Place" type should be enough) and marked it as Default for this project. Of couse -- you need proper web server for that (Apache/nginx/IIS/etc)

Once done, IDE will build URLs that you have specified there.

Because you do not have default deployment entry, PhpStorm uses OWN SIMPLE web server using this kind of URL: localhost:63342/PROJECT_NAME/file.php. Based on your URLs .. you have a project called "localhost".

What problem can be in php.ini

You have not provided output of your phpinfo() .. so I cannot comment on this. I can only say that it works just fine here with php properly configured (Windows 7 using PhpStorm v7 & 8 EAP).

But it is possible that PHP cannot load mysql library when initialising those ,ysql extensions (for whatever reason) when using built-in server. Adding path to PHP folder to the PATH environment variable (and possible computer restart) may help here.

Couple of links in case you have not seen them yet:

0

Almost the same suggestion that from Andriy: run phpinfo() under built-in server (that you seem to use http://blog.jetbrains.com/phpstorm/2013/09/built-in-webserver-in-phpstorm/) and check if the correct php.ini is used with correct config.

0

Please sign in to leave a comment.