Trouble configuring PHP for use with MySQL

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Bacu
Forum Newbie
Posts: 3
Joined: Sun May 09, 2010 9:56 pm

Trouble configuring PHP for use with MySQL

Post by Bacu »

After enabling MySQL in the .ini, it still doesn't work. Any page that I try to use MySQL in won't yield anything but a blank screen, but no outright errors. phpinfo doesn't say that MySQL module is enabled. Any suggestions?
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: Trouble configuring PHP for use with MySQL

Post by mikosiko »

show/tell us:
- few lines around the line where did you enabled MySql
- your platform... windows/Linux?
- some of the code that you are using for testing

in your php.ini what is the value of the variable "extension_dir" ?

are you sure that in the folder indicated in extension_dir you have the php_mysql.dll or php_mysqli.dll ?
Bacu
Forum Newbie
Posts: 3
Joined: Sun May 09, 2010 9:56 pm

Re: Trouble configuring PHP for use with MySQL

Post by Bacu »

Code: Select all

<?php
$mysqli = new mysqli("localhost", "root", "pass", "DB");
if (mysqli_connect_errno()){
	printf("connection failed: %s\n", mysqli_connect_error());
	exit();
	} else {
		printf("host information %s\n", mysqli_get_host_info($mysqli));
		mysqli_close($mysqli)}
?>
Just a simple chunk to test connection or not, before I start trying to figure it out.

on windows.

Code: Select all

extension_dir = "./"
There is no php_mysql.dll or php_mysqli.dll, I'm guessing that's part of the problem.
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: Trouble configuring PHP for use with MySQL

Post by mikosiko »

Bacu wrote:There is no php_mysql.dll or php_mysqli.dll, I'm guessing that's part of the problem.
for sure it is the problem.

- your extension_dir must point to the "ext" folder under your PHP directory installation
- php_mysql.dll or php_mysqli.dll (ideally both but only 1 is required.. looking your code you need the second one) must be present under the "ext" directory.

set it up and be sure to re-start Apache and check again with phpinfo()
Bacu
Forum Newbie
Posts: 3
Joined: Sun May 09, 2010 9:56 pm

Re: Trouble configuring PHP for use with MySQL

Post by Bacu »

php_mysqli.dll is in /ext

changed extension_dir to C:\php\ext

Still nothing.
Post Reply