Jump to content

Recommended Posts

I am a newbie, and I have just learned some knowledges about php

Today I tried using some command to work with database MySQL

In editor of phpdesigner, I typed this code:

 

<?php
phpinfo(); 
 
// Create connection
    $db = mysqli_connect("localhost", "booksdb", "TABLEname") or die(mysqli_connect_error());
 
 
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
 
?>
 
but when Ctrl + F9 to compile, It show error: Fatal error: Call undefined function mysqli_connect()
 
I saw some questions same me asked on stackoverlow, some ones said the reason is extension mysql has't been enabled yet. But I don't know how to to that ? ( I also setuped Xampp and Vertrigo )
 
So I need a suggestion from other members
 
Thanks for reading
Link to comment
https://forums.phpfreaks.com/topic/296790-call-undefined-function-mysqli_connect/
Share on other sites

What operating system and server packages are you using now?

 

phpinfo(); is to see about server configuration, do you see a mysqli section? if so it's installed.

 

Look at Loaded Configuration File and visit that php.ini file location, ensure is no ; in front of extension=php_mysqli.dll

If you made a change and saved the file then restart apache service.

 

The correct way to connect is host,user,password,database

$db = mysqli_connect("localhost","user_name","user_password","database_name") or die("Error " . mysqli_error($db)); 

Do you have any problem with some other php function or only with this one? Could you run this script and give us the output (should be mysqli_connect function is not available).  Try also the old mysql_connect instead mysqli_connect.

<?php

if (function_exists('mysqli_connect')) {
    echo "mysqli_connect function is available.<br />\n";
} else {
    echo "mysqli_connect function is not available.<br />\n";
}
Edited by jazzman1

 

Do you have any problem with some other php function or only with this one? Could you run this script and give us the output (should be mysqli_connect function is not available).  Try also the old mysql_connect instead mysqli_connect.

<?php

if (function_exists('mysqli_connect')) {
    echo "mysqli_connect function is available.<br />\n";
} else {
    echo "mysqli_connect function is not available.<br />\n";
}

I tested on host of 000webhost. and result is "mysqli_connect function is available."

 

so the aim I want is able to remove error: Fatal call to undefined function mysql  :sweat: when compile in phpdesigner software

thanks much for helping

 

Yeap, you have a problem with your local setup. What happens if you're using mysl_connect instead mysqli_connect function?

 

I tried using both code with above 2 functions, add compiler still announces: Fatal call to undefined..........

In this case, does my computer has some problem ?

ok I will create new database on 000webhost and try writting a connected app php

thanks

the phpdesigner ide you are using is invoking php directly, not through the web server.

 

you either need to invoke your files using a browser, through the web server, or you need to configure phpdesigner to use the same php.ini that the web based php is using. see the following from the phpdesigner documentation -

 

If you are working with PHP extensions such as MySQL please specify where to find the PHP configuration file (php.ini).

 

On the Tools menu, point to Preferences

Select Debugger

In the field 'Configuration File' check and type in the path for the configuration file (.ini), or click the Browse button to locate the PHP interpreter

the phpdesigner ide you are using is invoking php directly, not through the web server.

 

you either need to invoke your files using a browser, through the web server, or you need to configure phpdesigner to use the same php.ini that the web based php is using. see the following from the phpdesigner documentation -

 

 

I did as you told, but the error still appears  :sweat:

Edited by m4u_hoahoctro

at this point i don't think we know what exactly you have or what's being ran. you stated you installed xampp and Vertrigo. afaik, those both would have attempted to install Apache/Mysql/Php and either would have produced installation errors or perhaps installed two different apache/mysql servers using different port numbers.

 

when you are running the phpinfo(); statement to find the php.ini and the mysqli information, how exactly are you invoking the .php script containing the phpinfo() statement? through phpdesigner or are you using your browser with a url something like - http://localhost/your_php_file.php ?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.