r/PHPhelp • • Feb 06 '25

Call to undefined function mysqli_connect()

0 Upvotes

I've been trying to fix this issue for days, I tried checking if all the configuration files in xampp are set up correctly, I tried uninstalling and reinstalling xampp, nothing seems to work.

I'm bound to using mysqli to connect to a database for my uni project, so I can't look for an alternative.

Does anyone have a solution for this?

r/PHPhelp • • Sep 14 '21

Solved Issue with mysqli_connect()

2 Upvotes

I keep getting this error when ever i load up my website on windows:

Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in dir\public\config.php:8 Stack trace: #0 {main} thrown in dir\public\config.php on line 8

Ive looked online and tried editing the php.ini (not running apache so dont mention it) with uncommenting the extention= php_mysqli and even extension_dir = "E:\php\ext" but this didnt fix it. Below is my config file:

Config.php:

<?php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', 'test');
define('DB_NAME', 'web_mc_login');
 
/* Attempt to connect to MySQL database */
$link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
 
// Check connection
if($link === false){
    die("ERROR: Could not connect to " . DB_NAME + "Reason: " . mysqli_connect_error());
}

EDIT: Mange to fit by reinstalling php. No clue why though that would fix it

r/PHPhelp • • Nov 14 '23

Why am I receiving a "Fatal error: Uncaught mysqli_sql_exception" Error

1 Upvotes

I've doubled checked multiple times and the database details are not incorrect in the code. Is there something else that I am missing or is it that I simple cannot connect to the database.

<?php

// gets access to php file containing my password $pass = include("pass.php"); // echo $password;

// connects to the weather_report database $connect = new mysqli("localhost","db2349473","$password","weather_report");

// error managing if ($connect->connect_error) { echo "Connection error:". $connect ->connect_error; exit(); }

// writes query for all fields in weather_report $mysql = "SELECT * FROM weather_report ORDER BY last_update DESC limit 1";

// gets results $result = $connect ->query($mysql);

if ($result == false) { echo "<h4> SQL error description: ". $connect ->error. "</h4>"; }

/// GET data, convert to JSON and print $row = $result -> fetch_assoc(); print json_encode($row);

// Free result set and close connection $result -> free_result(); $connect -> close();

?>

r/PHPhelp • • Mar 31 '20

Call to undefined function mysqli_connect()

2 Upvotes

Hello!

So I have my code:

<?php
/* Database credentials. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_NAME', 'slashed');
 
/* Attempt to connect to MySQL database */
$link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

$mysqli = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
 
// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
} else {
	// echo("Success");
}
?>

and it throws: Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /var/www/html/assets/config.php:10

I have done everything I could find, and am at my wit's end.

I am using an AWS ec2 with the amazon Linux distro.

Thanks!

r/PHPhelp • • Jan 04 '24

Solved I'm getting the Error Fatal error: Uncaught mysqli_sql_exception

2 Upvotes

Hey.

For several years I have been using a small PHP tool to enter, display and manage events. The tool was programmed by someone else. Over the last few years I have tried to keep the code as functional as possible with every PHP version change on my webspace. But now I changed from PHP 8 to PHP 8.1 and it doesn't work anymore and I can't figure out what's wrong.

This is the error message I get:

Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Entry' at line 2 in /path/to/file.php:47 Stack trace: #0 /path/to/file.php(47): mysqli_query() #1 {main} thrown in /path/to/file.php on line 47

And this is the corresponding code in the PHP file (line 46-54):

   // update the database record
    $result = mysqli_query($db,"update $database_table
        set month='$month', day='$day', year='$year', venue='$venue', location='$location', details='$details', artist_id='$the_artist_id'  
        where show_id = '$the_id'") 
        or exit("<h2>Could not change show</h2>");

    // echo out a status report and show id
    echo("<div class='box'>\n\t<h3>showlister :: edit show</h3>\n</div>\n");
    echo("<div class='box'>show (id='$the_id') updated</div>\n");

Can anyone help?

r/AskProgramming • • Dec 09 '21

Databases Call to undefined function mysqli_connect()

4 Upvotes

I'm making a feedback system for my final year project which includes a login system.

Currently my problem is I'm stuck at connecting database.

The error is like the title says "Call to undefined function mysqli_connect()"

Code below:

$servername = "localhost";

$username = "root";

$password = "";

$databasename = "osfs";

$conn = mysqli_connect($servername, $username, $password, $databasename);

// database connection

if (!$conn)

{

die("Connection failed:" . mysqli_connect_error());

}

One solution to this problem that I've tried by looking up stackoverflow & discord is delete the semicolon ';' in front of extension=mysqli. There are 2 lines named extension=mysqli in my php.ini file and I've deleted both semicolons but the same error still persists. Is there something else that I'm missing?

I really don't have much time now since next week is the project's deadline.

Sharing a portion of the php.ini file where I made the edit just in case. The bold text is where I delete the ';'.

; If you wish to have an extension loaded automatically, use the following

; syntax:

;

; extension=modulename

;

; For example:

;

extension=mysqli

;

; When the extension library to load is not located in the default extension

; directory, You may specify an absolute path to the library file:

;

; extension=/path/to/extension/mysqli.so

;

; Note : The syntax used in previous PHP versions ('extension=<ext>.so' and

; 'extension='php_<ext>.dll') is supported for legacy reasons and may be

; deprecated in a future PHP major version. So, when it is possible, please

; move to the new ('extension=<ext>) syntax.

;

; Notes for Windows environments :

;

; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)

; extension folders as well as the separate PECL DLL download (PHP 5+).

; Be sure to appropriately set the extension_dir directive.

;

;extension=bz2

;extension=curl

;extension=fileinfo

;extension=gd2

;extension=gettext

;extension=gmp

;extension=intl

;extension=imap

;extension=interbase

;extension=ldap

;extension=mbstring

;extension=exif ; Must be after mbstring as it depends on it

extension=mysqli

r/PHPhelp • • Dec 05 '23

Solved PHP 5.6.40 MYSQL functions not working? - "Call to undefined function mysqli_connect()"

0 Upvotes

The DLL loads fine, but I still get Fatal error: Call to undefined function mysqli_connect() when testing it.

I have to use a version 5.x on this internal system for the moment - at some point the codebase it will be updated, to work with newer versions but don't have the time right now.

php -m shows it is the loaded

php -i shows

Loaded plugins => mysqlnd,debug_trace,auth_plugin_mysql_native_password,auth_plugin_mysql_clear_password
API Extensions => mysql,mysqli,pdo_mysql

mysqli
MysqlI Support => enabled
Client API library version => mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $
Active Persistent Links => 0
Inactive Persistent Links => 0
Active Links => 0
Directive => Local Value => Master Value
mysqli.allow_local_infile => On => On
mysqli.allow_persistent => On => On
mysqli.default_host => no value => no value
mysqli.default_port => 3306 => 3306
mysqli.default_pw => no value => no value
mysqli.default_socket => no value => no value
mysqli.default_user => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.max_persistent => Unlimited => Unlimited
mysqli.reconnect => Off => Off
mysqli.rollback_on_cached_plink => Off => Off

Anything else I should be looking for?