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.
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 ?
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
I'm jealous. My hosting company doesn't have mcrypt. LOL
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.
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?
Removed it a restarted the server.
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.
Check your firewall, it may be blocking access to the port
Turned off all firewalls and still getting the same messages.
Try going back to using localhost for the hostname
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.
Verify the mysql server is running and boud to a network port as opposed to trying to use a socket.
Apache is running on port 80.
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?
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"!