Fatal error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

phpBrandNew
Forum Commoner
Posts: 36
Joined: Thu Sep 02, 2010 12:51 am

Fatal error

Post by phpBrandNew »

Hi
I encounter the following fatal error, what does it means ?

Fatal error:
Call to undefined function mysql_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\dbDetails.php on line 21

dbDetail.php -
https://docs.google.com/file/d/0B4UYFQD ... sp=sharing
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Fatal error

Post by Christopher »

It sounds like you do not have the mysql extension installed on this server. You can use the phpinfo() function to display what extensions are installed. You can also try mysqli_connect() and the mysqli functions.
(#10850)
phpBrandNew
Forum Commoner
Posts: 36
Joined: Thu Sep 02, 2010 12:51 am

Re: Fatal error

Post by phpBrandNew »

Where can I find the extension ?

please click here to view
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Fatal error

Post by Christopher »

Neither MySQL or PDO are listed. If this extension is already compiled for you PHP installation then edit your php.ini file to enable this extension. Otherwise you will need to recompile PHP with this extension.

I would recommend not using the mysql extension as it is no longer supported. Instead use the mysqli or PDO extension.
(#10850)
phpBrandNew
Forum Commoner
Posts: 36
Joined: Thu Sep 02, 2010 12:51 am

Re: Fatal error

Post by phpBrandNew »

According to php.ini, seems extension=php_mysqli.dll is already enable.
https://docs.google.com/file/d/0B4UYFQD ... sp=sharing

I do not know whether I am right ??

(Installation on Windows Systems

On Windows, PHP is most commonly installed using the binary installer.
PHP 5.0, 5.1, 5.2

Once PHP has been installed, some configuration is required to enable mysqli and specify the client library you want it to use.

The mysqli extension is not enabled by default, so the php_mysqli.dll DLL must be enabled inside of php.ini. In order to do this you need to find the php.ini file (typically located in c:\php), and make sure you remove the comment (semi-colon) from the start of the line extension=php_mysqli.dll, in the section marked [PHP_MYSQLI].

Also, if you want to use the MySQL Client Library with mysqli, you need to make sure PHP can access the client library file. The MySQL Client Library is included as a file named libmysql.dll in the Windows PHP distribution. This file needs to be available in the Windows system's PATH environment variable, so that it can be successfully loaded. See the FAQ titled "How do I add my PHP directory to the PATH on Windows" for information on how to do this. Copying libmysql.dll to the Windows system directory (typically c:\Windows\system) also works, as the system directory is by default in the system's PATH. However, this practice is strongly discouraged.

As with enabling any PHP extension (such as php_mysqli.dll), the PHP directive extension_dir should be set to the directory where the PHP extensions are located. See also the Manual Windows Installation Instructions. An example extension_dir value for PHP 5 is c:\php\ext. )
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Fatal error

Post by Christopher »

Yes all of those things. You need to 1) make sure the path to the extensions directory is correct in php.ini, 2) uncomment the extensions that you want to enable in php.ini, 3) restart the webserver so the changes take effect, 4) check phpinfo() to verify that the extensions are loaded.
(#10850)
phpBrandNew
Forum Commoner
Posts: 36
Joined: Thu Sep 02, 2010 12:51 am

Re: Fatal error

Post by phpBrandNew »

I believe I have done step 1-3, but couldn't load the extension. What I need to show that I have not done ?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Fatal error

Post by Christopher »

phpBrandNew wrote:What I need to show that I have not done ?
Do you still get the "Call to undefined function mysql_connect()" error? Does phpinfo() show the mysql extension? Are you sure that your extension directory is set correctly in php.ini?
(#10850)
phpBrandNew
Forum Commoner
Posts: 36
Joined: Thu Sep 02, 2010 12:51 am

Re: Fatal error

Post by phpBrandNew »

Yes, I still bave " Call to undefined function mysql_connect()" error.

My phpinfo() still does not show mysql extension.

I have this in php.ini,

extension=php_mssql.dll
[PHP_MYSQL]
extension=php_mysqli.dll
[PHP_MYSQLI]

are they setting correctly ?
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Fatal error

Post by social_experiment »

phpBrandNew wrote:are they setting correctly ?
extension=php_mysql.dll
^ you want this

;extension=php_mysql.dll
It probably looks like this within your php.ini at the moment. remove the ; to enable the extension :)
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
phpBrandNew
Forum Commoner
Posts: 36
Joined: Thu Sep 02, 2010 12:51 am

Re: Fatal error

Post by phpBrandNew »

ya, the semicolon already removed, but no result.

According to my phpinfo(),
https://docs.google.com/file/d/0B4UYFQD ... sp=sharing

the configuration file (php.ini) path : C:\Windows

I install php in c:\, so it is c:\program files\php\php.ini

is this cause problem ?
annaharris
Forum Commoner
Posts: 30
Joined: Mon Mar 25, 2013 6:52 am

Re: Fatal error

Post by annaharris »

phpinfo may show the php details, but does it show that MySQL is installed? You need mysql to use mysql_connect. If you can't find a reference to mysql in phpinfo, make sure the library is loaded.
phpBrandNew
Forum Commoner
Posts: 36
Joined: Thu Sep 02, 2010 12:51 am

Re: Fatal error

Post by phpBrandNew »

ya, there is no mysql reference in phpinfo(). But how to get the library loaded ?
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Fatal error

Post by social_experiment »

phpBrandNew wrote:But how to get the library loaded ?
Try to re-install or use a package like XAMPP
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
phpBrandNew
Forum Commoner
Posts: 36
Joined: Thu Sep 02, 2010 12:51 am

Re: Fatal error

Post by phpBrandNew »

I already install XAMPP, as I am new to this, please hint on how to begin.
Post Reply