I installed apache, php and mysql. Now when I execute the php code, the mysqli_connect()
is not working, neither it's showing the message in die.
$dbc=mysqli_connect(' ', ' ', ' ', ' ') or die('not connecting');
Now someone tell me what database username shall I pass to mysqli_connect
and what password. I don't remember I was asked for any username or password
and why isn't the message in die()
showing up?
My var_dump(function_exists('mysqli_connect'));
outputs bool(false).. if it has anything to do with it, how do I correct it.?
The mysqli_connect() function establishes a connection with MySQL server and returns the connection as an object.
The mysqli_connect() function in PHP is used to connect you to the database. In the previous version of the connection mysql_connect() was used for connection and then there comes mysqli_connect() where i means improved version of connection and is more secure than mysql_connect().
It'll automatically enable the mysqli extension for the PHP because connect using mysql is deprecated in PHP 7. If not an Ubuntu user then you can just rename php-prodcution. ini file to php. ini and enable the extension by removing semicolon in the php.
PHP offers two different ways to connect to MySQL server: MySQLi (Improved MySQL) and PDO (PHP Data Objects) extensions. While the PDO extension is more portable and supports more than twelve different databases, MySQLi extension as the name suggests supports MySQL database only.
Looks like MySQLi extension is not installed. What does var_dump(function_exists('mysqli_connect'));
output?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With