1

I have this PHP code:

define('DB_SERVER', 'localhost:3306');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', 'viadonau');
define('DB_DATABASE', 'vinoservice');
echo DB_SERVER ;
echo DB_USERNAME;
echo DB_PASSWORD;
echo DB_DATABASE;
$link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE);

I alway get a fatal error and i dont know why....on mysql workbench i can connect to the database...and in PHPStorm i can also configure the data source and i can run a query but in php i cant connect. Thanks for help!!!

5
  • keep password as empty if you are working in local.. Commented Feb 24, 2017 at 10:56
  • 2
    the error seems to say that the mysqli extension is not installed/activated see stackoverflow.com/questions/25281467/… Commented Feb 24, 2017 at 10:58
  • 1
    looks to me the MySQLi php library is not enabled.. check it with <?php phpinfo(); ?> Commented Feb 24, 2017 at 10:58
  • I add these two lines but not working yet :S : extension=php_mysqli.dll extension=C:\Utils\php\ext\php_mysqli.dll Commented Feb 24, 2017 at 11:08
  • You just have to remove ; from php.ini extension=php_mysqli.dll and ofcource restart apache Commented Feb 24, 2017 at 11:12

1 Answer 1

1

If you create a new PHP file and add the following to it, it should show if MySQLi is enabled or not.

<?php phpinfo(); ?>

If you don't have MySQLi then it will show up with no mysqli

If you do have it, it will show mysqli

You can install the MySQLi extension through terminal by using the following, if on PHP5

apt-get install php5-mysqli

However if you use php 7 use

apt-get install php7.0-mysqli
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.