I'm using PHP Version 5.3.3 on a Linux server. When I try to use mysql_connect() or mysqli_connect() to reach the database, I get an error saying:
Fatal error: Call to undefined function mysql_connect()
or
Fatal error: Call to undefined function mysqli_connect()
You can see my testing page here: http://gorp.osg.ufl.edu/BOT3151/testing.php
You can see the phpinfo page here: http://gorp.osg.ufl.edu/phptest.php
The relevant configure commands are here:
'--with-mysql=shared,/usr'
'--with-mysqli=shared,/usr/lib64/mysql/mysql_config'
'--with-pdo-mysql=shared,/usr/lib64/mysql/mysql_config'
It also says that these .ini files are being parsed:
/etc/php.d/mysql.ini
/etc/php.d/mysqli.ini
The php.ini file also includes these lines:
extension=mysql.so
extension=mysqli.so
So what's going wrong here? Is mySQL not properly installed on the server? How can I fix this?
ADDENDUM: I should have explained that this is on a shared server that I don't administer. I just have access to my folder on the server through SFTP. But I do have a php.ini file and I have an extensions folder. So is this something I can fix myself or do I need help from a server administrator?
Try to install PHP MySQL by:
apt-get install php5-mysql
Then your MySQL is easily set with your PHP and Apache setting. If your MySQL is installed already you can uninstall it first and then try to install PHP MySQL by the code above in a terminal.
It is the easiest way to do it without needing any settings.
The "mysqli" extension is not loaded. You can NOT see the section in your phpinfo() file.
http://gorp.osg.ufl.edu/phptest.php
You should see something like this on that page:
https://drive.google.com/open?id=0B7VdYIkRLxQWaDRLYVNLeU84am8
Just because you have uncommented the line extension=mysqli.so does not mean it will load. The file mysqli.so is possibly not in a folder where PHP is looking for it or does not exist at all.
Check "extension_dir" in your php.ini file. Then go and see if the file mysqli.so is actually there.
Have you restarted your web server?
Given that your PHP info page does not list a section displaying the MySQL configuration, it stands to reason that MySQL may not be installed on your server.
I was facing similar issue. There was some problem with the default values in php.ini file. Please have a look at this answer if your problem wasn't solved with the answer given above.
Related
I have IIS 10 and my program calls curl_init function to make API calls. But I get this error:
"Call to undefined function curl_init()" . Also when I look at the output of phpinfo() there is no cURL section showed up.
I've triple checked the php.ini file for extension=curl and ext folder for php_curl.dll. I also downloaded ssleay32.dll libeay32.dll files to system32 folder in C:. I restarted the server a couple of time. Still, when I check the phpinfo() there is no curl section there.
Here is what I have found in StackOverflow:
similar error
joshjdevl's answer may be the solution but what is the difference between thread-safe and non-thread-safe PHP package
Why does it work ?
about enabling curl extension here it is said that one should "add paths of your PHP directory to the Windows Environment PATH Variable for .dll dependencies." but in my local machine-my another machine-(with wampserver) I didn't add PHP to environment variables and it works, so do I really need to do that?
about making sure the system uses the correct php.ini file When I look at the phpinfo output I can see the path of the php.ini file. Based on that I assume IIS uses that php.ini file. I don't expect it to use another one.
about installing curl extension
I have searched more than 30 StackOverflow pages and still do not have a solution.
After 8 hours of search and tens of StackOverflow questions, I've finally added the PHP path to environment variables and in the output of phpinfo() method cURL section started being shown and the error disappeared.
Windows Start -> Edit the system environment variables -> Advanced -> Environment Variables -> New..
For a more detailed explanation and for screenshots
But still have no idea why it works properly even though I didn't add PHP paths to Environment variables in my local machine. I assume it may be about wampserver configurations.
I have been a happy user of XAMPP for years,
but today I have updated to the latest Windows 32 bit version on a Windows 10 machine.
I couldn't see a 64 bit version.
Anyway, all went well,
and once I changed some settings, I was able to see all my old databases under the new phpMyAdmin.
But my PHP scripts are bombing out before they start.
Even phpinfo gives the same error message, which is...
"Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'F:/My Documents/OneDrive/Webs/htdocs/index.php'
(include_path='.;C:/xampp/php/pear/PEAR') in Unknown on line 0"
The test script of index.php is nothing more than
<?php echo "HELLO"; ?>
The statement in php.ini is
include_path = ".;C:/xampp/php/pear/PEAR"
and there are no other include_path statements.
The directory C:/xampp/php/pear/PEAR does exist.
The index.php file is there.
I don't know why there's a PEAR folder inside a pear folder - that's how Xampp installed it.
I have tried all variations of that include_path statement to no avail.
I have left out one of the pears.
Leaving out the include_path statement altogether just results in the PHP default which is a folder which is definitely not there, so that's no good.
My localhost is inside the OneDrive folder as you can see from the error message, but I have been doing it that way for years.
Now I cannot run any PHP scripts. Pure HTML is no problem.
The new installation of Xampp has totally replaced the old one, and its Control Panel v3.2.2 looks to be working perfectly.
phpMyAdmin seems to be working fine, but not phpinfo, as said.
I have scanned the web for answers to this, and there is plenty of forum Q&A's, but they all tell me to do what I have done.
The computer is Windows 10 Pro, and is fully up to date. Apache 2.4.33.
PHP 5.6.35. Database server is 10.1.31 MariaDB.
I've run out of ideas. Any help will be appreciated.
Thanks Mike.
You need to fix your include_path system variable to point to the correct location.
To fix it edit the php.ini file. In that file you will find a line that says, "include_path = ...". (You can find out what the location of php.ini by running phpinfo() on a page.) Fix the part of the line that says, "\xampplite\php\pear\PEAR" to read "C:\xampplite\php\pear". Make sure to leave the semi-colons before and/or after the line in place.
Restart PHP and you should be good to go. To restart PHP in IIS you can restart the application pool assigned to your site or, better yet, restart IIS all together.
first: check all the paths in the php. ini ( use a search or a grep to check them)
second: check that you don't have any extensions added twice (one in the beginning and one in the end of the file)
I am having a problem getting phpmyadmin to work correctly on my desktop. Every time I try running phpmyadmin, I get the following error:
Fatal error: Call to undefined function __() in C:\Apache24\htdocs\phpMyAdmin\libraries\sanitizing.lib.php on line 135
I was wondering if anyone has advise on how to make phpmyadmin work correctly. I have Apache v2.4.1.8, php v5.5.33, and phpMAdmin v4.6.0 installed and according to the tutorials I followed, everything works correctly until I get to the phpMyAdmin.
If you need any other info, I will reply what I can.
This is a permissions error.
You need to
Go into php.ini file and make sure extension=mbstring.dll is enabled.
Restart your webserver.
In the newest php versions the "extension_dir" path is not enabled initial. So maybe it helps... :)
screenshot
In addition to making sure extension=mbstring.dll is enabled, you should make sure the extension path is correct.
By default, the extension path is set "/ext" in the php.ini file.
However, when install httpd as a service, the relative path may be incorrect.
So, you should edit the extension path to an absolute path, such as "C:\Program Files\PHP\v5.6.21\ext".
I just installed Apache 2.2.15/PHP 5.3.2/MySQL 5.1.44 on Windows Vista. Apache is working fine, PHP is functional, and MySQL works on the CLI. However, when I try to access MySQL via PHP, I get an error (Fatal error: Call to undefined function mysql_connect()). extension=php_mysql.dll and extension=php_mbstring.dll are uncommented in the php.ini file, and PHP is in the system path. There is no libmysql.dll in either the top level PHP directory or the ext directory. There's a libmySQL.dll file in the MySQL bin directory (which is also in the system path); I tried renaming it, but that doesn't do anything
Also, in case anyone wants to know, I originally installed PHP using the MSI installer, but it was missing some DLLs, so I installed from the zip file.
I think I've exhausted all my options. Any help on this problem would be very appreciated.
Thanks in advance.
IIRC the msi installer sets some registry values that influence the php configuration, see http://docs.php.net/configuration.changes#configuration.changes.windows. That might change the location of the php.ini that is used. You might want to delete those registry keys. Anyway, you did edit the file that is shown in the output of phpinfo()?
Which build of php do you use? The one you can download from http://windows.php.net/download/? Then you probably have the new mysqlnd transport driver built into the php core dll and don't need libmysql.dll. The mysqlnd driver should show up in the output of phpinfo(). Does it?
It sounds like you do not have the MySQL mod for PHP properly installed or configured. I recommend using AMP on Linux, so sorry for not having any specific instructions for Windows.
I'm using WAMP on windows, which installs PHP, Apache and MySQL.
I'm now working on something new that requires PostgreSQL. The current install won't do it for me, as I keep getting these errors:
Call to undefined function pg_query()
Always
undefined function
I've installed PostgreSQL 8.3.7-1 for windows, added php_pgsql.dll,php_pdo_pgsql.dll and even libpq.dll, which a note on the PHP page for postgreSQL says Windows users need starting from PHP 5.2.6
Still, I keep getting these errors...
Can someone advise the best course of action? Or should I just uninstall apache and everything else, and do a fresh install of each component seperatly?
xampp doesn't "tell" apache/php which php.ini to use. Therefore php uses its default lookup strategy to find the .ini file. If you haven't changed anything this will be the one in the directory where the apache binary is located, xampp/apache/bin/php.ini. Did you edit this file and removed the semicolon before extension=php_pgsql.dll ?
When in doubt askecho 'php.ini: ', get_cfg_var('cfg_file_path');which file you have to edit.
xampp installs php as a module by default and you have to restart the apache in order to get php to read the php.ini again.
After thatecho extension_loaded('pgsql') ? 'yes':'no';should print yes. If it doesn't stop the apache service, open a command shell, go to your xampp directory and enterapache_start.batThis will start the apache as a console application and you can see startup errors in this console (instead of windows' event manager). If a dll is missing you will get a message box.
Did you enable it in the php ini file?
What does a call to phpinfo() say is installed for extensions?
Depending on what kind of errors you see in the Apache's error.log the answers on this question might be helpful.
I did the same as you did and got rid of the issue.But mine was for xampp. Probably you should re-install your wamp.