Jump to content

Recommended Posts

You cannot do this:
[code]extension = "C:\PHP\ext\php_mysqli.dll"[/code]
You need to setup the extension_dir to point to where your PHP extensions are loacted

Then you scroll down and enable the php_mysql.dll extension. You enable this extension for the mysql_* functions.
If you are using the mysqli_* functions then you enable the php_mysqli.dll function.
[quote]You need to setup the extension_dir to point to where your PHP extensions are loacted[/quote]

Isn't that what "C:\PHP\ext" does??

And I'm using MySQL Server 5.0, so from my understanding I'm using the mysqli.dll file, so what do I need to do differently to call it?  I've tried both extension = "C:\PHP\ext\php_mysqli.dll" and
extension = "C:\PHP\ext\php_mysql.dll", which is the way the php.ini came, only I deleted the semicolon and added the "i" in php_mysqli.dll when php_mysql.dll didn't work....
You cannot do [i]extension = "C:\PHP\ext\php_mysqli.dll"[/i] to enable a PHP extension. What you need to do is uncomment the extension you want to enable in the php.ini. For example if you want to enable the mysql extension you'll need to find the following in the php.ini:
[code];extension=php_mysql.dll[/code]
Then you remove the semi-colon from the start of that line. Or if you want use the MySQL Improved Extension you need to add [b]extension=php_mysqli.dll[/b] to end of the extension list in the php.ini

Now before you save the php.ini and restart the server you need to make sure the extension_dir directive is setup correctly. To setup the extension_dir scroll up and find this:
[code]; Directory in which the loadable extensions (modules) reside.[/code]

Below that line should be the extension_dir directive. By defualt it will be this:
[code]extension_dir = "./"[/code]
Change [B]./[/B] to [B]C:\php\ext[/B]
PHP will use this directive to find the extensions.

Now save the php.ini and restart your server. Note: make sure a file called libmysql.dll (with is found in the root of the PHP folder (C:\php)) is either in the C:\WINDOWS folder. Note if you are on Win2k or on Windows Server xxxx you put it in the C:\WINNT folder

Also it doesnt matter which version of MySQL you have as you can use the php_mysql.dll extension on either version of MySQL. You dont need to enable the php_mysqli.dll function if you are using MySQL5.

The thing that sepends on which extension you use is down to the type of mysql functions you are using For example if you are using the [b]mysql_connect[/b] function to connect to MySQL or any other mysql_*() function you use the [b]php_mysql.dll[/b] extension.
But if you are using the [b]mysql[color=red]i[/color]_connect[/b] (note the i after mysql) function to connect to MySQL or any other mysql[b]i[/b]_*() function then you use the [b]php_mysqli.dll[/b] extension.
  • 4 weeks later...
  • 1 month later...
[b][u]RESOLVED[/u][/b]

Yet again...I had to reformat my hard drive and now I get to do all of this all over again...

I'm getting a "Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\emerge\ContactList.php on line 134" again...

php.ini is as follows...

[quote]
;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;

; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
;
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"

; The root of the PHP pages, used only if nonempty.
; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root
; if you are running php as a CGI under any web server (other than IIS)
; see documentation for security issues.  The alternate is to use the
; cgi.force_redirect configuration below
doc_root =C:\inetpub\wwwroot\

; The directory under which PHP opens the script using /~username used only
; if nonempty.
user_dir =

; Directory in which the loadable extensions (modules) reside.
extension_dir = C:\php\ext

; Whether or not to enable the dl() function.  The dl() function does NOT work
; properly in multithreaded servers, such as IIS or Zeus, and is automatically
; disabled on them.
enable_dl = Off

;;;;;;;;;;;;;;;;;;
;dynamic extentions
;;;;;;;;;;;;;;;;;;

extension=php_mysql.dll

[MySQL]
; Allow or prevent persistent links.
mysql.allow_persistent = On

; Maximum number of persistent links.  -1 means no limit.
mysql.max_persistent = -1

; Maximum number of links (persistent + non-persistent).  -1 means no limit.
mysql.max_links = -1

; Default port number for mysql_connect().  If unset, mysql_connect() will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
; compile-time value defined MYSQL_PORT (in that order).  Win32 will only look
; at MYSQL_PORT.
mysql.default_port =

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
mysql.default_socket =

; Default host for mysql_connect() (doesn't apply in safe mode).
mysql.default_host = localhost

; Default user for mysql_connect() (doesn't apply in safe mode).
mysql.default_user =localhost

; Default password for mysql_connect() (doesn't apply in safe mode).
; Note that this is generally a *bad* idea to store passwords in this file.
; *Any* user with PHP access can run 'echo get_cfg_var("mysql.default_password")
; and reveal this password!  And of course, any users with read access to this
; file will be able to reveal the password as well.
mysql.default_password =dsartain

; Maximum time (in secondes) for connect timeout. -1 means no limit
mysql.connect_timeout = 5000

; Trace mode. When trace_mode is active (=On), warnings for table/index scans and
; SQL-Errors will be displayed.
mysql.trace_mode = Off
[/quote]

The php_mysql.dll and the libmysql.dll file is in the C:\php and C:\php\ext directories.  libmysql.dll is also in the C:\WINNT (running Win2K) directory.  I've restarted my IIS (version 4) server and still get the error...What am I missing???

Sorry to post this issue again...

EDIT::I fixed this.  I hadn't added the PHPRC=C:\php to the environment variables for Win2K...thanks though...
  • 2 months later...
I have this problem: [b]Cannot load mysql extension. Please check your PHP configuration. - Documentation[/b]

The [b]extension_dir[/b] in phpinfo shows [b]c:\php5[/b], yet i definetely have [b]extension_dir[/b] set to [b]c:\php\ext[/b] in the [b]php.ini[/b] file. What am i doing wrong?

Despite php.ini being in [b]c:\php[/b], in phpinfo() it says: [b]Configuration File (php.ini) Path C:\WINDOWS[/b] - I dont understand this either. Can someone help please...

Thank you

Shears :)
Do you have the php.ini file in more than one place on your HD?  Have you added the directory where your php.ini file is located (i.e. C:\php) to your Windows Path??  If you installed PHP5, are you sure the directory isn't C:\php5 instead of C:\php??  If this doesn't help, please copy and paste your php.ini content as a quote so we can look at it...maybe something is commented out or something.
[quote author=Shears link=topic=87276.msg498622#msg498622 date=1168134461]
I have this problem: [b]Cannot load mysql extension. Please check your PHP configuration. - Documentation[/b]

The [b]extension_dir[/b] in phpinfo shows [b]c:\php5[/b], yet i definetely have [b]extension_dir[/b] set to [b]c:\php\ext[/b] in the [b]php.ini[/b] file. What am i doing wrong?

Despite php.ini being in [b]c:\php[/b], in phpinfo() it says: [b]Configuration File (php.ini) Path C:\WINDOWS[/b] - I dont understand this either. Can someone help please...

Thank you

Shears :)

[/quote]
Its because PHP cannot find the php.ini

PHP looks in the following places for the php.ini
- C:/WINDOWS or C:/WINDOWS/SYSTEM32
- Or in the Windows PATH variable

I would recommend you to add PHP to PATH.
Hello .Thank you for your replies :)

[quote author=dsartain link=topic=87276.msg498798#msg498798 date=1168151433]
Do you have the php.ini file in more than one place on your HD?  Have you added the directory where your php.ini file is located (i.e. C:\php) to your Windows Path?? [/quote]If you mean, have i entered it in Environmental Variables > System Variables, yes i have.

[quote]If you installed PHP5, are you sure the directory isn't C:\php5 instead of C:\php??[/quote] I have checked this about 100 times, but i guess it can hurt check another... Ok, yes it is definetely [b]C:\php[/b].

[quote]If this doesn't help, please copy and paste your php.ini content as a quote so we can look at it...maybe something is commented out or something.
[/quote]
Please attach the php.ini to your post. You can do this by doing the following:
Click the Modify button for your post above this.

Expand the Additional Options area. Now attahc your php.ini file to the post. Click Save button. php.ini should now be attached to your post.

Also when you added PHP to the path you did restart your PC? You must restart your PC in order for the changes to the PATH to be made.
One other thing, you have to create a new Environment Variable called PHPRC, see the php documentation to find the appropriate value, mine is "C:\php"  PHP documentation is located http://www.php.net/manual/en/  So you may want to ensure that you've followed all of the steps precisely.

Also, if you haven't already, you need to make some modifications to IIS (or Apache) to run PHP as well, consult the php documentation for instructions on that as well.

Let me know if you need anything else...
  • 1 year later...
Hello,

I installed My SQL version 5.0.51a (msi) and PHP version 5.2.5 (msi). But when I run the script, the error message saying that there is no "My SQL extensions".

In fact, when I installed PHP, I selected to install My SQL extensions. Please note that I installed by msi installer package.

PHP.ini include for My SQL extensions. Please see the followings.

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

php_mysql.dll is located at C:\PHP\ext.

libmysql.dll is located at C:\PHP

C:\PHP is also in the PATH.

But it didn't work. After reading this forum, I moved "php.ini" to C:\Windows directory and "phpinfo()" now include the section for "My SQL".

Again I tried to run the script below and it return "Unable to connect to MySQL".

Could you advice on that?


<?php
$username = "pee_wee";
$password = "let_me_in";
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
print "Connected to MySQL<br>";
// you're going to do lots more here soon
mysql_close($dbh);
?>

Thanks.

Tin Aung Soe
  • 2 months later...
I'm having an error connecting to the database for the admin section of my website and I think it relates to this topic. It's weird because I'm able to connect to the database for every other section of the site. Here is the error when I try to log in to the admin section:

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /data/16/1/57/83/1546246/user/1664829/htdocs/admin/functions.php on line 6
Database connectivity Error

The function in question (line 6 is the if statement):

function dbcon(){
global $host, $user, $pass, $db,$link;
if(!($link=mysql_connect($host,$user,$pass) && mysql_select_db($db)))
{
sprintf("Internal error %d %s",mysql_errno(),mysql_error());
return 0;
}
else
{
return 1;
}
}


Everything works fine in PHP4, its when I switched to PHP5 that I started getting errors. Any idea whats wrong?
Has nothing to do with the mysql extension not being bundled.

If you manage your own server, ensure that the server is running (probably it is) on the local machine, and make sure right socket file is used. This should help with that:

http://www.tech-recipes.com/mysql_tips762.html

If not, contact your host.
  • 1 month later...
Guest
This topic is now closed to further replies.
×
×
  • 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.