MAMP can't do mysqli

Asked 2 years ago, Updated 2 years ago, 46 views

<?php
define("HOSTNAME","localhost");
define("USERNAME","root");
define("PASSWORD","root");
define("DB_NAME","testDB");

$conn = new mysqli(HOSTNAME, USERNAME, PASSWORD, DB_NAME);

if($conn->connect_errno) {
    echo("<br>Failed to connect to MySQL:(".$conn->connect_errno.")".$conn->connect_error);
}else{
    echo("<br/>Connected to database ".DB_NAME);
    echo("<br/>".$conn->host_info);
}
?>

I'm simply working on a code that calls mysqli object-oriented, but it doesn't work on amp, it only works on wamp There is nothing on the result page and only 500 error codes are being received from the server.

Add phpinfo.

php mysql

2022-09-22 21:34

1 Answers

Is Mamp and Wamp a development environment integration program like Xampp?

Maybe it's a problem that mysqli extension module is not installed.

To tell you what I remember, at php.ini extension=php_mysqli Uncomment or

Or I think the php version is low. Alternatively, there will be a setting that adds an extension module in that program.

The error not output is

error_reporting(E_ALL);
ini_set("display_errors", 1);
If you add two lines to the top and try again, the error will be printed.

I hope it helps you a lot.


2022-09-22 21:34

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.