PHP MySQL Error

Programming, for all ages and all languages.
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

PHP MySQL Error

Post by XCHG »

So I'm learning PHP and I got this error message while invoking the mysql_pconnect() function:

[quote=Server]Fatal error: Call to undefined function mysqli_pconnect() in C:\Inetpub\wwwroot\index.php on line 16[/quote]

I searched on the Internet and apparently it means that the version of PHP that I have is not compiled with support for MySQL. Does anybody know how I can fix this or is there a way to work around this problem without needing to compile anything?
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: PHP MySQL Error

Post by Solar »

XCHG wrote:Does anybody know how I can fix this or is there a way to work around this problem without needing to compile anything?
Google "Windows PHP MySQLi".

First thought:

USE="mysqli" emerge php - OK, that's Gentoo Linux, scratch that thought.

Second hit:

Installed PHP5/Apache 2.0/MySQLi -- Yay me!

Third hit:

PHP: mysqli

Fourth hit:

MySQL AB: Download Connector / PHP
Every good solution is obvious once you've found it.
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post by XCHG »

Solar,

Thanks for the prompt reply. I was actually looking at this link but didn't bother with MySQLi. I followed the instructions but now I am getting the same exact error but this time for mysqli of course. I am using:

MySQL 5.0.51a
PHP 5.2.5 (With PHP ISAPI on IIS)
IIS 5.1 on Windows XP SP2

Some of the links also state that PHP should be recompiled even if I want the mysqli extension. Is that correct?
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

No idea... never used PHP / MySQL on Windows. (See my first thought. 8) )
Every good solution is obvious once you've found it.
DeletedAccount
Member
Member
Posts: 566
Joined: Tue Jun 20, 2006 9:17 am

Post by DeletedAccount »

How about using XAMPP .... :?: :D
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

If you want support, I suggest using linux.

Please don't flame - I'm not suggesting this because of hippiness or simple-mindedness. Most php tutorials (including environment setup) assume a LAMP configuration (Linux, Apache, MySQL, PHP), for the simple reason that windows is hardly ever used on the web. IIS is not used that much, and when it is used it is by large businesses who have "enterprise" software in .NET or some similar M$-ised language.

If you run linux, even in a VM, it'll make your setup life a hell of a lot easier. Also it'll help you avoid scratching your chin when that syscall or that bit of inline BASH script in the example PHP scripts work on linux but not on windows! ;)
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Post by 01000101 »

have you looked at the phpinfo()??
are you 100% sure that MySQL & MySQLi are BOTH enabled in the PHP.ini and that the php.ini is even loaded properly?
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post by XCHG »

01000101 wrote:have you looked at the phpinfo()??
are you 100% sure that MySQL & MySQLi are BOTH enabled in the PHP.ini and that the php.ini is even loaded properly?
Wow. phpinfo() doesn't include anything about MySQL in the report except for the PATH that I have included :?:
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
User avatar
B.E
Member
Member
Posts: 275
Joined: Sat Oct 21, 2006 5:29 pm
Location: Brisbane Australia
Contact:

Post by B.E »

from this (quote from MySQL page):
http://au2.php.net/manual/en/ref.mysql.php
PHP 5+

MySQL is no longer enabled by default, so the php_mysql.dll DLL must be enabled inside of php.ini. Also, PHP needs access to the MySQL client library. A file named libmysql.dll is included in the Windows PHP distribution and in order for PHP to talk to MySQL this file needs to be available to the Windows systems PATH. See the FAQ titled "How do I add my PHP directory to the PATH on Windows" for information on how to do this. Although copying libmysql.dll to the Windows system directory also works (because the system directory is by default in the system's PATH), it's not recommended.

As with enabling any PHP extension (such as php_mysql.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

Note: If when starting the web server an error similar to the following occurs: "Unable to load dynamic library './php_mysql.dll'", this is because php_mysql.dll and/or libmysql.dll cannot be found by the system.

Image
Microsoft: "let everyone run after us. We'll just INNOV~1"
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post by XCHG »

Ironically, all of the information provided by the official website for PHP is literally useless about IIS/MySQL/PHP. I followed this link which explained what I had to do and everything works now; finally, after 2-3 days.

Thanks guys. I appreciate your help.
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post by XCHG »

Oh and also may I add that I got sick of IIS and installed Apache 2.0. Apparently Apache 2.2.x is not compatible with PHP5; I tried it actually and it didn't work so...
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Post by 01000101 »

I love IIS... that's what I use for my web-server.

IIS7 is AMAZING. I used to run Server2008 w/ IIS7, and it was probably one of the most user-friendly environments out there.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

Apache 2.2.x *IS* compatible with PHP5 - I setup a Windows-based server two weeks ago with Apache 2.2.0, PHP5 and MySQL and it's still running smoothly. You just need to make sure all the DLLs are referenced properly in all the configuration files.
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post by XCHG »

pcmattman wrote:Apache 2.2.x *IS* compatible with PHP5 - I setup a Windows-based server two weeks ago with Apache 2.2.0, PHP5 and MySQL and it's still running smoothly. You just need to make sure all the DLLs are referenced properly in all the configuration files.
Really? I tried and it didn't work especially when I noticed that PHP.ini wasn't even being read and that I didn't have any other copies of the file anywhere in the PATH. I even removed its contents and saved it and it didn't change anything :!:
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

PhpIniDir in Apache's httpd.conf?

Edit: Also, you'd have to setup the handlers for PHP, though I'm pretty sure that you would've already done that.
Post Reply