mdragotta1 — 2011-02-05T15:34:41-05:00 — #1
I know there's another thread on this but it doesn't help me.
Reading Database Driven Websites and I come to this error when I try to run this code:
$link = mysqli_connect('localhost', 'root', 'password');
$output = 'Unable to connect to the datbase server.';
if (!mysqli_set_charset($link, 'utf8'))
$output = 'Unable to set database connection encoding.';
if (!mysqli_select_db($link, 'ijdb'))
$output = 'Unable to locate the joke database.';
$output = 'Database connection established.';
Of course, I filled in password with my real password. I checked my PHP info and the Loaded Configuration File was configured correctly i.e. extension=php_mysqli.dll was uncommented in php.ini. My php version is 5.3.5. I installed the thread safe version of PHP. I tried changing the localhost to 127.0.0.1. I tried everything in that thread and nothing helps. I can't even get a different error message. It just keeps coming up: Fatal error: Call to undefined function mysqli_connect() in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 2.
Can someone please help. I'm itching to move on in the book. Thanks in advance.
spacephoenix — 2011-02-05T15:47:47-05:00 — #2
Run the following:
echo 'The following PHP extensions are loaded on this server';
It will list all the PHP extensions which are currently loaded on the server concerned. Is there an entry in the outputted list for mysqli ?
mdragotta1 — 2011-02-05T15:50:34-05:00 — #3
This is what I get:
The following PHP extensions are loaded on this server
 => Core
 => bcmath
 => calendar
 => com_dotnet
 => ctype
 => date
 => ereg
 => filter
 => ftp
 => hash
 => iconv
 => json
 => mcrypt
 => SPL
 => odbc
 => pcre
 => Reflection
 => session
 => standard
 => mysqlnd
 => tokenizer
 => zip
 => zlib
 => libxml
 => dom
 => PDO
 => Phar
 => SimpleXML
 => wddx
 => xml
 => xmlreader
 => xmlwriter
 => apache2handler
 => mhash
kevinslair — 2011-02-05T17:47:48-05:00 — #4
I'm jealous. My hosting company doesn't have mcrypt. LOL
mdragotta1 — 2011-02-05T18:33:57-05:00 — #5
Can someone please help me with this? I've been all over the internet looking for a solution and I literally can't find anything that helps.
spacephoenix — 2011-02-05T18:36:33-05:00 — #6
Did you remove the ; from in front of the extension=php_mysqli.dll or was it not there, if you removed it, did you reboot the server afterwards?
mdragotta1 — 2011-02-05T18:37:45-05:00 — #7
Removed it a restarted the server.
mdragotta1 — 2011-02-05T18:59:53-05:00 — #8
Ok. I figured out the original problem but now I get these error messages:
Warning: mysqli_connect() function.mysqli-connect:  No connection could be made because the target machine actively (trying to connect via tcp://127.0.0.1:3306) in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 2
Warning: mysqli_connect() No connection could be made because the target machine actively refused it. in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 2
Any suggestions for these new problems? Thanks.
spacephoenix — 2011-02-05T19:36:53-05:00 — #9
Check your firewall, it may be blocking access to the port
mdragotta1 — 2011-02-05T20:00:37-05:00 — #10
Turned off all firewalls and still getting the same messages.
spacephoenix — 2011-02-05T20:10:33-05:00 — #11
Try going back to using localhost for the hostname
mdragotta1 — 2011-02-05T20:18:11-05:00 — #12
Yeah, tried that too. The error message just changes from: (trying to connect via tcp://127.0.0.3:3306)
to: (trying to connect via tcp://localhost:3306)
Wow. I've been at this for hours and I just can't find a solution. Very frustrating.
chriswiegman — 2011-02-05T22:17:24-05:00 — #13
Verify the mysql server is running and boud to a network port as opposed to trying to use a socket.
mdragotta1 — 2011-02-05T22:50:35-05:00 — #14
Apache is running on port 80.
hughesa — 2011-03-16T16:59:09-04:00 — #15
You said you have figured out the original problem. I am experiencing the exact same problem, would you care to share with me the solution?
artin — 2011-05-09T17:30:10-04:00 — #16
If you're getting the error message:
Fatal error: Call to undefined function mysqli_connect()
then, the "mysqli" module is probably not being loaded by php. You can confirm this by running phpinfo(); in your php code. If "mysqli" is not listed in the resulting page, then it is not being loaded.
I'm using php 5.3.6, and mysql 14.14 on Windows 7. The solution that successfully loads "mysqli" for me (and prevents the above error message) is to download "libmysql.dll" from libmysql.dll free download - DLL-files.com and put it in my path, or just copy it to my Windows folder.
Ironically, I found this solution by reading PHP: Installation - Manual, which says that for php 5.3.0+ you don't need to configure access to "libmysql.dll"!