Page 1 of 2

Fatal error

Posted: Thu May 23, 2013 10:13 pm
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

Re: Fatal error

Posted: Fri May 24, 2013 12:53 am
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.

Re: Fatal error

Posted: Fri May 24, 2013 2:27 am
by phpBrandNew
Where can I find the extension ?

please click here to view

Re: Fatal error

Posted: Fri May 24, 2013 3:21 pm
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.

Re: Fatal error

Posted: Sat May 25, 2013 9:26 am
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. )

Re: Fatal error

Posted: Sat May 25, 2013 10:29 am
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.

Re: Fatal error

Posted: Mon May 27, 2013 8:14 am
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 ?

Re: Fatal error

Posted: Mon May 27, 2013 9:57 am
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?

Re: Fatal error

Posted: Tue May 28, 2013 12:52 am
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 ?

Re: Fatal error

Posted: Tue May 28, 2013 3:26 am
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 :)

Re: Fatal error

Posted: Tue May 28, 2013 5:25 am
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 ?

Re: Fatal error

Posted: Sat Jun 01, 2013 6:43 am
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.

Re: Fatal error

Posted: Sun Jun 02, 2013 4:21 am
by phpBrandNew
ya, there is no mysql reference in phpinfo(). But how to get the library loaded ?

Re: Fatal error

Posted: Sun Jun 02, 2013 8:47 am
by social_experiment
phpBrandNew wrote:But how to get the library loaded ?
Try to re-install or use a package like XAMPP

Re: Fatal error

Posted: Sun Jun 02, 2013 11:31 pm
by phpBrandNew
I already install XAMPP, as I am new to this, please hint on how to begin.