m4u_hoahoctro Posted June 13, 2015 Share Posted June 13, 2015 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 Quote Link to comment https://forums.phpfreaks.com/topic/296790-call-undefined-function-mysqli_connect/ Share on other sites More sharing options...
QuickOldCar Posted June 13, 2015 Share Posted June 13, 2015 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)); Quote Link to comment https://forums.phpfreaks.com/topic/296790-call-undefined-function-mysqli_connect/#findComment-1513771 Share on other sites More sharing options...
m4u_hoahoctro Posted June 13, 2015 Author Share Posted June 13, 2015 I found 2 lines extension=php_mysql.dll extension=php_mysqli.dll I remove ";" and restart vertrigo but the problem is still exsiting Quote Link to comment https://forums.phpfreaks.com/topic/296790-call-undefined-function-mysqli_connect/#findComment-1513775 Share on other sites More sharing options...
QuickOldCar Posted June 13, 2015 Share Posted June 13, 2015 vertrigo is not apache Quote Link to comment https://forums.phpfreaks.com/topic/296790-call-undefined-function-mysqli_connect/#findComment-1513776 Share on other sites More sharing options...
m4u_hoahoctro Posted June 13, 2015 Author Share Posted June 13, 2015 vertrigo is not apache sorry because I haven't had many knowledges about web but I modified above lines as you said, so if not enough, what shoud I do next ? Quote Link to comment https://forums.phpfreaks.com/topic/296790-call-undefined-function-mysqli_connect/#findComment-1513778 Share on other sites More sharing options...
jazzman1 Posted June 13, 2015 Share Posted June 13, 2015 (edited) 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 June 13, 2015 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/296790-call-undefined-function-mysqli_connect/#findComment-1513779 Share on other sites More sharing options...
m4u_hoahoctro Posted June 13, 2015 Author Share Posted June 13, 2015 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 when compile in phpdesigner software thanks much for helping Quote Link to comment https://forums.phpfreaks.com/topic/296790-call-undefined-function-mysqli_connect/#findComment-1513780 Share on other sites More sharing options...
jazzman1 Posted June 13, 2015 Share Posted June 13, 2015 Yeap, you have a problem with your local setup. What happens if you're using mysl_connect instead mysqli_connect function? Quote Link to comment https://forums.phpfreaks.com/topic/296790-call-undefined-function-mysqli_connect/#findComment-1513783 Share on other sites More sharing options...
QuickOldCar Posted June 13, 2015 Share Posted June 13, 2015 Restarting the server is an easy way. Quote Link to comment https://forums.phpfreaks.com/topic/296790-call-undefined-function-mysqli_connect/#findComment-1513784 Share on other sites More sharing options...
m4u_hoahoctro Posted June 13, 2015 Author Share Posted June 13, 2015 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 Quote Link to comment https://forums.phpfreaks.com/topic/296790-call-undefined-function-mysqli_connect/#findComment-1513785 Share on other sites More sharing options...
jazzman1 Posted June 13, 2015 Share Posted June 13, 2015 Try to run echo "Hello World"; onto your local machine and tell us what's going on. I am not sure how proper is you local setup config. Quote Link to comment https://forums.phpfreaks.com/topic/296790-call-undefined-function-mysqli_connect/#findComment-1513786 Share on other sites More sharing options...
Barand Posted June 13, 2015 Share Posted June 13, 2015 Re-run phpinfo(); and see if the MySQLi section has appeared and check the Loaded Configuration File setting to make sure you edited the correct php.ini file Quote Link to comment https://forums.phpfreaks.com/topic/296790-call-undefined-function-mysqli_connect/#findComment-1513787 Share on other sites More sharing options...
m4u_hoahoctro Posted June 13, 2015 Author Share Posted June 13, 2015 (edited) @Barand is it ? Edited June 13, 2015 by m4u_hoahoctro Quote Link to comment https://forums.phpfreaks.com/topic/296790-call-undefined-function-mysqli_connect/#findComment-1513788 Share on other sites More sharing options...
Barand Posted June 13, 2015 Share Posted June 13, 2015 Yes, that confirms that MySQLi is installed and the functions should be available to you Quote Link to comment https://forums.phpfreaks.com/topic/296790-call-undefined-function-mysqli_connect/#findComment-1513790 Share on other sites More sharing options...
mac_gyver Posted June 13, 2015 Share Posted June 13, 2015 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 Quote Link to comment https://forums.phpfreaks.com/topic/296790-call-undefined-function-mysqli_connect/#findComment-1513791 Share on other sites More sharing options...
m4u_hoahoctro Posted June 13, 2015 Author Share Posted June 13, 2015 (edited) 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 Edited June 13, 2015 by m4u_hoahoctro Quote Link to comment https://forums.phpfreaks.com/topic/296790-call-undefined-function-mysqli_connect/#findComment-1513818 Share on other sites More sharing options...
m4u_hoahoctro Posted June 14, 2015 Author Share Posted June 14, 2015 I tried connecting to mysql on my host of 000webhost. and it worked, but I don't know why the error when compile still appears Quote Link to comment https://forums.phpfreaks.com/topic/296790-call-undefined-function-mysqli_connect/#findComment-1513820 Share on other sites More sharing options...
mac_gyver Posted June 14, 2015 Share Posted June 14, 2015 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/296790-call-undefined-function-mysqli_connect/#findComment-1513848 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.