Skip to content
loading...

Help, l am getting error "call to undefined function msqli_query() " whenever l try connecting my database

ramseyrama555 profile image Ramsey Rama twitter logo ・1 min read  

Hey, am getting this error "call to undefined function msqli_query() " whenever l try to link with MSQL database.
Am using PHP 7 and l have edited and uncommented extension=msqli, pdo lines in php.ini file but none of the solutions seem to be working .
Below is my code:
<?php
$connection=msqli_connect("localhost","root","","php");

$name=$_POST["name"];
$email=$_POST["email"];
$pass=$_POST["password"];


mysqli_query($connection,"INSERT INTO `members`(`id`, `name`, `email`, `password`, `date`)
VALUES ('','$name','$email','$pass',NOW())");

?>
twitter logo DISCUSS (9)
Discussion
markdown guide
 

Hi,

could you check via the phpinfo(); function if the mysqli extension is loaded in your current environment.

If yes, you should see a table with "mysql support".

If you don't see the table then you may edited the wrong php.ini.

Make sure you've edited the php.ini in your php directory and not the php.ini~develop or php.ini~production.

Simon

 

One more question,

Did you wrote exactly "msqli_connect" or did you wrote "mysqli_connect"?

Maybe you have a spelling mistake.

 

Come to think of it, you were right the whole time, l had actually written "msqi" instead of "mysqli", wasn't paying attention well enough to my typos 😅😅, this has actually made me uninstall my local sever it was actually a simple typo error... Thanks buddy... I Will be more careful on typos

 

What do you mean by this because am seeing the same exact "mysqli_connect" in your statement

In your post above you wrote that you've enabled the "msqli" extension (it should be "mysqli").

Did you copied the error: "call to undefined function msqli_query() "

If yes, check that you have "mYsqli" every where not "msqli" (You missed the Y)

See: php.net/manual/en/mysqli.query.php

Simon

Yes got tired of searching endless.... I just backed up my htdocs files, databases, uninstalled Xampp and msql and deleted everything, reinstalled afresh n it's now working, guess the problem was some configuration problems that wasted my time, thanks for the reach out, the referenced link did really help to understand everything

 

I have edited the exact php.ini but still getting the same error sir

 

Hi,

just two more little things for correctness.

1. You should not save user input ($_POST) directly into the database.

See: php.net/manual/en/security.databas...
And: php.net/manual/en/mysqli.prepare.php

2. You save the user password also directly into the database, instead you should use php's inbuilt functions password_hash() and password_verify().

See: php.net/manual/en/function.passwor...
And: php.net/manual/en/function.passwor...

Have a nice day :)

Simon

 

Thanks so much for the guidance this will go along way

Classic DEV Post from Jul 27 '19

If You Don't Know, Now You Know - GitHub Is Restricting Access For Users From Iran And A Few Other Embargoed Countries

Please help our cause against modern-day discrimination

Ramsey Rama profile image
I am an AI developer and Data Scientist expert